Extract all QtQuick 1 elements into a separate library/plugin.
[profile/ivi/qtdeclarative.git] / src / qtquick1 / graphicsitems / qdeclarativeitemsmodule.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "QtQuick1/private/qdeclarativeitemsmodule_p.h"
43
44 #include <QtGui/qaction.h>
45 #include <QtGui/qvalidator.h>
46 #include <QtGui/qgraphicseffect.h>
47 #include <QtGui/qgraphicsitem.h>
48
49 #include "QtQuick1/private/qdeclarativeevents_p_p.h"
50 #include "QtQuick1/private/qdeclarativescalegrid_p_p.h"
51 #include "QtQuick1/private/qdeclarativeanimatedimage_p.h"
52 #include "QtQuick1/private/qdeclarativeborderimage_p.h"
53 #include "QtQuick1/private/qdeclarativepositioners_p.h"
54 #include "QtQuick1/private/qdeclarativemousearea_p.h"
55 #include "QtQuick1/private/qdeclarativeflickable_p.h"
56 #include "QtQuick1/private/qdeclarativeflickable_p_p.h"
57 #include "QtQuick1/private/qdeclarativeflipable_p.h"
58 #include "QtQuick1/private/qdeclarativefocuspanel_p.h"
59 #include "QtQuick1/private/qdeclarativefocusscope_p.h"
60 #include "QtQuick1/private/qdeclarativegridview_p.h"
61 #include "QtQuick1/private/qdeclarativeimage_p.h"
62 #include "QtQuick1/private/qdeclarativeitem_p.h"
63 #include "QtQuick1/private/qdeclarativelayoutitem_p.h"
64 #include "QtQuick1/private/qdeclarativelistview_p.h"
65 #include "QtQuick1/private/qdeclarativeloader_p.h"
66 #include "QtQuick1/private/qdeclarativemousearea_p.h"
67 #include "QtQuick1/private/qdeclarativepath_p.h"
68 #include "QtQuick1/private/qdeclarativepathview_p.h"
69 #include "QtQuick1/private/qdeclarativerectangle_p.h"
70 #include "QtQuick1/private/qdeclarativerepeater_p.h"
71 #include "QtQuick1/private/qdeclarativetranslate_p.h"
72 #include "QtQuick1/private/qdeclarativetext_p.h"
73 #include "QtQuick1/private/qdeclarativetextedit_p.h"
74 #include "QtQuick1/private/qdeclarativetextinput_p.h"
75 #include "QtQuick1/private/qdeclarativevisualitemmodel_p.h"
76 #include "QtQuick1/private/qdeclarativegraphicswidget_p.h"
77 #ifdef QT_WEBKIT_LIB
78 #include "QtQuick1/private/qdeclarativewebview_p.h"
79 #include "QtQuick1/private/qdeclarativewebview_p_p.h"
80 #endif
81 #include "QtQuick1/private/qdeclarativeanchors_p.h"
82 #include "QtQuick1/private/qdeclarativepincharea_p.h"
83
84 static QDeclarativePrivate::AutoParentResult qgraphicsobject_autoParent(QObject *obj, QObject *parent)
85 {
86     QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(obj);
87     if (!gobj)
88         return QDeclarativePrivate::IncompatibleObject;
89
90     QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parent);
91     if (!gparent)
92         return QDeclarativePrivate::IncompatibleParent;
93
94     gobj->setParentItem(gparent);
95     return QDeclarativePrivate::Parented;
96 }
97
98 void QDeclarative1ItemModule::defineModule(QDeclarativeQtQuick1Module::Module module)
99 {
100     QDeclarativePrivate::RegisterAutoParent autoparent = { 0, &qgraphicsobject_autoParent };
101     QDeclarativePrivate::qmlregister(QDeclarativePrivate::AutoParentRegistration, &autoparent);
102
103     qmlRegisterType<QDeclarative1Anchors>();
104     qmlRegisterType<QDeclarative1KeyEvent>();
105     qmlRegisterType<QDeclarative1MouseEvent>();
106     qmlRegisterType<QGraphicsObject>();
107     qmlRegisterType<QGraphicsTransform>();
108     qmlRegisterType<QDeclarative1PathElement>();
109     qmlRegisterType<QDeclarative1Curve>();
110     qmlRegisterType<QDeclarative1ScaleGrid>();
111 #ifndef QT_NO_VALIDATOR
112     qmlRegisterType<QValidator>();
113 #endif
114     qmlRegisterType<QDeclarative1VisualModel>();
115 #ifndef QT_NO_ACTION
116     qmlRegisterType<QAction>();
117 #endif
118     qmlRegisterType<QDeclarative1Pen>();
119     qmlRegisterType<QDeclarative1FlickableVisibleArea>();
120 #ifndef QT_NO_GRAPHICSEFFECT
121     qmlRegisterType<QGraphicsEffect>();
122 #endif
123
124     if (module == QDeclarativeQtQuick1Module::QtQuick1) {
125 #ifdef QT_NO_MOVIE
126         qmlRegisterTypeNotAvailable("QtQuick",1,0,"AnimatedImage",
127             qApp->translate("QDeclarative1AnimatedImage","Qt was built without support for QMovie"));
128 #else
129         qmlRegisterType<QDeclarative1AnimatedImage>("QtQuick",1,0,"AnimatedImage");
130 #endif
131         qmlRegisterType<QDeclarative1BorderImage>("QtQuick",1,0,"BorderImage");
132         qmlRegisterType<QDeclarative1Column>("QtQuick",1,0,"Column");
133         qmlRegisterType<QDeclarative1Drag>("QtQuick",1,0,"Drag");
134         qmlRegisterType<QDeclarative1Flickable>("QtQuick",1,0,"Flickable");
135         qmlRegisterType<QDeclarative1Flipable>("QtQuick",1,0,"Flipable");
136         qmlRegisterType<QDeclarative1Flow>("QtQuick",1,0,"Flow");
137         qmlRegisterType<QDeclarative1FocusPanel>("QtQuick",1,0,"FocusPanel");
138         qmlRegisterType<QDeclarative1FocusScope>("QtQuick",1,0,"FocusScope");
139         qmlRegisterType<QDeclarative1Gradient>("QtQuick",1,0,"Gradient");
140         qmlRegisterType<QDeclarative1GradientStop>("QtQuick",1,0,"GradientStop");
141         qmlRegisterType<QDeclarative1Grid>("QtQuick",1,0,"Grid");
142         qmlRegisterType<QDeclarative1GridView>("QtQuick",1,0,"GridView");
143         qmlRegisterType<QDeclarative1Image>("QtQuick",1,0,"Image");
144         qmlRegisterType<QDeclarativeItem>("QtQuick",1,0,"Item");
145         qmlRegisterType<QDeclarative1LayoutItem>("QtQuick",1,0,"LayoutItem");
146         qmlRegisterType<QDeclarative1ListView>("QtQuick",1,0,"ListView");
147         qmlRegisterType<QDeclarative1Loader>("QtQuick",1,0,"Loader");
148         qmlRegisterType<QDeclarative1MouseArea>("QtQuick",1,0,"MouseArea");
149         qmlRegisterType<QDeclarative1Path>("QtQuick",1,0,"Path");
150         qmlRegisterType<QDeclarative1PathAttribute>("QtQuick",1,0,"PathAttribute");
151         qmlRegisterType<QDeclarative1PathCubic>("QtQuick",1,0,"PathCubic");
152         qmlRegisterType<QDeclarative1PathLine>("QtQuick",1,0,"PathLine");
153         qmlRegisterType<QDeclarative1PathPercent>("QtQuick",1,0,"PathPercent");
154         qmlRegisterType<QDeclarative1PathQuad>("QtQuick",1,0,"PathQuad");
155         qmlRegisterType<QDeclarative1PathView>("QtQuick",1,0,"PathView");
156 #ifndef QT_NO_VALIDATOR
157         qmlRegisterType<QIntValidator>("QtQuick",1,0,"IntValidator");
158         qmlRegisterType<QDoubleValidator>("QtQuick",1,0,"DoubleValidator");
159         qmlRegisterType<QRegExpValidator>("QtQuick",1,0,"RegExpValidator");
160 #endif
161         qmlRegisterType<QDeclarative1Rectangle>("QtQuick",1,0,"Rectangle");
162         qmlRegisterType<QDeclarative1Repeater>("QtQuick",1,0,"Repeater");
163         qmlRegisterType<QGraphicsRotation>("QtQuick",1,0,"Rotation");
164         qmlRegisterType<QDeclarative1Row>("QtQuick",1,0,"Row");
165         qmlRegisterType<QDeclarative1Translate>("QtQuick",1,0,"Translate");
166         qmlRegisterType<QGraphicsScale>("QtQuick",1,0,"Scale");
167         qmlRegisterType<QDeclarative1Text>("QtQuick",1,0,"Text");
168         qmlRegisterType<QDeclarative1TextEdit>("QtQuick",1,0,"TextEdit");
169 #ifndef QT_NO_LINEEDIT
170         qmlRegisterType<QDeclarative1TextInput>("QtQuick",1,0,"TextInput");
171 #endif
172         qmlRegisterType<QDeclarative1ViewSection>("QtQuick",1,0,"ViewSection");
173         qmlRegisterType<QDeclarative1VisualDataModel>("QtQuick",1,0,"VisualDataModel");
174         qmlRegisterType<QDeclarative1VisualItemModel>("QtQuick",1,0,"VisualItemModel");
175
176         qmlRegisterType<QGraphicsWidget>("QtQuick",1,0,"QGraphicsWidget");
177         qmlRegisterExtendedType<QGraphicsWidget,QDeclarative1GraphicsWidget>("QtQuick",1,0,"QGraphicsWidget");
178
179         qmlRegisterUncreatableType<QDeclarative1KeyNavigationAttached>("QtQuick",1,0,"KeyNavigation",QDeclarative1KeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
180         qmlRegisterUncreatableType<QDeclarative1KeysAttached>("QtQuick",1,0,"Keys",QDeclarative1KeysAttached::tr("Keys is only available via attached properties"));
181
182         // QtQuick 1.1 items
183         qmlRegisterType<QDeclarative1PinchArea>("QtQuick",1,1,"PinchArea");
184         qmlRegisterType<QDeclarative1Pinch>("QtQuick",1,1,"Pinch");
185         qmlRegisterType<QDeclarative1PinchEvent>();
186         qmlRegisterType<QDeclarativeItem,1>("QtQuick",1,1,"Item");
187         qmlRegisterType<QDeclarative1MouseArea,1>("QtQuick",1,1,"MouseArea");
188         qmlRegisterType<QDeclarative1Flickable,1>("QtQuick",1,1,"Flickable");
189         qmlRegisterType<QDeclarative1ListView,1>("QtQuick",1,1,"ListView");
190         qmlRegisterType<QDeclarative1GridView,1>("QtQuick",1,1,"GridView");
191         qmlRegisterType<QDeclarative1Row,1>("QtQuick",1,1,"Row");
192         qmlRegisterType<QDeclarative1Grid,1>("QtQuick",1,1,"Grid");
193         qmlRegisterType<QDeclarative1Flow,1>("QtQuick",1,1,"Flow");
194         qmlRegisterType<QDeclarative1Repeater,1>("QtQuick",1,1,"Repeater");
195         qmlRegisterType<QDeclarative1Text,1>("QtQuick",1,1,"Text");
196         qmlRegisterType<QDeclarative1TextEdit,1>("QtQuick",1,1,"TextEdit");
197 #ifndef QT_NO_LINEEDIT
198         qmlRegisterType<QDeclarative1TextInput,1>("QtQuick",1,1,"TextInput");
199 #endif
200         qmlRegisterRevision<QDeclarative1ImageBase,1>("QtQuick",1,1);
201         qmlRegisterRevision<QDeclarative1ImplicitSizeItem,0>("QtQuick",1,0);
202         qmlRegisterRevision<QDeclarative1ImplicitSizeItem,1>("QtQuick",1,1);
203         qmlRegisterRevision<QDeclarative1ImplicitSizePaintedItem,0>("QtQuick",1,0);
204         qmlRegisterRevision<QDeclarative1ImplicitSizePaintedItem,1>("QtQuick",1,1);
205         qmlRegisterUncreatableType<QDeclarative1LayoutMirroringAttached>("QtQuick",1,1,"LayoutMirroring", QDeclarative1LayoutMirroringAttached::tr("LayoutMirroring is only available via attached properties"));
206     } else if (module == QDeclarativeQtQuick1Module::Qt47) {
207 #ifdef QT_NO_MOVIE
208         qmlRegisterTypeNotAvailable("Qt",4,7,"AnimatedImage",
209             qApp->translate("QDeclarative1AnimatedImage","Qt was built without support for QMovie"));
210 #else
211         qmlRegisterType<QDeclarative1AnimatedImage>("Qt",4,7,"AnimatedImage");
212 #endif
213         qmlRegisterType<QDeclarative1BorderImage>("Qt",4,7,"BorderImage");
214         qmlRegisterType<QDeclarative1Column>("Qt",4,7,"Column");
215         qmlRegisterType<QDeclarative1Drag>("Qt",4,7,"Drag");
216         qmlRegisterType<QDeclarative1Flickable>("Qt",4,7,"Flickable");
217         qmlRegisterType<QDeclarative1Flipable>("Qt",4,7,"Flipable");
218         qmlRegisterType<QDeclarative1Flow>("Qt",4,7,"Flow");
219         qmlRegisterType<QDeclarative1FocusPanel>("Qt",4,7,"FocusPanel");
220         qmlRegisterType<QDeclarative1FocusScope>("Qt",4,7,"FocusScope");
221         qmlRegisterType<QDeclarative1Gradient>("Qt",4,7,"Gradient");
222         qmlRegisterType<QDeclarative1GradientStop>("Qt",4,7,"GradientStop");
223         qmlRegisterType<QDeclarative1Grid>("Qt",4,7,"Grid");
224         qmlRegisterType<QDeclarative1GridView>("Qt",4,7,"GridView");
225         qmlRegisterType<QDeclarative1Image>("Qt",4,7,"Image");
226         qmlRegisterType<QDeclarativeItem>("Qt",4,7,"Item");
227         qmlRegisterType<QDeclarative1LayoutItem>("Qt",4,7,"LayoutItem");
228         qmlRegisterType<QDeclarative1ListView>("Qt",4,7,"ListView");
229         qmlRegisterType<QDeclarative1Loader>("Qt",4,7,"Loader");
230         qmlRegisterType<QDeclarative1MouseArea>("Qt",4,7,"MouseArea");
231         qmlRegisterType<QDeclarative1Path>("Qt",4,7,"Path");
232         qmlRegisterType<QDeclarative1PathAttribute>("Qt",4,7,"PathAttribute");
233         qmlRegisterType<QDeclarative1PathCubic>("Qt",4,7,"PathCubic");
234         qmlRegisterType<QDeclarative1PathLine>("Qt",4,7,"PathLine");
235         qmlRegisterType<QDeclarative1PathPercent>("Qt",4,7,"PathPercent");
236         qmlRegisterType<QDeclarative1PathQuad>("Qt",4,7,"PathQuad");
237         qmlRegisterType<QDeclarative1PathView>("Qt",4,7,"PathView");
238 #ifndef QT_NO_VALIDATOR
239         qmlRegisterType<QIntValidator>("Qt",4,7,"IntValidator");
240         qmlRegisterType<QDoubleValidator>("Qt",4,7,"DoubleValidator");
241         qmlRegisterType<QRegExpValidator>("Qt",4,7,"RegExpValidator");
242 #endif
243         qmlRegisterType<QDeclarative1Rectangle>("Qt",4,7,"Rectangle");
244         qmlRegisterType<QDeclarative1Repeater>("Qt",4,7,"Repeater");
245         qmlRegisterType<QGraphicsRotation>("Qt",4,7,"Rotation");
246         qmlRegisterType<QDeclarative1Row>("Qt",4,7,"Row");
247         qmlRegisterType<QDeclarative1Translate>("Qt",4,7,"Translate");
248         qmlRegisterType<QGraphicsScale>("Qt",4,7,"Scale");
249         qmlRegisterType<QDeclarative1Text>("Qt",4,7,"Text");
250         qmlRegisterType<QDeclarative1TextEdit>("Qt",4,7,"TextEdit");
251 #ifndef QT_NO_LINEEDIT
252         qmlRegisterType<QDeclarative1TextInput>("Qt",4,7,"TextInput");
253 #endif
254         qmlRegisterType<QDeclarative1ViewSection>("Qt",4,7,"ViewSection");
255         qmlRegisterType<QDeclarative1VisualDataModel>("Qt",4,7,"VisualDataModel");
256         qmlRegisterType<QDeclarative1VisualItemModel>("Qt",4,7,"VisualItemModel");
257
258         qmlRegisterType<QGraphicsWidget>("Qt",4,7,"QGraphicsWidget");
259         qmlRegisterExtendedType<QGraphicsWidget,QDeclarative1GraphicsWidget>("Qt",4,7,"QGraphicsWidget");
260
261         qmlRegisterUncreatableType<QDeclarative1KeyNavigationAttached>("Qt",4,7,"KeyNavigation",QDeclarative1KeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
262         qmlRegisterUncreatableType<QDeclarative1KeysAttached>("Qt",4,7,"Keys",QDeclarative1KeysAttached::tr("Keys is only available via attached properties"));
263     }
264 }
265
266
267