1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "qquickitemsmodule_p.h"
44 #include "qquickitem.h"
45 #include "qquickitem_p.h"
46 #include "qquickevents_p_p.h"
47 #include "qquickrectangle_p.h"
48 #include "qquickfocusscope_p.h"
49 #include "qquicktext_p.h"
50 #include "qquicktextinput_p.h"
51 #include "qquicktextedit_p.h"
52 #include "qquickimage_p.h"
53 #include "qquickborderimage_p.h"
54 #include "qquickscalegrid_p_p.h"
55 #include "qquickmousearea_p.h"
56 #include "qquickpincharea_p.h"
57 #include "qquickflickable_p.h"
58 #include "qquickflickable_p_p.h"
59 #include "qquicklistview_p.h"
60 #include "qquickvisualitemmodel_p.h"
61 #include "qquickvisualdatamodel_p.h"
62 #include "qquickgridview_p.h"
63 #include "qquickpathview_p.h"
64 #include <private/qquickpath_p.h>
65 #include <private/qquickpathinterpolator_p.h>
66 #include "qquickpositioners_p.h"
67 #include "qquickrepeater_p.h"
68 #include "qquickloader_p.h"
69 #include "qquickanimatedimage_p.h"
70 #include "qquickflipable_p.h"
71 #include "qquicktranslate_p.h"
72 #include "qquickstateoperations_p.h"
73 #include "qquickitemanimation_p.h"
74 #include <private/qquickshadereffect_p.h>
75 #include <QtQuick/private/qquickshadereffectsource_p.h>
76 //#include <private/qquickpincharea_p.h>
77 #include <QtQuick/private/qquickcanvasitem_p.h>
78 #include <QtQuick/private/qquickcontext2d_p.h>
79 #include "qquicksprite_p.h"
80 #include "qquickspriteimage_p.h"
81 #include "qquickdrag_p.h"
82 #include "qquickdroparea_p.h"
83 #include "qquickmultipointtoucharea_p.h"
84 #include <private/qqmlmetatype_p.h>
85 #include <QtQuick/private/qquickaccessibleattached_p.h>
87 static QQmlPrivate::AutoParentResult qquickitem_autoParent(QObject *obj, QObject *parent)
89 QQuickItem *item = qobject_cast<QQuickItem *>(obj);
91 return QQmlPrivate::IncompatibleObject;
93 QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent);
95 return QQmlPrivate::IncompatibleParent;
97 item->setParentItem(parentItem);
98 return QQmlPrivate::Parented;
101 static bool compareQQuickAnchorLines(const void *p1, const void *p2)
103 const QQuickAnchorLine &l1 = *static_cast<const QQuickAnchorLine*>(p1);
104 const QQuickAnchorLine &l2 = *static_cast<const QQuickAnchorLine*>(p2);
108 static void qt_quickitems_defineModule(const char *uri, int major, int minor)
110 QQmlPrivate::RegisterAutoParent autoparent = { 0, &qquickitem_autoParent };
111 QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent);
112 QQuickItemPrivate::registerAccessorProperties();
115 qmlRegisterTypeNotAvailable(uri,major,minor,"AnimatedImage", qApp->translate("QQuickAnimatedImage","Qt was built without support for QMovie"));
117 qmlRegisterType<QQuickAnimatedImage>(uri,major,minor,"AnimatedImage");
119 qmlRegisterType<QQuickBorderImage>(uri,major,minor,"BorderImage");
120 qmlRegisterType<QQuickColumn>(uri,major,minor,"Column");
121 qmlRegisterType<QQuickFlickable>(uri,major,minor,"Flickable");
122 qmlRegisterType<QQuickFlipable>(uri,major,minor,"Flipable");
123 qmlRegisterType<QQuickFlow>(uri,major,minor,"Flow");
124 // qmlRegisterType<QQuickFocusPanel>(uri,major,minor,"FocusPanel");
125 qmlRegisterType<QQuickFocusScope>(uri,major,minor,"FocusScope");
126 qmlRegisterType<QQuickGradient>(uri,major,minor,"Gradient");
127 qmlRegisterType<QQuickGradientStop>(uri,major,minor,"GradientStop");
128 qmlRegisterType<QQuickGrid>(uri,major,minor,"Grid");
129 qmlRegisterType<QQuickGridView>(uri,major,minor,"GridView");
130 qmlRegisterType<QQuickImage>(uri,major,minor,"Image");
131 qmlRegisterType<QQuickItem>(uri,major,minor,"Item");
132 qmlRegisterType<QQuickListView>(uri,major,minor,"ListView");
133 qmlRegisterType<QQuickLoader>(uri,major,minor,"Loader");
134 qmlRegisterType<QQuickMouseArea>(uri,major,minor,"MouseArea");
135 qmlRegisterType<QQuickPath>(uri,major,minor,"Path");
136 qmlRegisterType<QQuickPathAttribute>(uri,major,minor,"PathAttribute");
137 qmlRegisterType<QQuickPathCubic>(uri,major,minor,"PathCubic");
138 qmlRegisterType<QQuickPathLine>(uri,major,minor,"PathLine");
139 qmlRegisterType<QQuickPathPercent>(uri,major,minor,"PathPercent");
140 qmlRegisterType<QQuickPathQuad>(uri,major,minor,"PathQuad");
141 qmlRegisterType<QQuickPathCatmullRomCurve>("QtQuick",2,0,"PathCurve");
142 qmlRegisterType<QQuickPathArc>("QtQuick",2,0,"PathArc");
143 qmlRegisterType<QQuickPathSvg>("QtQuick",2,0,"PathSvg");
144 qmlRegisterType<QQuickPathView>(uri,major,minor,"PathView");
145 qmlRegisterUncreatableType<QQuickBasePositioner>(uri,major,minor,"Positioner",
146 QStringLiteral("Positioner is an abstract type that is only available as an attached property."));
147 #ifndef QT_NO_VALIDATOR
148 qmlRegisterType<QQuickIntValidator>(uri,major,minor,"IntValidator");
149 qmlRegisterType<QQuickDoubleValidator>(uri,major,minor,"DoubleValidator");
150 qmlRegisterType<QRegExpValidator>(uri,major,minor,"RegExpValidator");
152 qmlRegisterType<QQuickRectangle>(uri,major,minor,"Rectangle");
153 qmlRegisterType<QQuickRepeater>(uri,major,minor,"Repeater");
154 qmlRegisterType<QQuickRow>(uri,major,minor,"Row");
155 qmlRegisterType<QQuickTranslate>(uri,major,minor,"Translate");
156 qmlRegisterType<QQuickRotation>(uri,major,minor,"Rotation");
157 qmlRegisterType<QQuickScale>(uri,major,minor,"Scale");
158 qmlRegisterType<QQuickText>(uri,major,minor,"Text");
159 qmlRegisterType<QQuickTextEdit>(uri,major,minor,"TextEdit");
160 qmlRegisterType<QQuickTextInput>(uri,major,minor,"TextInput");
161 qmlRegisterType<QQuickViewSection>(uri,major,minor,"ViewSection");
162 qmlRegisterType<QQuickVisualDataModel>(uri,major,minor,"VisualDataModel");
163 qmlRegisterType<QQuickVisualDataGroup>(uri,major,minor,"VisualDataGroup");
164 qmlRegisterType<QQuickVisualItemModel>(uri,major,minor,"VisualItemModel");
166 qmlRegisterType<QQuickItemLayer>();
167 qmlRegisterType<QQuickAnchors>();
168 qmlRegisterType<QQuickKeyEvent>();
169 qmlRegisterType<QQuickMouseEvent>();
170 qmlRegisterType<QQuickTransform>();
171 qmlRegisterType<QQuickPathElement>();
172 qmlRegisterType<QQuickCurve>();
173 qmlRegisterType<QQuickScaleGrid>();
174 qmlRegisterType<QQuickTextLine>();
175 #ifndef QT_NO_VALIDATOR
176 qmlRegisterType<QValidator>();
178 qmlRegisterType<QQuickVisualModel>();
179 qmlRegisterType<QQuickPen>();
180 qmlRegisterType<QQuickFlickableVisibleArea>();
181 qRegisterMetaType<QQuickAnchorLine>("QQuickAnchorLine");
182 QQmlMetaType::setQQuickAnchorLineCompareFunction(compareQQuickAnchorLines);
184 qmlRegisterUncreatableType<QQuickKeyNavigationAttached>(uri,major,minor,"KeyNavigation",QQuickKeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
185 qmlRegisterUncreatableType<QQuickKeysAttached>(uri,major,minor,"Keys",QQuickKeysAttached::tr("Keys is only available via attached properties"));
186 qmlRegisterUncreatableType<QQuickLayoutMirroringAttached>(uri,major,minor,"LayoutMirroring", QQuickLayoutMirroringAttached::tr("LayoutMirroring is only available via attached properties"));
187 qmlRegisterUncreatableType<QQuickViewTransitionAttached>(uri,major,minor,"ViewTransition",QQuickViewTransitionAttached::tr("ViewTransition is only available via attached properties"));
189 qmlRegisterType<QQuickPinchArea>(uri,major,minor,"PinchArea");
190 qmlRegisterType<QQuickPinch>(uri,major,minor,"Pinch");
191 qmlRegisterType<QQuickPinchEvent>();
193 qmlRegisterType<QQuickShaderEffect>("QtQuick", 2, 0, "ShaderEffect");
194 qmlRegisterType<QQuickShaderEffectSource>("QtQuick", 2, 0, "ShaderEffectSource");
195 qmlRegisterUncreatableType<QQuickShaderEffectMesh>("QtQuick", 2, 0, "ShaderEffectMesh", QQuickShaderEffectMesh::tr("Cannot create instance of abstract class ShaderEffectMesh."));
196 qmlRegisterType<QQuickGridMesh>("QtQuick", 2, 0, "GridMesh");
198 qmlRegisterUncreatableType<QQuickPaintedItem>("QtQuick", 2, 0, "PaintedItem", QQuickPaintedItem::tr("Cannot create instance of abstract class PaintedItem"));
200 qmlRegisterType<QQuickCanvasItem>("QtQuick", 2, 0, "Canvas");
202 qmlRegisterType<QQuickSprite>("QtQuick", 2, 0, "Sprite");
203 qmlRegisterType<QQuickSpriteImage>("QtQuick", 2, 0, "SpriteImage");
205 qmlRegisterType<QQuickParentChange>(uri, major, minor,"ParentChange");
206 qmlRegisterType<QQuickAnchorChanges>(uri, major, minor,"AnchorChanges");
207 qmlRegisterType<QQuickAnchorSet>();
208 qmlRegisterType<QQuickAnchorAnimation>(uri, major, minor,"AnchorAnimation");
209 qmlRegisterType<QQuickParentAnimation>(uri, major, minor,"ParentAnimation");
210 qmlRegisterType<QQuickPathAnimation>("QtQuick",2,0,"PathAnimation");
211 qmlRegisterType<QQuickPathInterpolator>("QtQuick",2,0,"PathInterpolator");
213 qmlRegisterType<QQuickDropArea>("QtQuick", 2, 0, "DropArea");
214 qmlRegisterType<QQuickDropEvent>();
215 qmlRegisterType<QQuickDropAreaDrag>();
216 qmlRegisterUncreatableType<QQuickDrag>("QtQuick", 2, 0, "Drag", QQuickDragAttached::tr("Drag is only available via attached properties"));
218 qmlRegisterType<QQuickMultiPointTouchArea>("QtQuick", 2, 0, "MultiPointTouchArea");
219 qmlRegisterType<QQuickTouchPoint>("QtQuick", 2, 0, "TouchPoint");
220 qmlRegisterType<QQuickGrabGestureEvent>();
222 #ifndef QT_NO_ACCESSIBILITY
223 qmlRegisterUncreatableType<QQuickAccessibleAttached>("QtQuick", 2, 0, "Accessible",QQuickAccessibleAttached::tr("Accessible is only available via attached properties"));
227 void QQuickItemsModule::defineModule()
229 static bool initialized = false;
234 QByteArray name = "QtQuick";
235 int majorVersion = 2;
236 int minorVersion = 0;
238 qt_quickitems_defineModule(name, majorVersion, minorVersion);