aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/items/qsgitemsmodule.cpp
blob: a3752fcec83d2543bf3997dc62fae82510c91052 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qsgitemsmodule_p.h"

#include "qsgitem.h"
#include "qsgitem_p.h"
#include "qsgevents_p_p.h"
#include "qsgrectangle_p.h"
#include "qsgfocusscope_p.h"
#include "qsgtext_p.h"
#include "qsgtextinput_p.h"
#include "qsgtextedit_p.h"
#include "qsgimage_p.h"
#include "qsgborderimage_p.h"
#include "qsgscalegrid_p_p.h"
#include "qsgmousearea_p.h"
#include "qsgpincharea_p.h"
#include "qsgflickable_p.h"
#include "qsgflickable_p_p.h"
#include "qsglistview_p.h"
#include "qsgvisualitemmodel_p.h"
#include "qsggridview_p.h"
#include "qsgpathview_p.h"
#include <private/qdeclarativepath_p.h>
#include "qsgpositioners_p.h"
#include "qsgrepeater_p.h"
#include "qsgloader_p.h"
#include "qsganimatedimage_p.h"
#include "qsgflipable_p.h"
#include "qsgtranslate_p.h"
#include "qsgstateoperations_p.h"
#include "qsganimation_p.h"
#include <private/qsgshadereffectitem_p.h>
#include <private/qsgshadereffectsource_p.h>
//#include "private/qsgpincharea_p.h"
#include "qsgcanvasitem_p.h"
#include "qsgcontext2d_p.h"
#include "qsgsprite_p.h"
#include "qsgspriteimage_p.h"
#include "qsgdragtarget_p.h"

static QDeclarativePrivate::AutoParentResult qsgitem_autoParent(QObject *obj, QObject *parent)
{
    QSGItem *item = qobject_cast<QSGItem *>(obj);
    if (!item)
        return QDeclarativePrivate::IncompatibleObject;

    QSGItem *parentItem = qobject_cast<QSGItem *>(parent);
    if (!parentItem)
        return QDeclarativePrivate::IncompatibleParent;

    item->setParentItem(parentItem);
    return QDeclarativePrivate::Parented;
}

