~saviq/ubuntu/saucy/qtdeclarative-opensource-src/add-qtquick-delegate-range

« back to all changes in this revision

Viewing changes to src/qml/qml/qqmlmetatype_p.h

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 14:17:19 UTC
  • Revision ID: package-import@ubuntu.com-20130205141719-qqeyml8wslpyez52
Tags: upstream-5.0.1
ImportĀ upstreamĀ versionĀ 5.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/legal
 
5
**
 
6
** This file is part of the QtQml 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
#ifndef QQMLMETATYPE_P_H
 
43
#define QQMLMETATYPE_P_H
 
44
 
 
45
//
 
46
//  W A R N I N G
 
47
//  -------------
 
48
//
 
49
// This file is not part of the Qt API.  It exists purely as an
 
50
// implementation detail.  This header file may change from version to
 
51
// version without notice, or even be removed.
 
52
//
 
53
// We mean it.
 
54
//
 
55
 
 
56
#include "qqml.h"
 
57
#include <private/qtqmlglobal_p.h>
 
58
 
 
59
#include <QtCore/qglobal.h>
 
60
#include <QtCore/qvariant.h>
 
61
#include <QtCore/qbitarray.h>
 
62
#include <QtQml/qjsvalue.h>
 
63
 
 
64
QT_BEGIN_NAMESPACE
 
65
 
 
66
class QQmlType;
 
67
class QQmlEngine;
 
68
class QQmlCustomParser;
 
69
class QQmlTypePrivate;
 
70
class QQmlTypeModule;
 
71
class QHashedString;
 
72
class QHashedStringRef;
 
73
class QReadWriteLock;
 
74
 
 
75
class Q_QML_PRIVATE_EXPORT QQmlMetaType
 
76
{
 
77
public:
 
78
    static QList<QString> qmlTypeNames();
 
79
    static QList<QQmlType*> qmlTypes();
 
80
    static QList<QQmlType*> qmlSingletonTypes();
 
81
 
 
82
    static QQmlType *qmlType(const QString &qualifiedName, int, int);
 
83
    static QQmlType *qmlType(const QHashedStringRef &name, const QHashedStringRef &module, int, int);
 
84
    static QQmlType *qmlType(const QMetaObject *);
 
85
    static QQmlType *qmlType(const QMetaObject *metaObject, const QHashedStringRef &module, int version_major, int version_minor);
 
86
    static QQmlType *qmlType(int);
 
87
 
 
88
    static QMetaProperty defaultProperty(const QMetaObject *);
 
89
    static QMetaProperty defaultProperty(QObject *);
 
90
    static QMetaMethod defaultMethod(const QMetaObject *);
 
91
    static QMetaMethod defaultMethod(QObject *);
 
92
 
 
93
    static bool isQObject(int);
 
94
    static QObject *toQObject(const QVariant &, bool *ok = 0);
 
95
 
 
96
    static int listType(int);
 
97
    static int attachedPropertiesFuncId(const QMetaObject *);
 
98
    static QQmlAttachedPropertiesFunc attachedPropertiesFuncById(int);
 
99
 
 
100
    enum TypeCategory { Unknown, Object, List };
 
101
    static TypeCategory typeCategory(int);
 
102
        
 
103
    static bool isInterface(int);
 
104
    static const char *interfaceIId(int);
 
105
    static bool isList(int);
 
106
 
 
107
    typedef QVariant (*StringConverter)(const QString &);
 
108
    static void registerCustomStringConverter(int, StringConverter);
 
109
    static StringConverter customStringConverter(int);
 
110
 
 
111
    static bool isAnyModule(const QString &uri);
 
112
    static bool isModule(const QString &module, int versionMajor, int versionMinor);
 
113
    static QQmlTypeModule *typeModule(const QString &uri, int majorVersion);
 
114
 
 
115
    static QList<QQmlPrivate::AutoParentFunction> parentFunctions();
 
116
 
 
117
    static int QQuickAnchorLineMetaTypeId();
 
118
    typedef bool (*CompareFunction)(const void *, const void *);
 
119
    static void setQQuickAnchorLineCompareFunction(CompareFunction);
 
120
    static bool QQuickAnchorLineCompare(const void *p1, const void *p2);
 
121
 
 
122
    static bool namespaceContainsRegistrations(const QString &);
 
123
 
 
124
    static void protectNamespace(const QString &);
 
125
 
 
126
    static void setTypeRegistrationNamespace(const QString &);
 
127
    static QStringList typeRegistrationFailures();
 
128
 
 
129
    static QReadWriteLock *typeRegistrationLock();
 
130
 
 
131
private:
 
132
    static CompareFunction anchorLineCompareFunction;
 
133
};
 
134
 
 
135
struct QQmlMetaTypeData;
 
136
class QHashedCStringRef;
 
137
class QHashedV8String;
 
138
class Q_QML_PRIVATE_EXPORT QQmlType
 
