1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2015 The Qt Company Ltd. 4 ** Contact: http://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtDeclarative 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 The Qt Company. For licensing terms 14 ** and conditions see http://www.qt.io/terms-conditions. For further 15 ** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free 20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and 21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the 22 ** following information to ensure the GNU Lesser General Public License 23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and 24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 25 ** 26 ** As a special exception, The Qt Company gives you certain additional 27 ** rights. These rights are described in The Qt Company LGPL Exception 28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 29 ** 30 ** GNU General Public License Usage 31 ** Alternatively, this file may be used under the terms of the GNU 32 ** General Public License version 3.0 as published by the Free Software 33 ** Foundation and appearing in the file LICENSE.GPL included in the 34 ** packaging of this file. Please review the following information to 35 ** ensure the GNU General Public License version 3.0 requirements will be 36 ** met: http://www.gnu.org/copyleft/gpl.html. 37 ** 38 ** $QT_END_LICENSE$ 39 ** 40 ****************************************************************************/ 41 42 #ifndef QDECLARATIVEMETATYPE_P_H 43 #define QDECLARATIVEMETATYPE_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 "qdeclarative.h" 57 58 #include <QtCore/qglobal.h> 59 #include <QtCore/qvariant.h> 60 #include <QtCore/qbitarray.h> 61 #include <private/qdeclarativeglobal_p.h> 62 #include <private/qdeclarativedirparser_p.h> 63 64 QT_BEGIN_NAMESPACE 65 66 class QDeclarativeType; 67 class QDeclarativeCustomParser; 68 class QDeclarativeTypePrivate; 69 70 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeMetaType 71 { 72 public: 73 static bool canCopy(int type); 74 static bool copy(int type, void *data, const void *copy = 0); 75 76 static QList<QByteArray> qmlTypeNames(); 77 static QList<QDeclarativeType*> qmlTypes(); 78 79 static QDeclarativeType *qmlType(const QByteArray &, int, int); 80 static QDeclarativeType *qmlType(const QMetaObject *); 81 static QDeclarativeType *qmlType(const QMetaObject *metaObject, const QByteArray &module, int version_major, int version_minor); 82 static QDeclarativeType *qmlType(int); 83 84 static QDeclarativeDirComponents qmlComponents(const QByteArray& module, int version_major, int version_minor); 85 86 static QMetaProperty defaultProperty(const QMetaObject *); 87 static QMetaProperty defaultProperty(QObject *); 88 static QMetaMethod defaultMethod(const QMetaObject *); 89 static QMetaMethod defaultMethod(QObject *); 90 91 static bool isQObject(int); 92 static QObject *toQObject(const QVariant &, bool *ok = 0); 93 94 static int listType(int); 95 static int attachedPropertiesFuncId(const QMetaObject *); 96 static QDeclarativeAttachedPropertiesFunc attachedPropertiesFuncById(int); 97 98 enum TypeCategory { Unknown, Object, List }; 99 static TypeCategory typeCategory(int); 100 101 static bool isInterface(int); 102 static const char *interfaceIId(int); 103 static bool isList(int); 104 105 typedef QVariant (*StringConverter)(const QString &); 106 static void registerCustomStringConverter(int, StringConverter); 107 static StringConverter customStringConverter(int); 108 109 static bool isModule(const QByteArray &module, int versionMajor, int versionMinor); 110 111 static QList<QDeclarativePrivate::AutoParentFunction> parentFunctions(); 112 }; 113 114 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeType 115 { 116 public: 117 QByteArray typeName() const; 118 QByteArray qmlTypeName() const; 119 120 QByteArray module() const; 121 int majorVersion() const; 122 int minorVersion() const; 123 124 bool availableInVersion(int vmajor, int vminor) const; 125 bool availableInVersion(const QByteArray &module, int vmajor, int vminor) const; 126 127 QObject *create() const; 128 void create(QObject **, void **, size_t) const; 129 130 typedef void (*CreateFunc)(void *); 131 CreateFunc createFunction() const; 132 int createSize() const; 133 134 QDeclarativeCustomParser *customParser() const; 135 136 bool isCreatable() const; 137 bool isExtendedType() const; 138 QString noCreationReason() const; 139 140 bool isInterface() const; 141 int typeId() const; 142 int qListTypeId() const; 143 144 const QMetaObject *metaObject() const; 145 const QMetaObject *baseMetaObject() const; 146 int metaObjectRevision() const; 147 bool containsRevisionedAttributes() const; 148 149 QDeclarativeAttachedPropertiesFunc attachedPropertiesFunction() const; 150 const QMetaObject *attachedPropertiesType() const; 151 int attachedPropertiesId() const; 152 153 int parserStatusCast() const; 154 QVariant fromObject(QObject *) const; 155 const char *interfaceIId() const; 156 int propertyValueSourceCast() const; 157 int propertyValueInterceptorCast() const; 158 159 int index() const; 160 161 private: 162 QDeclarativeType *superType() const; 163 friend class QDeclarativeTypePrivate; 164 friend struct QDeclarativeMetaTypeData; 165 friend int registerType(const QDeclarativePrivate::RegisterType &); 166 friend int registerInterface(const QDeclarativePrivate::RegisterInterface &); 167 friend int registerComponent(const QDeclarativePrivate::RegisterComponent &); 168 QDeclarativeType(int, const QDeclarativePrivate::RegisterInterface &); 169 QDeclarativeType(int, const QDeclarativePrivate::RegisterType &); 170 ~QDeclarativeType(); 171 172 QDeclarativeTypePrivate *d; 173 }; 174 175 QT_END_NAMESPACE 176 177 #endif // QDECLARATIVEMETATYPE_P_H 178 179