static void qt_sgitems_defineModule(const char *uri, int major, int minor)
{
    QDeclarativePrivate::RegisterAutoParent autoparent = { 0, &qsgitem_autoParent };
    QDeclarativePrivate::qmlregister(QDeclarativePrivate::AutoParentRegistration, &autoparent);

#ifdef QT_NO_MOVIE
    qmlRegisterTypeNotAvailable(uri,major,minor,"AnimatedImage", qApp->translate("QSGAnimatedImage","Qt was built without support for QMovie"));
#else
    qmlRegisterType<QSGAnimatedImage>(uri,major,minor,"AnimatedImage");
#endif
    qmlRegisterType<QSGBorderImage>(uri,major,minor,"BorderImage");
    qmlRegisterType<QSGColumn>(uri,major,minor,"Column");
    qmlRegisterType<QSGDrag>(uri,major,minor,"Drag");
    qmlRegisterType<QSGFlickable>(uri,major,minor,"Flickable");
    qmlRegisterType<QSGFlipable>(uri,major,minor,"Flipable");
    qmlRegisterType<QSGFlow>(uri,major,minor,"Flow");
//    qmlRegisterType<QDeclarativeFocusPanel>(uri,major,minor,"FocusPanel");
    qmlRegisterType<QSGFocusScope>(uri,major,minor,"FocusScope");
    qmlRegisterType<QSGGradient>(uri,major,minor,"Gradient");
    qmlRegisterType<QSGGradientStop>(uri,major,minor,"GradientStop");
    qmlRegisterType<QSGGrid>(uri,major,minor,"Grid");
    qmlRegisterType<QSGGridView>(uri,major,minor,"GridView");
    qmlRegisterType<QSGImage>(uri,major,minor,"Image");
    qmlRegisterType<QSGItem>(uri,major,minor,"Item");
    qmlRegisterType<QSGListView>(uri,major,minor,"ListView");
    qmlRegisterType<QSGLoader>(uri,major,minor,"Loader");
    qmlRegisterType<QSGMouseArea>(uri,major,minor,"MouseArea");
    qmlRegisterType<QDeclarativePath>(uri,major,minor,"Path");
    qmlRegisterType<QDeclarativePathAttribute>(uri,major,minor,"PathAttribute");
    qmlRegisterType<QDeclarativePathCubic>(uri,major,minor,"PathCubic");
    qmlRegisterType<QDeclarativePathLine>(uri,major,minor,"PathLine");
    qmlRegisterType<QDeclarativePathPercent>(uri,major,minor,"PathPercent");
    qmlRegisterType<QDeclarativePathQuad>(uri,major,minor,"PathQuad");
    qmlRegisterType<QSGPathView>(uri,major,minor,"PathView");
#ifndef QT_NO_VALIDATOR
    qmlRegisterType<QIntValidator>(uri,major,minor,"IntValidator");
    qmlRegisterType<QDoubleValidator>(uri,major,minor,"DoubleValidator");
    qmlRegisterType<QRegExpValidator>(uri,major,minor,"RegExpValidator");
#endif
    qmlRegisterType<QSGRectangle>(uri,major,minor,"Rectangle");
    qmlRegisterType<QSGRepeater>(uri,major,minor,"Repeater");
    qmlRegisterType<QSGRow>(uri,major,minor,"Row");
    qmlRegisterType<QSGTranslate>(uri,major,minor,"Translate");
    qmlRegisterType<QSGRotation>(uri,major,minor,"Rotation");
    qmlRegisterType<QSGScale>(uri,major,minor,"Scale");
    qmlRegisterType<QSGText>(uri,major,minor,"Text");
    qmlRegisterType<QSGTextEdit>(uri,major,minor,"TextEdit");
    qmlRegisterType<QSGTextInput>(uri,major,minor,"TextInput");
    qmlRegisterType<QSGViewSection>(uri,major,minor,"ViewSection");
    qmlRegisterType<QSGVisualDataModel>(uri,major,minor,"VisualDataModel");
    qmlRegisterType<QSGVisualItemModel>(uri,major,minor,"VisualItemModel");

    qmlRegisterType<QSGAnchors>();
    qmlRegisterType<QSGKeyEvent>();
    qmlRegisterType<QSGMouseEvent>();
    qmlRegisterType<QSGTransform>();
    qmlRegisterType<QDeclarativePathElement>();
    qmlRegisterType<QDeclarativeCurve>();
    qmlRegisterType<QSGScaleGrid>();
#ifndef QT_NO_VALIDATOR
    qmlRegisterType<QValidator>();
#endif
    qmlRegisterType<QSGVisualModel>();
#ifndef QT_NO_ACTION
    qmlRegisterType<QAction>();
#endif
    qmlRegisterType<QSGPen>();
    qmlRegisterType<QSGFlickableVisibleArea>();
    qRegisterMetaType<QSGAnchorLine>("QSGAnchorLine");

    qmlRegisterUncreatableType<QSGKeyNavigationAttached>(uri,major,minor,"KeyNavigation",QSGKeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
    qmlRegisterUncreatableType<QSGKeysAttached>(uri,major,minor,"Keys",QSGKeysAttached::tr("Keys is only available via attached properties"));
    qmlRegisterUncreatableType<QSGLayoutMirroringAttached>(uri,major,minor,"LayoutMirroring", QSGLayoutMirroringAttached::tr("LayoutMirroring is only available via attached properties"));

    qmlRegisterType<QSGPinchArea>(uri,major,minor,"PinchArea");
    qmlRegisterType<QSGPinch>(uri,major,minor,"Pinch");
    qmlRegisterType<QSGPinchEvent>();

    qmlRegisterType<QSGShaderEffectItem>("QtQuick", 2, 0, "ShaderEffectItem");
    qmlRegisterType<QSGShaderEffectSource>("QtQuick", 2, 0, "ShaderEffectSource");
    qmlRegisterUncreatableType<QSGShaderEffectMesh>("QtQuick", 2, 0, "ShaderEffectMesh", QSGShaderEffectMesh::tr("Cannot create instance of abstract class ShaderEffectMesh."));
    qmlRegisterType<QSGGridMesh>("QtQuick", 2, 0, "GridMesh");

    qmlRegisterUncreatableType<QSGPaintedItem>("QtQuick", 2, 0, "PaintedItem", QSGPaintedItem::tr("Cannot create instance of abstract class PaintedItem"));

    qmlRegisterType<QSGCanvasItem>("QtQuick", 2, 0, "Canvas");
    qmlRegisterType<QSGContext2D>();
    qmlRegisterType<QSGCanvasGradient>();

    qmlRegisterType<QSGSprite>("QtQuick", 2, 0, "Sprite");
    qmlRegisterType<QSGSpriteImage>("QtQuick", 2, 0, "SpriteImage");

    qmlRegisterType<QSGParentChange>(uri, major, minor,"ParentChange");
    qmlRegisterType<QSGAnchorChanges>(uri, major, minor,"AnchorChanges");
    qmlRegisterType<QSGAnchorSet>();
    qmlRegisterType<QSGAnchorAnimation>(uri, major, minor,"AnchorAnimation");
    qmlRegisterType<QSGParentAnimation>(uri, major, minor,"ParentAnimation");

    qmlRegisterType<QSGDragTarget>("QtQuick", 2, 0, "DragTarget");
    qmlRegisterType<QSGDragTargetEvent>();
}

void QSGItemsModule::defineModule()
{
    static bool initialized = false;
    if (initialized)
        return;
    initialized = true;

    // XXX todo -  Remove before final integration...
    QByteArray mode = qgetenv("QMLSCENE_IMPORT_NAME");
    QByteArray name = "QtQuick";
    int majorVersion = 2;
    int minorVersion = 0;
    if (mode == "quick1") {
        majorVersion = 1;
    } else if (mode == "qt") {
        name = "Qt";
        majorVersion = 4;
        minorVersion = 7;
    }

    qt_sgitems_defineModule(name, majorVersion, minorVersion);
}