139
{
 
140
public:
 
141
    QByteArray typeName() const;
 
142
    const QString &qmlTypeName() const;
 
143
    const QString &elementName() const;
 
144
 
 
145
    const QHashedString &module() const;
 
146
    int majorVersion() const;
 
147
    int minorVersion() const;
 
148
 
 
149
    bool availableInVersion(int vmajor, int vminor) const;
 
150
    bool availableInVersion(const QHashedStringRef &module, int vmajor, int vminor) const;
 
151
 
 
152
    QObject *create() const;
 
153
    void create(QObject **, void **, size_t) const;
 
154
 
 
155
    typedef void (*CreateFunc)(void *);
 
156
    CreateFunc createFunction() const;
 
157
    int createSize() const;
 
158
 
 
159
    QQmlCustomParser *customParser() const;
 
160
 
 
161
    bool isCreatable() const;
 
162
    bool isExtendedType() const;
 
163
    QString noCreationReason() const;
 
164
 
 
165
    bool isSingleton() const;
 
166
    bool isInterface() const;
 
167
    int typeId() const;
 
168
    int qListTypeId() const;
 
169
 
 
170
    const QMetaObject *metaObject() const;
 
171
    const QMetaObject *baseMetaObject() const;
 
172
    int metaObjectRevision() const;
 
173
    bool containsRevisionedAttributes() const;
 
174
 
 
175
    QQmlAttachedPropertiesFunc attachedPropertiesFunction() const;
 
176
    const QMetaObject *attachedPropertiesType() const;
 
177
    int attachedPropertiesId() const;
 
178
 
 
179
    int parserStatusCast() const;
 
180
    const char *interfaceIId() const;
 
181
    int propertyValueSourceCast() const;
 
182
    int propertyValueInterceptorCast() const;
 
183
 
 
184
    int index() const;
 
185
 
 
186
    class Q_QML_PRIVATE_EXPORT SingletonInstanceInfo
 
187
    {
 
188
    public:
 
189
        SingletonInstanceInfo()
 
190
            : scriptCallback(0), qobjectCallback(0), instanceMetaObject(0) {}
 
191
 
 
192
        QJSValue (*scriptCallback)(QQmlEngine *, QJSEngine *);
 
193
        QObject *(*qobjectCallback)(QQmlEngine *, QJSEngine *);
 
194
        const QMetaObject *instanceMetaObject;
 
195
        QString typeName;
 
196
 
 
197
        void setQObjectApi(QQmlEngine *, QObject *);
 
198
        QObject *qobjectApi(QQmlEngine *) const;
 
199
        void setScriptApi(QQmlEngine *, QJSValue);
 
200
        QJSValue scriptApi(QQmlEngine *) const;
 
201
 
 
202
        void init(QQmlEngine *);
 
203
        void destroy(QQmlEngine *);
 
204
 
 
205
        QHash<QQmlEngine *, QJSValue> scriptApis;
 
206
        QHash<QQmlEngine *, QObject *> qobjectApis;
 
207
    };
 
208
    SingletonInstanceInfo *singletonInstanceInfo() const;
 
209
 
 
210
    int enumValue(const QHashedStringRef &, bool *ok) const;
 
211
    int enumValue(const QHashedCStringRef &, bool *ok) const;
 
212
    int enumValue(const QHashedV8String &, bool *ok) const;
 
213
private:
 
214
    QQmlType *superType() const;
 
215
    friend class QQmlTypePrivate;
 
216
    friend struct QQmlMetaTypeData;
 
217
 
 
218
    enum RegistrationType {
 
219
        CppType = 0,
 
220
        SingletonType = 1
 
221
        // In the future, we should register all types via QQmlType, including Composite types.
 
222
    };
 
223
    friend QString registrationTypeString(RegistrationType);
 
224
    friend bool checkRegistration(RegistrationType, QQmlMetaTypeData *, const char *, const QString &);
 
225
    friend int registerType(const QQmlPrivate::RegisterType &);
 
226
    friend int registerSingletonType(const QQmlPrivate::RegisterSingletonType &);
 
227
    friend int registerInterface(const QQmlPrivate::RegisterInterface &);
 
228
    QQmlType(int, const QQmlPrivate::RegisterInterface &);
 
229
    QQmlType(int, const QString &, const QQmlPrivate::RegisterSingletonType &);
 
230
    QQmlType(int, const QString &, const QQmlPrivate::RegisterType &);
 
231
    ~QQmlType();
 
232
 
 
233
    QQmlTypePrivate *d;
 
234
};
 
235
 
 
236
class QQmlTypeModulePrivate;
 
237
class QQmlTypeModule
 
238
{
 
239
public:
 
240
    QString module() const;
 
241
    int majorVersion() const;
 
242
 
 
243
    int minimumMinorVersion() const;
 
244
    int maximumMinorVersion() const;
 
245
 
 
246
    QQmlType *type(const QHashedStringRef &, int);
 
247
    QQmlType *type(const QHashedV8String &, int);
 
248
 
 
249
    QList<QQmlType*> singletonTypes(int) const;
 
250
 
 
251
private:
 
252
    friend int registerType(const QQmlPrivate::RegisterType &);
 
253
    friend int registerSingletonType(const QQmlPrivate::RegisterSingletonType &);
 
254
    friend struct QQmlMetaTypeData;
 
255
 
 
256
    QQmlTypeModule();
 
257
    ~QQmlTypeModule();
 
258
    QQmlTypeModulePrivate *d;
 
259
};
 
260
 
 
261
class QQmlTypeModuleVersion 
 
262
{
 
263
public:
 
264
    QQmlTypeModuleVersion();
 
265
    QQmlTypeModuleVersion(QQmlTypeModule *, int);
 
266
    QQmlTypeModuleVersion(const QQmlTypeModuleVersion &);
 
267
    QQmlTypeModuleVersion &operator=(const QQmlTypeModuleVersion &);
 
268
 
 
269
    QQmlTypeModule *module() const;
 
270
    int minorVersion() const;
 
271
 
 
272
    QQmlType *type(const QHashedStringRef &) const;
 
273
    QQmlType *type(const QHashedV8String &) const;
 
274
 
 
275
private:
 
276
    QQmlTypeModule *m_module;
 
277
    int m_minor;
 
278
};
 
279
 
 
280
QT_END_NAMESPACE
 
281
 
 
282
#endif // QQMLMETATYPE_P_H
 
283