Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / qtquick1 / graphicsitems / qdeclarativeitemsmodule.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
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.
16 **
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.
20 **
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.
28 **
29 ** Other Usage
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.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "QtQuick1/private/qdeclarativeitemsmodule_p.h"
43
44 #include <QtWidgets/qaction.h>
45 #include <QtGui/qvalidator.h>
46 #include <QtWidgets/qgraphicseffect.h>
47 #include <QtWidgets/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 #include "QtQuick1/private/qdeclarativeanchors_p.h"
78 #include "QtQuick1/private/qdeclarativepincharea_p.h"
79 #include "QtQuick1/private/qdeclarativeaccessibleattached_p.h"
80
81 static QDeclarativePrivate::AutoParentResult qgraphicsobject_autoParent(QObject *obj, QObject *parent)
82 {
83     QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(obj);
84     if (!gobj)
85         return QDeclarativePrivate::IncompatibleObject;
86
87     QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parent);
88     if (!gparent)
89         return QDeclarativePrivate::IncompatibleParent;
90
91     gobj->setParentItem(gparent);
92     return QDeclarativePrivate::Parented;
93 }
94
95 void QDeclarative1ItemModule::defineModule(QDeclarativeQtQuick1Module::Module module)
96 {
97     QDeclarativePrivate::RegisterAutoParent autoparent = { 0, &qgraphicsobject_autoParent };
98     QDeclarativePrivate::qmlregister(QDeclarativePrivate::AutoParentRegistration, &autoparent);
99
100     qmlRegisterType<QDeclarative1Anchors>();
101     qmlRegisterType<QDeclarative1KeyEvent>();
102     qmlRegisterType<QDeclarative1MouseEvent>();
103     qmlRegisterType<QGraphicsObject>();
104     qmlRegisterType<QGraphicsTransform>();
105     qmlRegisterType<QDeclarative1PathElement>();
106     qmlRegisterType<QDeclarative1Curve>();
107     qmlRegisterType<QDeclarative1ScaleGrid>();
108 #ifndef QT_NO_VALIDATOR
109     qmlRegisterType<QValidator>();
110 #endif
111     qmlRegisterType<QDeclarative1VisualModel>();
112 #ifndef QT_NO_ACTION
113     qmlRegisterType<QAction>();
114 #endif
115     qmlRegisterType<QDeclarative1Pen>();
116     qmlRegisterType<QDeclarative1FlickableVisibleArea>();
117 #ifndef QT_NO_GRAPHICSEFFECT
118     qmlRegisterType<QGraphicsEffect>();
119 #endif
120
121     if (module == QDeclarativeQtQuick1Module::QtQuick1) {
122 #ifdef QT_NO_MOVIE
123         qmlRegisterTypeNotAvailable("QtQuick",1,0,"AnimatedImage",
124             qApp->translate("QDeclarative1AnimatedImage","Qt was built without support for QMovie"));
125 #else
126         qmlRegisterType<QDeclarative1AnimatedImage>("QtQuick",1,0,"AnimatedImage");
127 #endif
128         qmlRegisterType<QDeclarative1BorderImage>("QtQuick",1,0,"BorderImage");
129         qmlRegisterType<QDeclarative1Column>("QtQuick",1,0,"Column");
130         qmlRegisterType<QDeclarative1Drag>("QtQuick",1,0,"Drag");
131         qmlRegisterType<QDeclarative1Flickable>("QtQuick",1,0,"Flickable");
132         qmlRegisterType<QDeclarative1Flipable>("QtQuick",1,0,"Flipable");
133         qmlRegisterType<QDeclarative1Flow>("QtQuick",1,0,"Flow");
134         qmlRegisterType<QDeclarative1FocusPanel>("QtQuick",1,0,"FocusPanel");
135         qmlRegisterType<QDeclarative1FocusScope>("QtQuick",1,0,"FocusScope");
136         qmlRegisterType<QDeclarative1Gradient>("QtQuick",1,0,"Gradient");
137         qmlRegisterType<QDeclarative1GradientStop>("QtQuick",1,0,"GradientStop");
138         qmlRegisterType<QDeclarative1Grid>("QtQuick",1,0,"Grid");
139         qmlRegisterType<QDeclarative1GridView>("QtQuick",1,0,"GridView");
140         qmlRegisterType<QDeclarative1Image>("QtQuick",1,0,"Image");
141         qmlRegisterType<QDeclarativeItem>("QtQuick",1,0,"Item");
142         qmlRegisterType<QDeclarative1LayoutItem>("QtQuick",1,0,"LayoutItem");
143         qmlRegisterType<QDeclarative1ListView>("QtQuick",1,0,"ListView");
144         qmlRegisterType<QDeclarative1Loader>("QtQuick",1,0,"Loader");
145         qmlRegisterType<QDeclarative1MouseArea>("QtQuick",1,0,"MouseArea");
146         qmlRegisterType<QDeclarative1Path>("QtQuick",1,0,"Path");
147         qmlRegisterType<QDeclarative1PathAttribute>("QtQuick",1,0,"PathAttribute");
148         qmlRegisterType<QDeclarative1PathCubic>("QtQuick",1,0,"PathCubic");
149         qmlRegisterType<QDeclarative1PathLine>("QtQuick",1,0,"PathLine");
150         qmlRegisterType<QDeclarative1PathPercent>("QtQuick",1,0,"PathPercent");
151         qmlRegisterType<QDeclarative1PathQuad>("QtQuick",1,0,"PathQuad");
152         qmlRegisterType<QDeclarative1PathView>("QtQuick",1,0,"PathView");
153 #ifndef QT_NO_VALIDATOR
154         qmlRegisterType<QIntValidator>("QtQuick",1,0,"IntValidator");
155         qmlRegisterType<QDoubleValidator>("QtQuick",1,0,"DoubleValidator");
156         qmlRegisterType<QRegExpValidator>("QtQuick",1,0,"RegExpValidator");
157 #endif
158         qmlRegisterType<QDeclarative1Rectangle>("QtQuick",1,0,"Rectangle");
159         qmlRegisterType<QDeclarative1Repeater>("QtQuick",1,0,"Repeater");
160         qmlRegisterType<QGraphicsRotation>("QtQuick",1,0,"Rotation");
161         qmlRegisterType<QDeclarative1Row>("QtQuick",1,0,"Row");
162         qmlRegisterType<QDeclarative1Translate>("QtQuick",1,0,"Translate");
163         qmlRegisterType<QGraphicsScale>("QtQuick",1,0,"Scale");
164         qmlRegisterType<QDeclarative1Text>("QtQuick",1,0,"Text");
165         qmlRegisterType<QDeclarative1TextEdit>("QtQuick",1,0,"TextEdit");
166 #ifndef QT_NO_LINEEDIT
167         qmlRegisterType<QDeclarative1TextInput>("QtQuick",1,0,"TextInput");
168 #endif
169         qmlRegisterType<QDeclarative1ViewSection>("QtQuick",1,0,"ViewSection");
170         qmlRegisterType<QDeclarative1VisualDataModel>("QtQuick",1,0,"VisualDataModel");
171         qmlRegisterType<QDeclarative1VisualItemModel>("QtQuick",1,0,"VisualItemModel");
172
173         qmlRegisterType<QGraphicsWidget>("QtQuick",1,0,"QGraphicsWidget");
174         qmlRegisterExtendedType<QGraphicsWidget,QDeclarative1GraphicsWidget>("QtQuick",1,0,"QGraphicsWidget");
175
176         qmlRegisterUncreatableType<QDeclarative1KeyNavigationAttached>("QtQuick",1,0,"KeyNavigation",QDeclarative1KeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
177         qmlRegisterUncreatableType<QDeclarative1KeysAttached>("QtQuick",1,0,"Keys",QDeclarative1KeysAttached::tr("Keys is only available via attached properties"));
178
179         // QtQuick 1.1 items
180         qmlRegisterType<QDeclarative1PinchArea>("QtQuick",1,1,"PinchArea");
181         qmlRegisterType<QDeclarative1Pinch>("QtQuick",1,1,"Pinch");
182         qmlRegisterType<QDeclarative1PinchEvent>();
183         qmlRegisterType<QDeclarativeItem,1>("QtQuick",1,1,"Item");
184         qmlRegisterType<QDeclarative1MouseArea,1>("QtQuick",1,1,"MouseArea");
185         qmlRegisterType<QDeclarative1Flickable,1>("QtQuick",1,1,"Flickable");
186         qmlRegisterType<QDeclarative1ListView,1>("QtQuick",1,1,"ListView");
187         qmlRegisterType<QDeclarative1GridView,1>("QtQuick",1,1,"GridView");
188         qmlRegisterType<QDeclarative1Row,1>("QtQuick",1,1,"Row");
189         qmlRegisterType<QDeclarative1Grid,1>("QtQuick",1,1,"Grid");
190         qmlRegisterType<QDeclarative1Flow,1>("QtQuick",1,1,"Flow");
191         qmlRegisterType<QDeclarative1Repeater,1>("QtQuick",1,1,"Repeater");
192         qmlRegisterType<QDeclarative1Text,1>("QtQuick",1,1,"Text");
193         qmlRegisterType<QDeclarative1TextEdit,1>("QtQuick",1,1,"TextEdit");
194 #ifndef QT_NO_LINEEDIT
195         qmlRegisterType<QDeclarative1TextInput,1>("QtQuick",1,1,"TextInput");
196 #endif
197         qmlRegisterRevision<QDeclarative1ImageBase,1>("QtQuick",1,1);
198         qmlRegisterRevision<QDeclarative1ImplicitSizeItem,0>("QtQuick",1,0);
199         qmlRegisterRevision<QDeclarative1ImplicitSizeItem,1>("QtQuick",1,1);
200         qmlRegisterRevision<QDeclarative1ImplicitSizePaintedItem,0>("QtQuick",1,0);
201         qmlRegisterRevision<QDeclarative1ImplicitSizePaintedItem,1>("QtQuick",1,1);
202         qmlRegisterUncreatableType<QDeclarative1LayoutMirroringAttached>("QtQuick",1,1,"LayoutMirroring", QDeclarative1LayoutMirroringAttached::tr("LayoutMirroring is only available via attached properties"));
203 #ifndef QT_NO_ACCESSIBILITY
204         qmlRegisterUncreatableType<QDeclarativeAccessibleAttached>("QtQuick",1,0,"Accessible",QDeclarativeAccessibleAttached::tr("Accessible is only available via attached properties"));
205         qmlRegisterUncreatableType<QDeclarativeAccessibleAttached>("QtQuick",1,1,"Accessible",QDeclarativeAccessibleAttached::tr("Accessible is only available via attached properties"));
206 #endif
207
208     } else if (module == QDeclarativeQtQuick1Module::Qt47) {
209 #ifdef QT_NO_MOVIE
210         qmlRegisterTypeNotAvailable("Qt",4,7,"AnimatedImage",
211             qApp->translate("QDeclarative1AnimatedImage","Qt was built without support for QMovie"));
212 #else
213         qmlRegisterType<QDeclarative1AnimatedImage>("Qt",4,7,"AnimatedImage");
214 #endif
215         qmlRegisterType<QDeclarative1BorderImage>("Qt",4,7,"BorderImage");
216         qmlRegisterType<QDeclarative1Column>("Qt",4,7,"Column");
217         qmlRegisterType<QDeclarative1Drag>("Qt",4,7,"Drag");
218         qmlRegisterType<QDeclarative1Flickable>("Qt",4,7,"Flickable");
219         qmlRegisterType<QDeclarative1Flipable>("Qt",4,7,"Flipable");
220         qmlRegisterType<QDeclarative1Flow>("Qt",4,7,"Flow");
221         qmlRegisterType<QDeclarative1FocusPanel>("Qt",4,7,"FocusPanel");
222         qmlRegisterType<QDeclarative1FocusScope>("Qt",4,7,"FocusScope");
223         qmlRegisterType<QDeclarative1Gradient>("Qt",4,7,"Gradient");
224         qmlRegisterType<QDeclarative1GradientStop>("Qt",4,7,"GradientStop");
225         qmlRegisterType<QDeclarative1Grid>("Qt",4,7,"Grid");
226         qmlRegisterType<QDeclarative1GridView>("Qt",4,7,"GridView");
227         qmlRegisterType<QDeclarative1Image>("Qt",4,7,"Image");
228         qmlRegisterType<QDeclarativeItem>("Qt",4,7,"Item");
229         qmlRegisterType<QDeclarative1LayoutItem>("Qt",4,7,"LayoutItem");
230         qmlRegisterType<QDeclarative1ListView>("Qt",4,7,"ListView");
231         qmlRegisterType<QDeclarative1Loader>("Qt",4,7,"Loader");
232         qmlRegisterType<QDeclarative1MouseArea>("Qt",4,7,"MouseArea");
233         qmlRegisterType<QDeclarative1Path>("Qt",4,7,"Path");
234         qmlRegisterType<QDeclarative1PathAttribute>("Qt",4,7,"PathAttribute");
235         qmlRegisterType<QDeclarative1PathCubic>("Qt",4,7,"PathCubic");
236         qmlRegisterType<QDeclarative1PathLine>("Qt",4,7,"PathLine");
237         qmlRegisterType<QDeclarative1PathPercent>("Qt",4,7,"PathPercent");
238         qmlRegisterType<QDeclarative1PathQuad>("Qt",4,7,"PathQuad");
239         qmlRegisterType<QDeclarative1PathView>("Qt",4,7,"PathView");
240 #ifndef QT_NO_VALIDATOR
241         qmlRegisterType<QIntValidator>("Qt",4,7,"IntValidator");
242         qmlRegisterType<QDoubleValidator>("Qt",4,7,"DoubleValidator");
243         qmlRegisterType<QRegExpValidator>("Qt",4,7,"RegExpValidator");
244 #endif
245         qmlRegisterType<QDeclarative1Rectangle>("Qt",4,7,"Rectangle");
246         qmlRegisterType<QDeclarative1Repeater>("Qt",4,7,"Repeater");
247         qmlRegisterType<QGraphicsRotation>("Qt",4,7,"Rotation");
248         qmlRegisterType<QDeclarative1Row>("Qt",4,7,"Row");
249         qmlRegisterType<QDeclarative1Translate>("Qt",4,7,"Translate");
250         qmlRegisterType<QGraphicsScale>("Qt",4,7,"Scale");
251         qmlRegisterType<QDeclarative1Text>("Qt",4,7,"Text");
252         qmlRegisterType<QDeclarative1TextEdit>("Qt",4,7,"TextEdit");
253 #ifndef QT_NO_LINEEDIT
254         qmlRegisterType<QDeclarative1TextInput>("Qt",4,7,"TextInput");
255 #endif
256         qmlRegisterType<QDeclarative1ViewSection>("Qt",4,7,"ViewSection");
257         qmlRegisterType<QDeclarative1VisualDataModel>("Qt",4,7,"VisualDataModel");
258         qmlRegisterType<QDeclarative1VisualItemModel>("Qt",4,7,"VisualItemModel");
259
260         qmlRegisterType<QGraphicsWidget>("Qt",4,7,"QGraphicsWidget");
261         qmlRegisterExtendedType<QGraphicsWidget,QDeclarative1GraphicsWidget>("Qt",4,7,"QGraphicsWidget");
262
263         qmlRegisterUncreatableType<QDeclarative1KeyNavigationAttached>("Qt",4,7,"KeyNavigation",QDeclarative1KeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
264         qmlRegisterUncreatableType<QDeclarative1KeysAttached>("Qt",4,7,"Keys",QDeclarative1KeysAttached::tr("Keys is only available via attached properties"));
265     }
266 }
267
268
269