Qt 4.8
qdeclarativeitemsmodule.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "private/qdeclarativeitemsmodule_p.h"
43 
44 #include <QtGui/qaction.h>
45 #include <QtGui/qvalidator.h>
46 #include <QtGui/qgraphicseffect.h>
47 
48 #include "private/qdeclarativeevents_p_p.h"
49 #include "private/qdeclarativescalegrid_p_p.h"
50 #include "private/qdeclarativeanimatedimage_p.h"
51 #include "private/qdeclarativeborderimage_p.h"
52 #include "private/qdeclarativepositioners_p.h"
53 #include "private/qdeclarativemousearea_p.h"
54 #include "private/qdeclarativeflickable_p.h"
55 #include "private/qdeclarativeflickable_p_p.h"
56 #include "private/qdeclarativeflipable_p.h"
57 #include "private/qdeclarativefocuspanel_p.h"
58 #include "private/qdeclarativefocusscope_p.h"
59 #include "private/qdeclarativegridview_p.h"
60 #include "private/qdeclarativeimage_p.h"
61 #include "private/qdeclarativeitem_p.h"
62 #include "private/qdeclarativelayoutitem_p.h"
63 #include "private/qdeclarativelistview_p.h"
64 #include "private/qdeclarativeloader_p.h"
65 #include "private/qdeclarativemousearea_p.h"
66 #include "private/qdeclarativepath_p.h"
67 #include "private/qdeclarativepathview_p.h"
68 #include "private/qdeclarativerectangle_p.h"
69 #include "private/qdeclarativerepeater_p.h"
70 #include "private/qdeclarativetranslate_p.h"
71 #include "private/qdeclarativetext_p.h"
72 #include "private/qdeclarativetextedit_p.h"
73 #include "private/qdeclarativetextinput_p.h"
74 #include "private/qdeclarativevisualitemmodel_p.h"
75 #include "private/qdeclarativegraphicswidget_p.h"
76 #ifdef QT_WEBKIT_LIB
77 #include "private/qdeclarativewebview_p.h"
78 #include "private/qdeclarativewebview_p_p.h"
79 #endif
80 #include "private/qdeclarativeanchors_p.h"
81 #include "private/qdeclarativepincharea_p.h"
82 
84 {
86  if (!gobj)
88 
89  QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parent);
90  if (!gparent)
92 
93  gobj->setParentItem(gparent);
95 }
96 
98 {
100  return;
101 
104 #ifdef QT_NO_MOVIE
105  qmlRegisterTypeNotAvailable("QtQuick",1,0,"AnimatedImage",
106  qApp->translate("QDeclarativeAnimatedImage","Qt was built without support for QMovie"));
107 #else
108  qmlRegisterType<QDeclarativeAnimatedImage>("QtQuick",1,0,"AnimatedImage");
109 #endif
110  qmlRegisterType<QDeclarativeBorderImage>("QtQuick",1,0,"BorderImage");
111  qmlRegisterType<QDeclarativeColumn>("QtQuick",1,0,"Column");
112  qmlRegisterType<QDeclarativeDrag>("QtQuick",1,0,"Drag");
113  qmlRegisterType<QDeclarativeFlickable>("QtQuick",1,0,"Flickable");
114  qmlRegisterType<QDeclarativeFlipable>("QtQuick",1,0,"Flipable");
115  qmlRegisterType<QDeclarativeFlow>("QtQuick",1,0,"Flow");
116  qmlRegisterType<QDeclarativeFocusPanel>("QtQuick",1,0,"FocusPanel");
117  qmlRegisterType<QDeclarativeFocusScope>("QtQuick",1,0,"FocusScope");
118  qmlRegisterType<QDeclarativeGradient>("QtQuick",1,0,"Gradient");
119  qmlRegisterType<QDeclarativeGradientStop>("QtQuick",1,0,"GradientStop");
120  qmlRegisterType<QDeclarativeGrid>("QtQuick",1,0,"Grid");
121  qmlRegisterType<QDeclarativeGridView>("QtQuick",1,0,"GridView");
122  qmlRegisterType<QDeclarativeImage>("QtQuick",1,0,"Image");
123  qmlRegisterType<QDeclarativeItem>("QtQuick",1,0,"Item");
124  qmlRegisterType<QDeclarativeLayoutItem>("QtQuick",1,0,"LayoutItem");
125  qmlRegisterType<QDeclarativeListView>("QtQuick",1,0,"ListView");
126  qmlRegisterType<QDeclarativeLoader>("QtQuick",1,0,"Loader");
127  qmlRegisterType<QDeclarativeMouseArea>("QtQuick",1,0,"MouseArea");
128  qmlRegisterType<QDeclarativePath>("QtQuick",1,0,"Path");
129  qmlRegisterType<QDeclarativePathAttribute>("QtQuick",1,0,"PathAttribute");
130  qmlRegisterType<QDeclarativePathCubic>("QtQuick",1,0,"PathCubic");
131  qmlRegisterType<QDeclarativePathLine>("QtQuick",1,0,"PathLine");
132  qmlRegisterType<QDeclarativePathPercent>("QtQuick",1,0,"PathPercent");
133  qmlRegisterType<QDeclarativePathQuad>("QtQuick",1,0,"PathQuad");
134  qmlRegisterType<QDeclarativePathView>("QtQuick",1,0,"PathView");
135 #ifndef QT_NO_VALIDATOR
136  qmlRegisterType<QIntValidator>("QtQuick",1,0,"IntValidator");
137  qmlRegisterType<QDoubleValidator>("QtQuick",1,0,"DoubleValidator");
138  qmlRegisterType<QRegExpValidator>("QtQuick",1,0,"RegExpValidator");
139 #endif
140  qmlRegisterType<QDeclarativeRectangle>("QtQuick",1,0,"Rectangle");
141  qmlRegisterType<QDeclarativeRepeater>("QtQuick",1,0,"Repeater");
142  qmlRegisterType<QGraphicsRotation>("QtQuick",1,0,"Rotation");
143  qmlRegisterType<QDeclarativeRow>("QtQuick",1,0,"Row");
144  qmlRegisterType<QDeclarativeTranslate>("QtQuick",1,0,"Translate");
145  qmlRegisterType<QGraphicsScale>("QtQuick",1,0,"Scale");
146  qmlRegisterType<QDeclarativeText>("QtQuick",1,0,"Text");
147  qmlRegisterType<QDeclarativeTextEdit>("QtQuick",1,0,"TextEdit");
148 #ifndef QT_NO_LINEEDIT
149  qmlRegisterType<QDeclarativeTextInput>("QtQuick",1,0,"TextInput");
150 #endif
151  qmlRegisterType<QDeclarativeViewSection>("QtQuick",1,0,"ViewSection");
152  qmlRegisterType<QDeclarativeVisualDataModel>("QtQuick",1,0,"VisualDataModel");
153  qmlRegisterType<QDeclarativeVisualItemModel>("QtQuick",1,0,"VisualItemModel");
154 
155  qmlRegisterType<QDeclarativeAnchors>();
156  qmlRegisterType<QDeclarativeKeyEvent>();
157  qmlRegisterType<QDeclarativeMouseEvent>();
158  qmlRegisterType<QGraphicsObject>();
159  qmlRegisterType<QGraphicsWidget>("QtQuick",1,0,"QGraphicsWidget");
160  qmlRegisterExtendedType<QGraphicsWidget,QDeclarativeGraphicsWidget>("QtQuick",1,0,"QGraphicsWidget");
161  qmlRegisterType<QGraphicsTransform>();
162  qmlRegisterType<QDeclarativePathElement>();
163  qmlRegisterType<QDeclarativeCurve>();
164  qmlRegisterType<QDeclarativeScaleGrid>();
165 #ifndef QT_NO_VALIDATOR
166  qmlRegisterType<QValidator>();
167 #endif
168  qmlRegisterType<QDeclarativeVisualModel>();
169 #ifndef QT_NO_ACTION
170  qmlRegisterType<QAction>();
171 #endif
172  qmlRegisterType<QDeclarativePen>();
173  qmlRegisterType<QDeclarativeFlickableVisibleArea>();
174 #ifndef QT_NO_GRAPHICSEFFECT
175  qmlRegisterType<QGraphicsEffect>();
176 #endif
177 
178  qmlRegisterUncreatableType<QDeclarativeKeyNavigationAttached>("QtQuick",1,0,"KeyNavigation",QDeclarativeKeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
179  qmlRegisterUncreatableType<QDeclarativeKeysAttached>("QtQuick",1,0,"Keys",QDeclarativeKeysAttached::tr("Keys is only available via attached properties"));
180 
181  // QtQuick 1.1 items
182  qmlRegisterType<QDeclarativePinchArea>("QtQuick",1,1,"PinchArea");
183  qmlRegisterType<QDeclarativePinch>("QtQuick",1,1,"Pinch");
184  qmlRegisterType<QDeclarativePinchEvent>();
185  qmlRegisterType<QDeclarativeItem,1>("QtQuick",1,1,"Item");
186  qmlRegisterType<QDeclarativeMouseArea,1>("QtQuick",1,1,"MouseArea");
187  qmlRegisterType<QDeclarativeFlickable,1>("QtQuick",1,1,"Flickable");
188  qmlRegisterType<QDeclarativeListView,1>("QtQuick",1,1,"ListView");
189  qmlRegisterType<QDeclarativeGridView,1>("QtQuick",1,1,"GridView");
190  qmlRegisterType<QDeclarativeRow,1>("QtQuick",1,1,"Row");
191  qmlRegisterType<QDeclarativeGrid,1>("QtQuick",1,1,"Grid");
192  qmlRegisterType<QDeclarativeFlow,1>("QtQuick",1,1,"Flow");
193  qmlRegisterType<QDeclarativeRepeater,1>("QtQuick",1,1,"Repeater");
194  qmlRegisterType<QDeclarativeText,1>("QtQuick",1,1,"Text");
195  qmlRegisterType<QDeclarativeTextEdit,1>("QtQuick",1,1,"TextEdit");
196 #ifndef QT_NO_LINEEDIT
197  qmlRegisterType<QDeclarativeTextInput,1>("QtQuick",1,1,"TextInput");
198 #endif
199  qmlRegisterRevision<QDeclarativeImageBase,1>("QtQuick",1,1);
200  qmlRegisterRevision<QDeclarativeImplicitSizeItem,0>("QtQuick",1,0);
201  qmlRegisterRevision<QDeclarativeImplicitSizeItem,1>("QtQuick",1,1);
202  qmlRegisterRevision<QDeclarativeImplicitSizePaintedItem,0>("QtQuick",1,0);
203  qmlRegisterRevision<QDeclarativeImplicitSizePaintedItem,1>("QtQuick",1,1);
204  qmlRegisterUncreatableType<QDeclarativeLayoutMirroringAttached>("QtQuick",1,1,"LayoutMirroring", QDeclarativeLayoutMirroringAttached::tr("LayoutMirroring is only available via attached properties"));
205 }
206 
208 {
210  return;
211 
212 #ifdef QT_NO_MOVIE
213  qmlRegisterTypeNotAvailable("Qt",4,7,"AnimatedImage",
214  qApp->translate("QDeclarativeAnimatedImage","Qt was built without support for QMovie"));
215 #else
216  qmlRegisterType<QDeclarativeAnimatedImage>("Qt",4,7,"AnimatedImage");
217 #endif
218  qmlRegisterType<QDeclarativeBorderImage>("Qt",4,7,"BorderImage");
219  qmlRegisterType<QDeclarativeColumn>("Qt",4,7,"Column");
220  qmlRegisterType<QDeclarativeDrag>("Qt",4,7,"Drag");
221  qmlRegisterType<QDeclarativeFlickable>("Qt",4,7,"Flickable");
222  qmlRegisterType<QDeclarativeFlipable>("Qt",4,7,"Flipable");
223  qmlRegisterType<QDeclarativeFlow>("Qt",4,7,"Flow");
224  qmlRegisterType<QDeclarativeFocusPanel>("Qt",4,7,"FocusPanel");
225  qmlRegisterType<QDeclarativeFocusScope>("Qt",4,7,"FocusScope");
226  qmlRegisterType<QDeclarativeGradient>("Qt",4,7,"Gradient");
227  qmlRegisterType<QDeclarativeGradientStop>("Qt",4,7,"GradientStop");
228  qmlRegisterType<QDeclarativeGrid>("Qt",4,7,"Grid");
229  qmlRegisterType<QDeclarativeGridView>("Qt",4,7,"GridView");
230  qmlRegisterType<QDeclarativeImage>("Qt",4,7,"Image");
231  qmlRegisterType<QDeclarativeItem>("Qt",4,7,"Item");
232  qmlRegisterType<QDeclarativeLayoutItem>("Qt",4,7,"LayoutItem");
233  qmlRegisterType<QDeclarativeListView>("Qt",4,7,"ListView");
234  qmlRegisterType<QDeclarativeLoader>("Qt",4,7,"Loader");
235  qmlRegisterType<QDeclarativeMouseArea>("Qt",4,7,"MouseArea");
236  qmlRegisterType<QDeclarativePath>("Qt",4,7,"Path");
237  qmlRegisterType<QDeclarativePathAttribute>("Qt",4,7,"PathAttribute");
238  qmlRegisterType<QDeclarativePathCubic>("Qt",4,7,"PathCubic");
239  qmlRegisterType<QDeclarativePathLine>("Qt",4,7,"PathLine");
240  qmlRegisterType<QDeclarativePathPercent>("Qt",4,7,"PathPercent");
241  qmlRegisterType<QDeclarativePathQuad>("Qt",4,7,"PathQuad");
242  qmlRegisterType<QDeclarativePathView>("Qt",4,7,"PathView");
243 #ifndef QT_NO_VALIDATOR
244  qmlRegisterType<QIntValidator>("Qt",4,7,"IntValidator");
245  qmlRegisterType<QDoubleValidator>("Qt",4,7,"DoubleValidator");
246  qmlRegisterType<QRegExpValidator>("Qt",4,7,"RegExpValidator");
247 #endif
248  qmlRegisterType<QDeclarativeRectangle>("Qt",4,7,"Rectangle");
249  qmlRegisterType<QDeclarativeRepeater>("Qt",4,7,"Repeater");
250  qmlRegisterType<QGraphicsRotation>("Qt",4,7,"Rotation");
251  qmlRegisterType<QDeclarativeRow>("Qt",4,7,"Row");
252  qmlRegisterType<QDeclarativeTranslate>("Qt",4,7,"Translate");
253  qmlRegisterType<QGraphicsScale>("Qt",4,7,"Scale");
254  qmlRegisterType<QDeclarativeText>("Qt",4,7,"Text");
255  qmlRegisterType<QDeclarativeTextEdit>("Qt",4,7,"TextEdit");
256 #ifndef QT_NO_LINEEDIT
257  qmlRegisterType<QDeclarativeTextInput>("Qt",4,7,"TextInput");
258 #endif
259  qmlRegisterType<QDeclarativeViewSection>("Qt",4,7,"ViewSection");
260  qmlRegisterType<QDeclarativeVisualDataModel>("Qt",4,7,"VisualDataModel");
261  qmlRegisterType<QDeclarativeVisualItemModel>("Qt",4,7,"VisualItemModel");
262 
263  qmlRegisterType<QGraphicsWidget>("Qt",4,7,"QGraphicsWidget");
264  qmlRegisterExtendedType<QGraphicsWidget,QDeclarativeGraphicsWidget>("Qt",4,7,"QGraphicsWidget");
265 
266  qmlRegisterUncreatableType<QDeclarativeKeyNavigationAttached>("Qt",4,7,"KeyNavigation",QDeclarativeKeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
267  qmlRegisterUncreatableType<QDeclarativeKeysAttached>("Qt",4,7,"Keys",QDeclarativeKeysAttached::tr("Keys is only available via attached properties"));
268 }
static QDeclarativePrivate::AutoParentResult qgraphicsobject_autoParent(QObject *obj, QObject *parent)
void setParentItem(QGraphicsItem *parent)
Sets this item&#39;s parent item to newParent.
int Q_AUTOTEST_EXPORT qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString &message)
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define qApp
int Q_DECLARATIVE_EXPORT qmlregister(RegistrationType, void *)
The QGraphicsObject class provides a base class for all graphics items that require signals...
static Type type()
Returns the type of application (Tty , GuiClient, or GuiServer).