summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarative.h222
-rw-r--r--src/declarative/qml/qdeclarativebinding_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal.cpp2
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp2
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp36
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp6
-rw-r--r--src/declarative/qml/qdeclarativeguard_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeinfo.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeintegercache.cpp2
-rw-r--r--src/declarative/qml/qdeclarativelist.h6
-rw-r--r--src/declarative/qml/qdeclarativemetaproperty.cpp269
-rw-r--r--src/declarative/qml/qdeclarativemetaproperty.h12
-rw-r--r--src/declarative/qml/qdeclarativemetaproperty_p.h37
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp129
-rw-r--r--src/declarative/qml/qdeclarativemetatype.h281
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h149
-rw-r--r--src/declarative/qml/qdeclarativeparser_p.h6
-rw-r--r--src/declarative/qml/qdeclarativeprivate.cpp48
-rw-r--r--src/declarative/qml/qdeclarativeprivate.h67
-rw-r--r--src/declarative/qml/qdeclarativepropertycache_p.h2
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp2
-rw-r--r--src/declarative/qml/qml.pri3
24 files changed, 635 insertions, 653 deletions
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
index ee5a27a..77b7484 100644
--- a/src/declarative/qml/qdeclarative.h
+++ b/src/declarative/qml/qdeclarative.h
@@ -39,18 +39,16 @@
**
****************************************************************************/
-#ifndef QML_H
-#define QML_H
+#ifndef QDECLARATIVE_H
+#define QDECLARATIVE_H
-#include "qdeclarativemetatype.h"
-#include "qdeclarativemetaproperty.h"
+#include "qdeclarativeprivate.h"
#include "qdeclarativeparserstatus.h"
#include "qdeclarativepropertyvaluesource.h"
+#include "qdeclarativepropertyvalueinterceptor.h"
#include "qdeclarativelist.h"
#include <QtCore/qbytearray.h>
-#include <QtCore/qstringlist.h>
-#include <QtCore/qurl.h>
#include <QtCore/qmetaobject.h>
QT_BEGIN_HEADER
@@ -88,17 +86,206 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+template<typename T>
+int qmlRegisterType()
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ 0,
+
+ 0, 0, 0, 0, &T::staticMetaObject,
+
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
+template<typename T>
+int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ QDeclarativePrivate::create<T>,
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
+template<typename T, typename E>
+int qmlRegisterExtendedType()
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ 0,
+
+ 0, 0, 0, 0, &T::staticMetaObject,
+
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ QDeclarativePrivate::createParent<E>, &E::staticMetaObject,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
+template<typename T, typename E>
+int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
+ const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativeAttachedPropertiesFunc attached = QDeclarativePrivate::attachedPropertiesFunc<E>();
+ const QMetaObject * attachedMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject<E>();
+ if (!attached) {
+ attached = QDeclarativePrivate::attachedPropertiesFunc<T>();
+ attachedMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject<T>();
+ }
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ QDeclarativePrivate::create<T>,
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ attached,
+ attachedMetaObject,
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ QDeclarativePrivate::createParent<E>, &E::staticMetaObject,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
+template<typename T>
+int qmlRegisterInterface(const char *typeName)
+{
+ QByteArray name(typeName);
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterInterface interface = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+
+ qobject_interface_iid<T *>()
+ };
+
+ return QDeclarativePrivate::registerType(interface);
+}
+
+template<typename T>
+int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
+ const char *qmlName, const char *typeName, QDeclarativeCustomParser *parser)
+{
+ QByteArray name(typeName);
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ QDeclarativePrivate::create<T>,
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ parser
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
#define QML_REGISTER_INTERFACE(INTERFACE) \
qmlRegisterInterface<INTERFACE>(#INTERFACE)
-#define QML_REGISTER_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, EXTENSION) \
- qmlRegisterExtendedType<TYPE,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE)
+#define QML_REGISTER_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, CLASS, EXTENSION) \
+ qmlRegisterExtendedType<CLASS,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN, #NAME)
-#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,TYPE,CLASS) \
- qmlRegisterType<CLASS>(#URI, VMAJ, VMIN, #TYPE, #CLASS)
+#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,NAME,CLASS) \
+ qmlRegisterType<CLASS>(#URI, VMAJ, VMIN, #NAME)
#define QML_REGISTER_NOCREATE_TYPE(CLASS) \
- qmlRegisterType<CLASS>(#CLASS)
+ qmlRegisterType<CLASS>()
class QDeclarativeContext;
class QDeclarativeEngine;
@@ -106,20 +293,13 @@ Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *);
Q_DECLARATIVE_EXPORT QDeclarativeContext *qmlContext(const QObject *);
Q_DECLARATIVE_EXPORT QDeclarativeEngine *qmlEngine(const QObject *);
Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true);
+Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObject(int *, const QObject *, const QMetaObject *, bool create);
template<typename T>
QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true)
{
- // ### is this threadsafe?
static int idx = -1;
-
- if (idx == -1)
- idx = QDeclarativeMetaType::attachedPropertiesFuncId(&T::staticMetaObject);
-
- if (idx == -1 || !obj)
- return 0;
-
- return qmlAttachedPropertiesObjectById(idx, obj, create);
+ return qmlAttachedPropertiesObject(&idx, obj, &T::staticMetaObject, create);
}
QT_END_NAMESPACE
@@ -129,4 +309,4 @@ Q_DECLARE_METATYPE(QVariant)
QT_END_HEADER
-#endif // QML_H
+#endif // QDECLARATIVE_H
diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h
index 432bf22..7c79b8c 100644
--- a/src/declarative/qml/qdeclarativebinding_p.h
+++ b/src/declarative/qml/qdeclarativebinding_p.h
@@ -56,6 +56,7 @@
#include "qdeclarative.h"
#include "qdeclarativepropertyvaluesource.h"
#include "qdeclarativeexpression.h"
+#include "qdeclarativemetaproperty.h"
#include <QtCore/QObject>
#include <QtCore/QMetaProperty>
diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp
index c47df32..ce396fd 100644
--- a/src/declarative/qml/qdeclarativeboundsignal.cpp
+++ b/src/declarative/qml/qdeclarativeboundsignal.cpp
@@ -45,7 +45,7 @@
#include "qdeclarativeengine_p.h"
#include "qdeclarativeexpression_p.h"
#include "qdeclarativecontext_p.h"
-#include "qdeclarativemetatype.h"
+#include "qdeclarativemetatype_p.h"
#include "qdeclarative.h"
#include "qdeclarativecontext.h"
#include "qdeclarativeglobal_p.h"
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 0e54d45..d9a0c74 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -51,7 +51,7 @@
#include "qdeclarativeengine_p.h"
#include "qdeclarativeengine.h"
#include "qdeclarativecontext.h"
-#include "qdeclarativemetatype.h"
+#include "qdeclarativemetatype_p.h"
#include "qdeclarativecustomparser_p_p.h"
#include "qdeclarativecontext_p.h"
#include "qdeclarativecomponent_p.h"
diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h
index cef1f3c..99587a8 100644
--- a/src/declarative/qml/qdeclarativecustomparser_p.h
+++ b/src/declarative/qml/qdeclarativecustomparser_p.h
@@ -53,7 +53,7 @@
// We mean it.
//
-#include "qdeclarativemetatype.h"
+#include "qdeclarativemetatype_p.h"
#include "qdeclarativeerror.h"
#include "qdeclarativeparser_p.h"
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 4575536..4435a5b 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -68,6 +68,7 @@
#include "qdeclarativedirparser_p.h"
#include "qdeclarativeextensioninterface.h"
#include "qdeclarativelist_p.h"
+#include "qdeclarativetypenamecache_p.h"
#include <qfxperf_p_p.h>
@@ -169,7 +170,6 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
QDeclarativeEnginePrivate::defineModule();
}
globalClass = new QDeclarativeGlobalScriptClass(&scriptEngine);
- fileImportPath.append(QLibraryInfo::location(QLibraryInfo::DataPath)+QDir::separator()+QLatin1String("qml"));
// env import paths
QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
@@ -721,6 +721,18 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre
return rv;
}
+QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object,
+ const QMetaObject *attachedMetaObject, bool create)
+{
+ if (*idCache == -1)
+ *idCache = QDeclarativeMetaType::attachedPropertiesFuncId(attachedMetaObject);
+
+ if (*idCache == -1 || !object)
+ return 0;
+
+ return qmlAttachedPropertiesObjectById(*idCache, object, create);
+}
+
void QDeclarativeDeclarativeData::destroyed(QObject *object)
{
if (deferredComponent)
@@ -1371,6 +1383,9 @@ public:
paths += QFileInfo(base.toLocalFile()).path();
paths += importPath;
paths += QDeclarativeEnginePrivate::get(engine)->environmentImportPath;
+ QString builtinPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
+ if (!builtinPath.isEmpty())
+ paths += builtinPath;
foreach (const QString &p, paths) {
dir = p+QLatin1Char('/')+url;
@@ -1491,9 +1506,6 @@ QDeclarativeEnginePrivate::Imports::~Imports()
delete d;
}
-#include "qdeclarativemetatype.h"
-#include "qdeclarativetypenamecache_p.h"
-
static QDeclarativeTypeNameCache *cacheForNamespace(QDeclarativeEngine *engine, const QDeclarativeEnginePrivate::ImportedNamespace &set, QDeclarativeTypeNameCache *cache)
{
if (!cache)
@@ -1582,14 +1594,17 @@ QUrl QDeclarativeEnginePrivate::Imports::baseUrl() const
Adds \a path as a directory where installed QML components are
defined in a URL-based directory structure.
- For example, if you add \c /opt/MyApp/lib/qml and then load QML
+ For example, if you add \c /opt/MyApp/lib/imports and then load QML
that imports \c com.mycompany.Feature, then QDeclarativeEngine will look
- in \c /opt/MyApp/lib/qml/com/mycompany/Feature/ for the components
- provided by that module (and in the case of versioned imports,
- for the \c qmldir file definiting the type version mapping.
+ in \c /opt/MyApp/lib/imports/com/mycompany/Feature/ for the components
+ provided by that module. A \c qmldir file is required for definiting the
+ type version mapping and possibly declarative extensions plugins.
+
+ The engine searches in the base directory of the qml file, then
+ the paths added via addImportPath(), then the paths specified in the
+ \c QML_IMPORT_PATH environment variable, then the builtin \c ImportsPath from
+ QLibraryInfo.
- By default, only the "qml" subdirectory of QLibraryInfo::location(QLibraryInfo::DataPath)
- is included on the import path.
*/
void QDeclarativeEngine::addImportPath(const QString& path)
{
@@ -1655,6 +1670,7 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString
const QStringList &suffixes,
const QString &prefix)
{
+ qWarning() << baseName;
foreach (const QString &suffix, suffixes) {
QString pluginFileName = prefix;
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index 7c9d833..c4a40c5 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -67,6 +67,7 @@
#include "qdeclarativeobjectscriptclass_p.h"
#include "qdeclarativecontextscriptclass_p.h"
#include "qdeclarativevaluetypescriptclass_p.h"
+#include "qdeclarativemetatype_p.h"
#include <QtScript/QScriptClass>
#include <QtScript/QScriptValue>
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index e4579a6..2ae0b54 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -43,8 +43,9 @@
#include "qdeclarativeboundsignal_p.h"
#include "qdeclarativeengine.h"
-#include "qdeclarativemetatype.h"
+#include "qdeclarativemetatype_p.h"
#include "qdeclarativemetaproperty.h"
+#include "qdeclarativemetaproperty_p.h"
#include "qdeclarativebinding_p.h"
#include "qdeclarativecontext_p.h"
#include "qdeclarativewatcher_p.h"
@@ -108,7 +109,8 @@ QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx)
rv.valueTypeName = QString::fromUtf8(prop.typeName());
rv.name = QString::fromUtf8(prop.name());
rv.hasNotifySignal = prop.hasNotifySignal();
- QDeclarativeAbstractBinding *binding = QDeclarativeMetaProperty(obj, rv.name).binding();
+ QDeclarativeAbstractBinding *binding =
+ QDeclarativeMetaPropertyPrivate::binding(QDeclarativeMetaProperty(obj, rv.name));
if (binding)
rv.binding = binding->expression();
diff --git a/src/declarative/qml/qdeclarativeguard_p.h b/src/declarative/qml/qdeclarativeguard_p.h
index 9d82d01..0861e9a 100644
--- a/src/declarative/qml/qdeclarativeguard_p.h
+++ b/src/declarative/qml/qdeclarativeguard_p.h
@@ -54,6 +54,7 @@
//
#include <QtCore/qglobal.h>
+#include <QtCore/qvariant.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeinfo.cpp b/src/declarative/qml/qdeclarativeinfo.cpp
index 41d09c4..7dc61fd 100644
--- a/src/declarative/qml/qdeclarativeinfo.cpp
+++ b/src/declarative/qml/qdeclarativeinfo.cpp
@@ -43,7 +43,7 @@
#include "qdeclarativedeclarativedata_p.h"
#include "qdeclarativecontext.h"
-#include "qdeclarativemetatype.h"
+#include "qdeclarativemetatype_p.h"
#include <QCoreApplication>
diff --git a/src/declarative/qml/qdeclarativeintegercache.cpp b/src/declarative/qml/qdeclarativeintegercache.cpp
index 7fa4b0c..8fa210f 100644
--- a/src/declarative/qml/qdeclarativeintegercache.cpp
+++ b/src/declarative/qml/qdeclarativeintegercache.cpp
@@ -42,7 +42,7 @@
#include "qdeclarativeintegercache_p.h"
#include "qdeclarativeengine_p.h"
-#include "qdeclarativemetatype.h"
+#include "qdeclarativemetatype_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h
index fb877b4..8d59384 100644
--- a/src/declarative/qml/qdeclarativelist.h
+++ b/src/declarative/qml/qdeclarativelist.h
@@ -42,7 +42,9 @@
#ifndef QDECLARATIVELIST_H
#define QDECLARATIVELIST_H
-#include "qdeclarativeprivate.h"
+#include <QtCore/qglobal.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qvariant.h>
QT_BEGIN_HEADER
@@ -50,6 +52,8 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+class QObject;
+class QMetaObject;
template<typename T>
struct QDeclarativeListProperty {
typedef void (*AppendFunction)(QDeclarativeListProperty<T> *, T*);
diff --git a/src/declarative/qml/qdeclarativemetaproperty.cpp b/src/declarative/qml/qdeclarativemetaproperty.cpp
index 253174d..8fc3b56 100644
--- a/src/declarative/qml/qdeclarativemetaproperty.cpp
+++ b/src/declarative/qml/qdeclarativemetaproperty.cpp
@@ -147,50 +147,111 @@ QDeclarativeMetaProperty::QDeclarativeMetaProperty(QObject *obj, const QString &
if (!isValid()) { d->object = 0; d->context = 0; }
}
+Q_GLOBAL_STATIC(QDeclarativeValueTypeFactory, qmlValueTypes);
+
void QDeclarativeMetaPropertyPrivate::initProperty(QObject *obj, const QString &name)
{
- QDeclarativeEnginePrivate *enginePrivate = 0;
- if (context && context->engine())
- enginePrivate = QDeclarativeEnginePrivate::get(context->engine());
+ if (!obj) return;
- object = obj;
+ QDeclarativeEngine *engine = context?context->engine():0;
+ QDeclarativeTypeNameCache *typeNameCache = context?QDeclarativeContextPrivate::get(context)->imports:0;
- if (name.isEmpty() || !obj)
- return;
+ QStringList path = name.split(QLatin1Char('.'));
+ if (path.isEmpty()) return;
+
+ QObject *currentObject = obj;
+
+ // Everything up to the last property must be an "object type" property
+ for (int ii = 0; ii < path.count() - 1; ++ii) {
+ const QString &pathName = path.at(ii);
+
+ if (QDeclarativeTypeNameCache::Data *data = typeNameCache?typeNameCache->data(pathName):0) {
+ if (data->type) {
+ QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
+ if (!func) return; // Not an attachable type
+
+ currentObject = qmlAttachedPropertiesObjectById(data->type->index(), currentObject);
+ if (!currentObject) return; // Something is broken with the attachable type
+ } else {
+ Q_ASSERT(data->typeNamespace);
+ if ((ii + 1) == path.count()) return; // No type following the namespace
+
+ ++ii; data = data->typeNamespace->data(path.at(ii));
+ if (!data || !data->type) return; // Invalid type in namespace
+
+ QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
+ if (!func) return; // Not an attachable type
+
+ currentObject = qmlAttachedPropertiesObjectById(data->type->index(), currentObject);
+ if (!currentObject) return; // Something is broken with the attachable type
+ }
+ } else {
+
+ QDeclarativePropertyCache::Data local;
+ QDeclarativePropertyCache::Data *property =
+ QDeclarativePropertyCache::property(engine, obj, pathName, local);
+
+ if (!property) return; // Not a property
+ if (property->flags & QDeclarativePropertyCache::Data::IsFunction)
+ return; // Not an object property
+
+ if (ii == (path.count() - 2) && property->propType < (int)QVariant::UserType) {
+ // We're now at a value type property. We can use a global valuetypes array as we
+ // never actually use the objects, just look up their properties.
+ QObject *typeObject = qmlValueTypes()->valueTypes[property->propType];
+ if (!typeObject) return; // Not a value type
+
+ int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData());
+ if (idx == -1) return; // Value type property does not exist
+
+ QMetaProperty vtProp = typeObject->metaObject()->property(idx);
+
+ object = currentObject;
+ core = *property;
+ valueType.flags = QDeclarativePropertyCache::Data::flagsForProperty(vtProp);
+ valueType.valueTypeCoreIdx = idx;
+ valueType.valueTypePropType = vtProp.userType();
+
+ return;
+ } else {
+ if (!(property->flags & QDeclarativePropertyCache::Data::IsQObjectDerived))
+ return; // Not an object property
+
+ void *args[] = { &currentObject, 0 };
+ QMetaObject::metacall(currentObject, QMetaObject::ReadProperty, property->coreIndex, args);
+ if (!currentObject) return; // No value
- if (enginePrivate && name.at(0).isUpper()) {
- // Attached property
- // ### What about qualified types?
- QDeclarativeTypeNameCache *tnCache = QDeclarativeContextPrivate::get(context)->imports;
- if (tnCache) {
- QDeclarativeTypeNameCache::Data *d = tnCache->data(name);
- if (d && d->type && d->type->attachedPropertiesFunction()) {
- attachedFunc = d->type->index();
}
}
- return;
- } else if (name.count() >= 3 &&
- name.at(0) == QChar(QLatin1Char('o')) &&
- name.at(1) == QChar(QLatin1Char('n')) &&
- name.at(2).isUpper()) {
- // Signal
- QString signalName = name.mid(2);
+ }
+
+ const QString &terminal = path.last();
+
+ if (terminal.count() >= 3 &&
+ terminal.at(0) == QLatin1Char('o') &&
+ terminal.at(1) == QLatin1Char('n') &&
+ terminal.at(2).isUpper()) {
+
+ QString signalName = terminal.mid(2);
signalName[0] = signalName.at(0).toLower();
- QMetaMethod method = QDeclarativeCompiler::findSignalByName(obj->metaObject(), signalName.toLatin1().constData());
+ QMetaMethod method = QDeclarativeCompiler::findSignalByName(currentObject->metaObject(), signalName.toLatin1().constData());
if (method.signature()) {
+ object = currentObject;
core.load(method);
return;
}
- }
+ }
// Property
QDeclarativePropertyCache::Data local;
QDeclarativePropertyCache::Data *property =
- QDeclarativePropertyCache::property(context?context->engine():0, obj, name, local);
- if (property && !(property->flags & QDeclarativePropertyCache::Data::IsFunction))
+ QDeclarativePropertyCache::property(context?context->engine():0, currentObject, terminal, local);
+ if (property && !(property->flags & QDeclarativePropertyCache::Data::IsFunction)) {
+ object = currentObject;
core = *property;
+ }
}
/*!
@@ -224,7 +285,6 @@ QDeclarativeMetaProperty::QDeclarativeMetaProperty(const QDeclarativeMetaPropert
\value Property The property is a regular Qt property.
\value SignalProperty The property is a signal property.
\value Default The property is the default property.
- \value Attached The property is an attached property.
*/
/*!
@@ -242,8 +302,6 @@ QDeclarativeMetaPropertyPrivate::propertyCategory() const
if (type & QDeclarativeMetaProperty::ValueTypeProperty) {
return QDeclarativeMetaProperty::Normal;
- } else if (type & QDeclarativeMetaProperty::Attached) {
- return QDeclarativeMetaProperty::Object;
} else if (type & QDeclarativeMetaProperty::Property) {
int type = propertyType();
if (type == QVariant::Invalid)
@@ -299,8 +357,7 @@ bool QDeclarativeMetaProperty::operator==(const QDeclarativeMetaProperty &other)
// from the other members
return d->object == other.d->object &&
d->core == other.d->core &&
- d->valueType == other.d->valueType &&
- d->attachedFunc == other.d->attachedFunc;
+ d->valueType == other.d->valueType;
}
/*!
@@ -317,8 +374,6 @@ int QDeclarativeMetaPropertyPrivate::propertyType() const
uint type = q->type();
if (type & QDeclarativeMetaProperty::ValueTypeProperty) {
return valueType.valueTypePropType;
- } else if (type & QDeclarativeMetaProperty::Attached) {
- return qMetaTypeId<QObject *>();
} else if (type & QDeclarativeMetaProperty::Property) {
if (core.propType == (int)QVariant::LastType)
return qMetaTypeId<QVariant>();
@@ -336,8 +391,6 @@ QDeclarativeMetaProperty::Type QDeclarativeMetaProperty::type() const
{
if (d->core.flags & QDeclarativePropertyCache::Data::IsFunction)
return SignalProperty;
- else if (d->attachedFunc != -1)
- return Attached;
else if (d->valueType.valueTypeCoreIdx != -1)
return (Type)(Property | ValueTypeProperty);
else if (d->core.isValid())
@@ -385,7 +438,6 @@ QDeclarativeMetaProperty &QDeclarativeMetaProperty::operator=(const QDeclarative
d->valueType = other.d->valueType;
- d->attachedFunc = other.d->attachedFunc;
return *this;
}
@@ -503,22 +555,23 @@ QMetaMethod QDeclarativeMetaProperty::method() const
Returns the binding associated with this property, or 0 if no binding
exists.
*/
-QDeclarativeAbstractBinding *QDeclarativeMetaProperty::binding() const
+QDeclarativeAbstractBinding *
+QDeclarativeMetaPropertyPrivate::binding(const QDeclarativeMetaProperty &that)
{
- if (!isProperty() || (type() & Attached) || !d->object)
+ if (!that.isProperty() || !that.d->object)
return 0;
- QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(d->object);
+ QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(that.d->object);
if (!data)
return 0;
- if (!data->hasBindingBit(d->core.coreIndex))
+ if (!data->hasBindingBit(that.d->core.coreIndex))
return 0;
QDeclarativeAbstractBinding *binding = data->bindings;
while (binding) {
// ### This wont work for value types
- if (binding->propertyIndex() == d->core.coreIndex)
+ if (binding->propertyIndex() == that.d->core.coreIndex)
return binding;
binding = binding->m_nextBinding;
}
@@ -539,15 +592,17 @@ QDeclarativeAbstractBinding *QDeclarativeMetaProperty::binding() const
the binding sets the intial value, it will use these flags for the write).
*/
QDeclarativeAbstractBinding *
-QDeclarativeMetaProperty::setBinding(QDeclarativeAbstractBinding *newBinding, QDeclarativeMetaProperty::WriteFlags flags) const
+QDeclarativeMetaPropertyPrivate::setBinding(const QDeclarativeMetaProperty &that,
+ QDeclarativeAbstractBinding *newBinding,
+ QDeclarativeMetaProperty::WriteFlags flags)
{
- if (!isProperty() || (type() & Attached) || !d->object) {
+ if (!that.isProperty() || !that.d->object) {
if (newBinding)
newBinding->destroy();
return 0;
}
- return d->setBinding(d->object, d->core, newBinding, flags);
+ return that.d->setBinding(that.d->object, that.d->core, newBinding, flags);
}
QDeclarativeAbstractBinding *
@@ -578,22 +633,24 @@ QDeclarativeMetaPropertyPrivate::setBinding(QObject *object, const QDeclarativeP
return 0;
}
+
/*!
Returns the expression associated with this signal property, or 0 if no
signal expression exists.
*/
-QDeclarativeExpression *QDeclarativeMetaProperty::signalExpression() const
+QDeclarativeExpression *
+QDeclarativeMetaPropertyPrivate::signalExpression(const QDeclarativeMetaProperty &that)
{
- if (!(type() & SignalProperty))
+ if (!(that.type() & QDeclarativeMetaProperty::SignalProperty))
return 0;
- const QObjectList &children = d->object->children();
+ const QObjectList &children = that.d->object->children();
for (int ii = 0; ii < children.count(); ++ii) {
QObject *child = children.at(ii);
QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child);
- if (signal && signal->index() == coreIndex())
+ if (signal && signal->index() == that.coreIndex())
return signal->expression();
}
@@ -607,39 +664,33 @@ QDeclarativeExpression *QDeclarativeMetaProperty::signalExpression() const
Ownership of \a expr transfers to QML. Ownership of the return value is
assumed by the caller.
*/
-QDeclarativeExpression *QDeclarativeMetaProperty::setSignalExpression(QDeclarativeExpression *expr) const
+QDeclarativeExpression *
+QDeclarativeMetaPropertyPrivate::setSignalExpression(const QDeclarativeMetaProperty &that,
+ QDeclarativeExpression *expr)
{
- if (!(type() & SignalProperty)) {
+ if (!(that.type() & QDeclarativeMetaProperty::SignalProperty)) {
delete expr;
return 0;
}
- const QObjectList &children = d->object->children();
+ const QObjectList &children = that.d->object->children();
for (int ii = 0; ii < children.count(); ++ii) {
QObject *child = children.at(ii);
QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child);
- if (signal && signal->index() == coreIndex())
+ if (signal && signal->index() == that.coreIndex())
return signal->setExpression(expr);
}
if (expr) {
- QDeclarativeBoundSignal *signal = new QDeclarativeBoundSignal(d->object, method(), d->object);
+ QDeclarativeBoundSignal *signal = new QDeclarativeBoundSignal(that.d->object, that.method(), that.d->object);
return signal->setExpression(expr);
} else {
return 0;
}
}
-QObject *QDeclarativeMetaPropertyPrivate::attachedObject() const
-{
- if (attachedFunc == -1)
- return 0;
- else
- return qmlAttachedPropertiesObjectById(attachedFunc, object);
-}
-
/*!
Returns the property value.
*/
@@ -652,7 +703,7 @@ QVariant QDeclarativeMetaProperty::read() const
return QVariant();
- } else if (type() & Property || type() & Attached) {
+ } else if (type() & Property) {
return d->readValueProperty();
@@ -663,11 +714,7 @@ QVariant QDeclarativeMetaProperty::read() const
QVariant QDeclarativeMetaPropertyPrivate::readValueProperty()
{
uint type = q->type();
- if (type & QDeclarativeMetaProperty::Attached) {
-
- return QVariant::fromValue(attachedObject());
-
- } else if(type & QDeclarativeMetaProperty::ValueTypeProperty) {
+ if(type & QDeclarativeMetaProperty::ValueTypeProperty) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context);
QDeclarativeValueType *valueType = 0;
@@ -742,7 +789,7 @@ bool QDeclarativeMetaPropertyPrivate::writeValueProperty(const QVariant &value,
{
// Remove any existing bindings on this property
if (!(flags & QDeclarativeMetaProperty::DontRemoveBinding)) {
- QDeclarativeAbstractBinding *binding = q->setBinding(0);
+ QDeclarativeAbstractBinding *binding = setBinding(*q, 0);
if (binding) binding->destroy();
}
@@ -978,7 +1025,7 @@ bool QDeclarativeMetaProperty::write(const QVariant &value, QDeclarativeMetaProp
*/
bool QDeclarativeMetaProperty::hasChangedNotifier() const
{
- if (type() & Property && !(type() & Attached) && d->object) {
+ if (type() & Property && d->object) {
return d->object->metaObject()->property(d->core.coreIndex).hasNotifySignal();
}
return false;
@@ -993,8 +1040,7 @@ bool QDeclarativeMetaProperty::hasChangedNotifier() const
*/
bool QDeclarativeMetaProperty::needsChangedNotifier() const
{
- return type() & Property && !(type() & Attached) &&
- !property().isConstant();
+ return type() & Property && !property().isConstant();
}
/*!
@@ -1007,7 +1053,7 @@ bool QDeclarativeMetaProperty::needsChangedNotifier() const
*/
bool QDeclarativeMetaProperty::connectNotifier(QObject *dest, int method) const
{
- if (!(type() & Property) || (type() & Attached) || !d->object)
+ if (!(type() & Property) || !d->object)
return false;
QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex);
@@ -1028,7 +1074,7 @@ bool QDeclarativeMetaProperty::connectNotifier(QObject *dest, int method) const
*/
bool QDeclarativeMetaProperty::connectNotifier(QObject *dest, const char *slot) const
{
- if (!(type() & Property) || (type() & Attached) || !d->object)
+ if (!(type() & Property) || !d->object)
return false;
QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex);
@@ -1054,8 +1100,6 @@ int QDeclarativeMetaProperty::valueTypeCoreIndex() const
return d->valueType.valueTypeCoreIdx;
}
-Q_GLOBAL_STATIC(QDeclarativeValueTypeFactory, qmlValueTypes);
-
struct SerializedData {
QDeclarativeMetaProperty::Type type;
@@ -1118,83 +1162,6 @@ QDeclarativeMetaPropertyPrivate::restore(const QByteArray &data, QObject *object
}
/*!
- \internal
-
- Creates a QDeclarativeMetaProperty for the property \a name of \a obj. Unlike
- the QDeclarativeMetaProperty(QObject*, QString, QDeclarativeContext*) constructor, this static function
- will correctly handle dot properties, including value types and attached properties.
-*/
-QDeclarativeMetaProperty QDeclarativeMetaProperty::createProperty(QObject *obj,
- const QString &name,
- QDeclarativeContext *context)
-{
- QDeclarativeTypeNameCache *typeNameCache = context?QDeclarativeContextPrivate::get(context)->imports:0;
-
- QStringList path = name.split(QLatin1Char('.'));
- QObject *object = obj;
-
- for (int jj = 0; jj < path.count() - 1; ++jj) {
- const QString &pathName = path.at(jj);
-
- if (QDeclarativeTypeNameCache::Data *data = typeNameCache?typeNameCache->data(pathName):0) {
- if (data->type) {
- QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
- if (!func)
- return QDeclarativeMetaProperty();
- object = qmlAttachedPropertiesObjectById(data->type->index(), object);
- if (!object)
- return QDeclarativeMetaProperty();
- continue;
- } else {
- Q_ASSERT(data->typeNamespace);
- ++jj;
- data = data->typeNamespace->data(path.at(jj));
- if (!data || !data->type)
- return QDeclarativeMetaProperty();
- QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
- if (!func)
- return QDeclarativeMetaProperty();
- object = qmlAttachedPropertiesObjectById(data->type->index(), object);
- if (!object)
- return QDeclarativeMetaProperty();
- continue;
- }
- }
-
- QDeclarativeMetaProperty prop(object, pathName, context);
-
- if (jj == path.count() - 2 && prop.propertyType() < (int)QVariant::UserType &&
- qmlValueTypes()->valueTypes[prop.propertyType()]) {
- // We're now at a value type property. We can use a global valuetypes array as we
- // never actually use the objects, just look up their properties.
- QObject *typeObject =
- qmlValueTypes()->valueTypes[prop.propertyType()];
- int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData());
- if (idx == -1)
- return QDeclarativeMetaProperty();
- QMetaProperty vtProp = typeObject->metaObject()->property(idx);
-
- QDeclarativeMetaProperty p = prop;
- p.d->valueType.valueTypeCoreIdx = idx;
- p.d->valueType.valueTypePropType = vtProp.userType();
- return p;
- }
-
- QObject *objVal = QDeclarativeMetaType::toQObject(prop.read());
- if (!objVal)
- return QDeclarativeMetaProperty();
- object = objVal;
- }
-
- const QString &propName = path.last();
- QDeclarativeMetaProperty prop(object, propName, context);
- if (!prop.isValid())
- return QDeclarativeMetaProperty();
- else
- return prop;
-}
-
-/*!
Returns true if lhs and rhs refer to the same metaobject data
*/
bool QDeclarativeMetaPropertyPrivate::equal(const QMetaObject *lhs, const QMetaObject *rhs)
diff --git a/src/declarative/qml/qdeclarativemetaproperty.h b/src/declarative/qml/qdeclarativemetaproperty.h
index 4dd6668..dce0b4f 100644
--- a/src/declarative/qml/qdeclarativemetaproperty.h
+++ b/src/declarative/qml/qdeclarativemetaproperty.h
@@ -100,8 +100,7 @@ public:
Property = 0x01,
SignalProperty = 0x02,
Default = 0x08,
- Attached = 0x10,
- ValueTypeProperty = 0x20 };
+ ValueTypeProperty = 0x10 };
Type type() const;
bool isProperty() const;
@@ -121,15 +120,6 @@ public:
QMetaProperty property() const;
- QDeclarativeAbstractBinding *binding() const;
- QDeclarativeAbstractBinding *setBinding(QDeclarativeAbstractBinding *,
- QDeclarativeMetaProperty::WriteFlags flags = QDeclarativeMetaProperty::DontRemoveBinding) const;
-
- QDeclarativeExpression *signalExpression() const;
- QDeclarativeExpression *setSignalExpression(QDeclarativeExpression *) const;
-
- static QDeclarativeMetaProperty createProperty(QObject *, const QString &, QDeclarativeContext *context=0);
-
int coreIndex() const;
int valueTypeCoreIndex() const;
private:
diff --git a/src/declarative/qml/qdeclarativemetaproperty_p.h b/src/declarative/qml/qdeclarativemetaproperty_p.h
index 9fd5ed2..5ebd2c5 100644
--- a/src/declarative/qml/qdeclarativemetaproperty_p.h
+++ b/src/declarative/qml/qdeclarativemetaproperty_p.h
@@ -64,18 +64,18 @@ QT_BEGIN_NAMESPACE
class QDeclarativeContext;
class QDeclarativeEnginePrivate;
-class QDeclarativeMetaPropertyPrivate
+class Q_AUTOTEST_EXPORT QDeclarativeMetaPropertyPrivate
{
public:
QDeclarativeMetaPropertyPrivate()
- : q(0), context(0), object(0), isDefaultProperty(false), isNameCached(false),
- attachedFunc(-1) {}
+ : q(0), context(0), object(0), isDefaultProperty(false), isNameCached(false) {}
+
QDeclarativeMetaPropertyPrivate(const QDeclarativeMetaPropertyPrivate &other)
: q(0), context(other.context), object(other.object),
isDefaultProperty(other.isDefaultProperty), isNameCached(other.isNameCached),
core(other.core), nameCache(other.nameCache),
- valueType(other.valueType), attachedFunc(other.attachedFunc) {}
+ valueType(other.valueType) {}
QDeclarativeMetaProperty *q;
QDeclarativeContext *context;
@@ -89,13 +89,9 @@ public:
// Describes the "virtual" value-type sub-property.
QDeclarativePropertyCache::ValueTypeData valueType;
- // The attached property accessor
- int attachedFunc;
-
void initProperty(QObject *obj, const QString &name);
void initDefault(QObject *obj);
- QObject *attachedObject() const;
QMetaMethod findSignal(QObject *, const QString &);
int propertyType() const;
@@ -105,19 +101,32 @@ public:
bool writeValueProperty(const QVariant &, QDeclarativeMetaProperty::WriteFlags);
static const QMetaObject *rawMetaObjectForType(QDeclarativeEnginePrivate *, int);
- static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags);
- static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, QDeclarativeContext *,
- QDeclarativeMetaProperty::WriteFlags flags = 0);
- static QDeclarativeAbstractBinding *setBinding(QObject *, const QDeclarativePropertyCache::Data &, QDeclarativeAbstractBinding *,
- QDeclarativeMetaProperty::WriteFlags flags = QDeclarativeMetaProperty::DontRemoveBinding);
+ static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object,
+ const QVariant &value, int flags);
+ static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &,
+ QDeclarativeContext *, QDeclarativeMetaProperty::WriteFlags flags = 0);
+ static QDeclarativeAbstractBinding *setBinding(QObject *, const QDeclarativePropertyCache::Data &,
+ QDeclarativeAbstractBinding *,
+ QDeclarativeMetaProperty::WriteFlags flags = QDeclarativeMetaProperty::DontRemoveBinding);
static QByteArray saveValueType(const QMetaObject *, int,
const QMetaObject *, int);
static QByteArray saveProperty(const QMetaObject *, int);
- static QDeclarativeMetaProperty restore(const QByteArray &, QObject *, QDeclarativeContext * = 0);
+ static QDeclarativeMetaProperty restore(const QByteArray &, QObject *, QDeclarativeContext *);
static bool equal(const QMetaObject *, const QMetaObject *);
static bool canConvert(const QMetaObject *from, const QMetaObject *to);
+
+
+ // "Public" (to QML) methods
+ static QDeclarativeAbstractBinding *binding(const QDeclarativeMetaProperty &that);
+ static QDeclarativeAbstractBinding *setBinding(const QDeclarativeMetaProperty &that,
+ QDeclarativeAbstractBinding *,
+ QDeclarativeMetaProperty::WriteFlags flags = QDeclarativeMetaProperty::DontRemoveBinding);
+ static QDeclarativeExpression *signalExpression(const QDeclarativeMetaProperty &that);
+ static QDeclarativeExpression *setSignalExpression(const QDeclarativeMetaProperty &that,
+ QDeclarativeExpression *) ;
+
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index 8f78843..e87f8ba 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "qdeclarativemetatype.h"
+#include "qdeclarativemetatype_p.h"
#include "qdeclarativeproxymetaobject_p.h"
#include "qdeclarativecustomparser_p.h"
@@ -131,7 +131,7 @@ public:
int m_parserStatusCast;
int m_propertyValueSourceCast;
int m_propertyValueInterceptorCast;
- QDeclarativePrivate::CreateFunc m_extFunc;
+ QObject *(*m_extFunc)(QObject *);
const QMetaObject *m_extMetaObject;
int m_index;
QDeclarativeCustomParser *m_customParser;
@@ -148,13 +148,13 @@ QDeclarativeTypePrivate::QDeclarativeTypePrivate()
}
-QDeclarativeType::QDeclarativeType(int type, int listType, const char *iid, int index)
+QDeclarativeType::QDeclarativeType(int index, const QDeclarativePrivate::RegisterInterface &interface)
: d(new QDeclarativeTypePrivate)
{
d->m_isInterface = true;
- d->m_iid = iid;
- d->m_typeId = type;
- d->m_listId = listType;
+ d->m_iid = interface.iid;
+ d->m_typeId = interface.typeId;
+ d->m_listId = interface.listId;
d->m_newFunc = 0;
d->m_index = index;
d->m_isSetup = true;
@@ -162,36 +162,31 @@ QDeclarativeType::QDeclarativeType(int type, int listType, const char *iid, int
d->m_version_min = 0;
}
-QDeclarativeType::QDeclarativeType(int type, int listType,
- QObject *(*newFunc)(), const char *qmlName,
- int version_maj, int version_min,
- const QMetaObject *metaObject,
- QDeclarativeAttachedPropertiesFunc attachedPropertiesFunc,
- const QMetaObject *attachedType,
- int parserStatusCast, int propertyValueSourceCast, int propertyValueInterceptorCast,
- QDeclarativePrivate::CreateFunc extFunc,
- const QMetaObject *extMetaObject, int index,
- QDeclarativeCustomParser *customParser)
+QDeclarativeType::QDeclarativeType(int index, const QDeclarativePrivate::RegisterType &type)
: d(new QDeclarativeTypePrivate)
{
- d->m_name = qmlName;
- d->m_version_maj = version_maj;
- d->m_version_min = version_min;
- d->m_typeId = type;
- d->m_listId = listType;
- d->m_newFunc = newFunc;
- d->m_baseMetaObject = metaObject;
- d->m_attachedPropertiesFunc = attachedPropertiesFunc;
- d->m_attachedPropertiesType = attachedType;
- d->m_parserStatusCast = parserStatusCast;
- d->m_propertyValueSourceCast = propertyValueSourceCast;
- d->m_propertyValueInterceptorCast = propertyValueInterceptorCast;
- d->m_extFunc = extFunc;
+ QByteArray name = type.uri;
+ if (type.uri) name += '/';
+ name += type.elementName;
+
+ d->m_name = name;
+ d->m_version_maj = type.versionMajor;
+ d->m_version_min = type.versionMinor;
+ d->m_typeId = type.typeId;
+ d->m_listId = type.listId;
+ d->m_newFunc = type.create;
+ d->m_baseMetaObject = type.metaObject;
+ d->m_attachedPropertiesFunc = type.attachedPropertiesFunction;
+ d->m_attachedPropertiesType = type.attachedPropertiesMetaObject;
+ d->m_parserStatusCast = type.parserStatusCast;
+ d->m_propertyValueSourceCast = type.valueSourceCast;
+ d->m_propertyValueInterceptorCast = type.valueInterceptorCast;
+ d->m_extFunc = type.extensionObjectCreate;
d->m_index = index;
- d->m_customParser = customParser;
+ d->m_customParser = type.customParser;
- if (extMetaObject)
- d->m_extMetaObject = extMetaObject;
+ if (type.extensionMetaObject)
+ d->m_extMetaObject = type.extensionMetaObject;
}
QDeclarativeType::~QDeclarativeType()
@@ -357,15 +352,19 @@ int QDeclarativeType::index() const
return d->m_index;
}
-int QDeclarativeMetaType::registerInterface(const QDeclarativePrivate::MetaTypeIds &id,
- const char *iid)
+int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterface &interface)
{
+ if (interface.version > 0) {
+ qWarning("Cannot mix incompatible QML versions.");
+ return -1;
+ }
+
QWriteLocker lock(metaTypeDataLock());
QDeclarativeMetaTypeData *data = metaTypeData();
int index = data->types.count();
- QDeclarativeType *type = new QDeclarativeType(id.typeId, id.listId, iid, index);
+ QDeclarativeType *type = new QDeclarativeType(index, interface);
data->types.append(type);
data->idToType.insert(type->typeId(), type);
@@ -374,27 +373,22 @@ int QDeclarativeMetaType::registerInterface(const QDeclarativePrivate::MetaTypeI
if (!type->qmlTypeName().isEmpty())
data->nameToType.insert(type->qmlTypeName(), type);
- if (data->interfaces.size() <= id.typeId)
- data->interfaces.resize(id.typeId + 16);
- if (data->lists.size() <= id.listId)
- data->lists.resize(id.listId + 16);
- data->interfaces.setBit(id.typeId, true);
- data->lists.setBit(id.listId, true);
+ if (data->interfaces.size() <= interface.typeId)
+ data->interfaces.resize(interface.typeId + 16);
+ if (data->lists.size() <= interface.listId)
+ data->lists.resize(interface.listId + 16);
+ data->interfaces.setBit(interface.typeId, true);
+ data->lists.setBit(interface.listId, true);
return index;
}
-int QDeclarativeMetaType::registerType(const QDeclarativePrivate::MetaTypeIds &id, QObject *(*func)(),
- const char *uri, int version_maj, int version_min, const char *cname,
- const QMetaObject *mo, QDeclarativeAttachedPropertiesFunc attach, const QMetaObject *attachMo,
- int pStatus, int object, int valueSource, int valueInterceptor, QDeclarativePrivate::CreateFunc extFunc, const QMetaObject *extmo, QDeclarativeCustomParser *parser)
+int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &type)
{
- Q_UNUSED(object);
-
- if (cname) {
- for (int ii = 0; cname[ii]; ++ii) {
- if (!isalnum(cname[ii])) {
- qWarning("QDeclarativeMetaType: Invalid QML name %s", cname);
+ if (type.elementName) {
+ for (int ii = 0; type.elementName[ii]; ++ii) {
+ if (!isalnum(type.elementName[ii])) {
+ qWarning("QDeclarativeMetaType: Invalid QML element name %s", type.elementName);
return -1;
}
}
@@ -404,30 +398,23 @@ int QDeclarativeMetaType::registerType(const QDeclarativePrivate::MetaTypeIds &i
QDeclarativeMetaTypeData *data = metaTypeData();
int index = data->types.count();
- QByteArray name = uri;
- if (uri)
- name += '/';
- name += cname;
+ QDeclarativeType *dtype = new QDeclarativeType(index, type);
- QDeclarativeType *type = new QDeclarativeType(id.typeId, id.listId,
- func, name, version_maj, version_min, mo, attach, attachMo, pStatus,
- valueSource, valueInterceptor, extFunc, extmo, index, parser);
+ data->types.append(dtype);
+ data->idToType.insert(dtype->typeId(), dtype);
+ data->idToType.insert(dtype->qListTypeId(), dtype);
- data->types.append(type);
- data->idToType.insert(type->typeId(), type);
- data->idToType.insert(type->qListTypeId(), type);
-
- if (!type->qmlTypeName().isEmpty())
- data->nameToType.insertMulti(type->qmlTypeName(), type);
+ if (!dtype->qmlTypeName().isEmpty())
+ data->nameToType.insertMulti(dtype->qmlTypeName(), dtype);
- data->metaObjectToType.insert(type->baseMetaObject(), type);
+ data->metaObjectToType.insert(dtype->baseMetaObject(), dtype);
- if (data->objects.size() <= id.typeId)
- data->objects.resize(id.typeId + 16);
- if (data->lists.size() <= id.listId)
- data->lists.resize(id.listId + 16);
- data->objects.setBit(id.typeId, true);
- data->lists.setBit(id.listId, true);
+ if (data->objects.size() <= type.typeId)
+ data->objects.resize(type.typeId + 16);
+ if (data->lists.size() <= type.listId)
+ data->lists.resize(type.listId + 16);
+ data->objects.setBit(type.typeId, true);
+ data->lists.setBit(type.listId, true);
return index;
}
diff --git a/src/declarative/qml/qdeclarativemetatype.h b/src/declarative/qml/qdeclarativemetatype.h
deleted file mode 100644
index 0634939..0000000
--- a/src/declarative/qml/qdeclarativemetatype.h
+++ /dev/null
@@ -1,281 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 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$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEMETATYPE_H
-#define QDECLARATIVEMETATYPE_H
-
-#include "qdeclarativeprivate.h"
-#include "qdeclarativeparserstatus.h"
-#include "qdeclarativepropertyvaluesource.h"
-#include "qdeclarativepropertyvalueinterceptor.h"
-#include "qdeclarativelist.h"
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qvariant.h>
-#include <QtCore/qbitarray.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDeclarativeType;
-class QDeclarativeCustomParser;
-class Q_DECLARATIVE_EXPORT QDeclarativeMetaType
-{
-public:
- static int registerType(const QDeclarativePrivate::MetaTypeIds &, QObject *(*)(), const char *, int vmaj, int vmin, const char *qmlName, const QMetaObject *, QDeclarativeAttachedPropertiesFunc, const QMetaObject *, int pStatus, int object, int valueSource, int valueInterceptor, QDeclarativePrivate::CreateFunc extFunc, const QMetaObject *extmo, QDeclarativeCustomParser *);
- static int registerInterface(const QDeclarativePrivate::MetaTypeIds &, const char *);
-
- static bool copy(int type, void *data, const void *copy = 0);
-
- static QList<QByteArray> qmlTypeNames();
- static QList<QDeclarativeType*> qmlTypes();
-
- static QDeclarativeType *qmlType(const QByteArray &, int, int);
- static QDeclarativeType *qmlType(const QMetaObject *);
- static QDeclarativeType *qmlType(int);
-
- static QMetaProperty defaultProperty(const QMetaObject *);
- static QMetaProperty defaultProperty(QObject *);
- static QMetaMethod defaultMethod(const QMetaObject *);
- static QMetaMethod defaultMethod(QObject *);
-
- static bool isQObject(int);
- static QObject *toQObject(const QVariant &, bool *ok = 0);
-
- static int listType(int);
- static int attachedPropertiesFuncId(const QMetaObject *);
- static QDeclarativeAttachedPropertiesFunc attachedPropertiesFuncById(int);
-
- enum TypeCategory { Unknown, Object, List };
- static TypeCategory typeCategory(int);
-
- static bool isInterface(int);
- static const char *interfaceIId(int);
- static bool isList(int);
-
- typedef QVariant (*StringConverter)(const QString &);
- static void registerCustomStringConverter(int, StringConverter);
- static StringConverter customStringConverter(int);
-};
-
-class QDeclarativeTypePrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeType
-{
-public:
- QByteArray typeName() const;
- QByteArray qmlTypeName() const;
-
- int majorVersion() const;
- int minorVersion() const;
- bool availableInVersion(int vmajor, int vminor) const;
-
- QObject *create() const;
-
- QDeclarativeCustomParser *customParser() const;
-
- bool isInterface() const;
- int typeId() const;
- int qListTypeId() const;
-
- const QMetaObject *metaObject() const;
- const QMetaObject *baseMetaObject() const;
-
- QDeclarativeAttachedPropertiesFunc attachedPropertiesFunction() const;
- const QMetaObject *attachedPropertiesType() const;
-
- int parserStatusCast() const;
- QVariant fromObject(QObject *) const;
- const char *interfaceIId() const;
- int propertyValueSourceCast() const;
- int propertyValueInterceptorCast() const;
-
- int index() const;
-private:
- friend class QDeclarativeMetaType;
- friend class QDeclarativeTypePrivate;
- friend struct QDeclarativeMetaTypeData;
- QDeclarativeType(int, int, const char *, int);
- QDeclarativeType(int, int, QObject *(*)(), const char *, int, int, const QMetaObject *, QDeclarativeAttachedPropertiesFunc, const QMetaObject *, int, int, int, QDeclarativePrivate::CreateFunc, const QMetaObject *, int, QDeclarativeCustomParser *);
- ~QDeclarativeType();
-
- QDeclarativeTypePrivate *d;
-};
-
-template<typename T>
-int qmlRegisterType(const char *typeName)
-{
- QByteArray name(typeName);
- QDeclarativePrivate::MetaTypeIds ids = {
- qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(QByteArray("QDeclarativeListProperty<" + name + ">").constData()),
- };
-
- return QDeclarativeMetaType::registerType(ids, 0, 0, 0, 0, 0,
- &T::staticMetaObject,
- QDeclarativePrivate::attachedPropertiesFunc<T>(),
- QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QObject>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
- 0, 0, 0);
-}
-
-template<typename T>
-int qmlRegisterType(const char *uri, int version_maj, int version_min, const char *qmlName, const char *typeName)
-{
- QByteArray name(typeName);
- QDeclarativePrivate::MetaTypeIds ids = {
- qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(QByteArray("QDeclarativeListProperty<" + name + ">").constData()),
- };
-
- return QDeclarativeMetaType::registerType(ids, QDeclarativePrivate::create<T>,
- uri, version_maj, version_min, qmlName,
- &T::staticMetaObject,
- QDeclarativePrivate::attachedPropertiesFunc<T>(),
- QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QObject>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
- 0, 0, 0);
-}
-
-template<typename T, typename E>
-int qmlRegisterExtendedType(const char *typeName)
-{
- QByteArray name(typeName);
- QDeclarativePrivate::MetaTypeIds ids = {
- qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(QByteArray("QDeclarativeListProperty<" + name + ">").constData()),
- };
-
- QDeclarativeAttachedPropertiesFunc attached =
- QDeclarativePrivate::attachedPropertiesFunc<E>();
- const QMetaObject * attachedMo =
- QDeclarativePrivate::attachedPropertiesMetaObject<E>();
- if (!attached) {
- attached = QDeclarativePrivate::attachedPropertiesFunc<T>();
- attachedMo = QDeclarativePrivate::attachedPropertiesMetaObject<T>();
- }
-
- return QDeclarativeMetaType::registerType(ids, 0, 0, 0, 0, 0,
- &T::staticMetaObject, attached, attachedMo,
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QObject>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
- &QDeclarativePrivate::CreateParent<E>::create, &E::staticMetaObject, 0);
-}
-
-template<typename T, typename E>
-int qmlRegisterExtendedType(const char *uri, int version_maj, int version_min, const char *qmlName, const char *typeName)
-{
- QByteArray name(typeName);
- QDeclarativePrivate::MetaTypeIds ids = {
- qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(QByteArray("QDeclarativeListProperty<" + name + ">").constData()),
- };
-
- QDeclarativeAttachedPropertiesFunc attached =
- QDeclarativePrivate::attachedPropertiesFunc<E>();
- const QMetaObject * attachedMo =
- QDeclarativePrivate::attachedPropertiesMetaObject<E>();
- if (!attached) {
- attached = QDeclarativePrivate::attachedPropertiesFunc<T>();
- attachedMo = QDeclarativePrivate::attachedPropertiesMetaObject<T>();
- }
-
- return QDeclarativeMetaType::registerType(ids, QDeclarativePrivate::create<T>,
- uri, version_maj, version_min, qmlName,
- &T::staticMetaObject,
- attached, attachedMo,
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QObject>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
- &QDeclarativePrivate::CreateParent<E>::create,
- &E::staticMetaObject, 0);
-}
-
-template<typename T>
-int qmlRegisterInterface(const char *typeName)
-{
- QByteArray name(typeName);
- QDeclarativePrivate::MetaTypeIds ids = {
- qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(QByteArray("QDeclarativeListProperty<" + name + ">").constData()),
- };
-
- return QDeclarativeMetaType::registerInterface(ids, qobject_interface_iid<T *>());
-}
-
-template<typename T>
-int qmlRegisterCustomType(const char *uri, int version_maj, int version_min, const char *qmlName, const char *typeName, QDeclarativeCustomParser *parser)
-{
- QByteArray name(typeName);
- QDeclarativePrivate::MetaTypeIds ids = {
- qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(QByteArray("QDeclarativeListProperty<" + name + ">").constData()),
- };
-
- return QDeclarativeMetaType::registerType(ids, QDeclarativePrivate::create<T>,
- uri, version_maj, version_min, qmlName,
- &T::staticMetaObject,
- QDeclarativePrivate::attachedPropertiesFunc<T>(),
- QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QObject>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
- 0, 0, parser);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEMETATYPE_H
-
diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
new file mode 100644
index 0000000..ec5c045
--- /dev/null
+++ b/src/declarative/qml/qdeclarativemetatype_p.h
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEMETATYPE_P_H
+#define QDECLARATIVEMETATYPE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qdeclarative.h"
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qbitarray.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeType;
+class QDeclarativeCustomParser;
+class Q_DECLARATIVE_EXPORT QDeclarativeMetaType
+{
+public:
+ static bool copy(int type, void *data, const void *copy = 0);
+
+ static QList<QByteArray> qmlTypeNames();
+ static QList<QDeclarativeType*> qmlTypes();
+
+ static QDeclarativeType *qmlType(const QByteArray &, int, int);
+ static QDeclarativeType *qmlType(const QMetaObject *);
+ static QDeclarativeType *qmlType(int);
+
+ static QMetaProperty defaultProperty(const QMetaObject *);
+ static QMetaProperty defaultProperty(QObject *);
+ static QMetaMethod defaultMethod(const QMetaObject *);
+ static QMetaMethod defaultMethod(QObject *);
+
+ static bool isQObject(int);
+ static QObject *toQObject(const QVariant &, bool *ok = 0);
+
+ static int listType(int);
+ static int attachedPropertiesFuncId(const QMetaObject *);
+ static QDeclarativeAttachedPropertiesFunc attachedPropertiesFuncById(int);
+
+ enum TypeCategory { Unknown, Object, List };
+ static TypeCategory typeCategory(int);
+
+ static bool isInterface(int);
+ static const char *interfaceIId(int);
+ static bool isList(int);
+
+ typedef QVariant (*StringConverter)(const QString &);
+ static void registerCustomStringConverter(int, StringConverter);
+ static StringConverter customStringConverter(int);
+};
+
+class QDeclarativeTypePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeType
+{
+public:
+ QByteArray typeName() const;
+ QByteArray qmlTypeName() const;
+
+ int majorVersion() const;
+ int minorVersion() const;
+ bool availableInVersion(int vmajor, int vminor) const;
+
+ QObject *create() const;
+
+ QDeclarativeCustomParser *customParser() const;
+
+ bool isInterface() const;
+ int typeId() const;
+ int qListTypeId() const;
+
+ const QMetaObject *metaObject() const;
+ const QMetaObject *baseMetaObject() const;
+
+ QDeclarativeAttachedPropertiesFunc attachedPropertiesFunction() const;
+ const QMetaObject *attachedPropertiesType() const;
+
+ int parserStatusCast() const;
+ QVariant fromObject(QObject *) const;
+ const char *interfaceIId() const;
+ int propertyValueSourceCast() const;
+ int propertyValueInterceptorCast() const;
+
+ int index() const;
+private:
+ friend class QDeclarativeTypePrivate;
+ friend class QDeclarativeMetaTypeData;
+ friend int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterface &);
+ friend int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &);
+ QDeclarativeType(int, const QDeclarativePrivate::RegisterInterface &);
+ QDeclarativeType(int, const QDeclarativePrivate::RegisterType &);
+ ~QDeclarativeType();
+
+ QDeclarativeTypePrivate *d;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEMETATYPE_P_H
+
diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h
index cfd0b87..aae507e 100644
--- a/src/declarative/qml/qdeclarativeparser_p.h
+++ b/src/declarative/qml/qdeclarativeparser_p.h
@@ -56,9 +56,11 @@
#include "qdeclarative.h"
#include "qdeclarativerefcount_p.h"
-#include <QtCore/QByteArray>
-#include <QtCore/QList>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qurl.h>
#include <QtCore/qstring.h>
+#include <QtCore/qstringlist.h>
#include <private/qobject_p.h>
diff --git a/src/declarative/qml/qdeclarativeprivate.cpp b/src/declarative/qml/qdeclarativeprivate.cpp
deleted file mode 100644
index 444fe56..0000000
--- a/src/declarative/qml/qdeclarativeprivate.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 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 "qdeclarativeprivate.h"
-
-QT_BEGIN_NAMESPACE
-
-QDeclarativePrivate::InstanceType::InstanceType(int) {}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h
index c8a8c74..01369d4 100644
--- a/src/declarative/qml/qdeclarativeprivate.h
+++ b/src/declarative/qml/qdeclarativeprivate.h
@@ -43,11 +43,10 @@
#define QDECLARATIVEPRIVATE_H
#include <QtCore/qglobal.h>
-
+#include <QtCore/qvariant.h>
#ifndef Q_OS_WIN
#include <stdint.h>
#endif
-#include <QtCore/qvariant.h>
QT_BEGIN_HEADER
@@ -57,9 +56,6 @@ QT_MODULE(Declarative)
typedef QObject *(*QDeclarativeAttachedPropertiesFunc)(QObject *);
-//template<typename T>
-//struct qml_hasAttached { static bool const value = false; };
-
template <typename TYPE>
class QDeclarativeTypeInfo
{
@@ -70,11 +66,15 @@ public:
};
+class QDeclarativeCustomParser;
namespace QDeclarativePrivate
{
template<typename T>
QObject *create() { return new T; }
+ template<typename T>
+ QObject *createParent(QObject *p) { return new T(p); }
+
template<class From, class To, int N>
struct StaticCastSelectorClass
{
@@ -167,41 +167,44 @@ namespace QDeclarativePrivate
return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::metaObject();
}
- struct MetaTypeIds {
+ struct RegisterType {
+ int version;
+
int typeId;
int listId;
- };
- typedef QObject *(*CreateFunc)(QObject *);
+ QObject *(*create)();
- template<typename T>
- struct CreateParent {
- static QObject *create(QObject *other) {
- return new T(other);
- }
- };
+ const char *uri;
+ int versionMajor;
+ int versionMinor;
+ const char *elementName;
+ const QMetaObject *metaObject;
- template<typename T>
- struct CreateNoParent {
- static QObject *create() {
- return new T;
- }
- };
+ QDeclarativeAttachedPropertiesFunc attachedPropertiesFunction;
+ const QMetaObject *attachedPropertiesMetaObject;
- struct Q_DECLARATIVE_EXPORT InstanceType {
- InstanceType(int);
- };
+ int parserStatusCast;
+ int valueSourceCast;
+ int valueInterceptorCast;
+
+ QObject *(*extensionObjectCreate)(QObject *);
+ const QMetaObject *extensionMetaObject;
- template<typename T, int VMAJ, int VMIN>
- struct Define {
- static InstanceType instance;
+ QDeclarativeCustomParser *customParser;
};
-
- template<typename T>
- struct ExtCreate {
- static QObject *create(QObject *other) {
- return new T(other);
- }
+
+ struct RegisterInterface {
+ int version;
+
+ int typeId;
+ int listId;
+
+ const char *iid;
};
+
+ int Q_DECLARATIVE_EXPORT registerType(const RegisterType &);
+ int Q_DECLARATIVE_EXPORT registerType(const RegisterInterface &);
+
}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h
index 7f4b174..68e6e6b 100644
--- a/src/declarative/qml/qdeclarativepropertycache_p.h
+++ b/src/declarative/qml/qdeclarativepropertycache_p.h
@@ -58,7 +58,7 @@
#include <QtCore/qvector.h>
-#include <private/qscriptdeclarativeclass_p.h>
+#include <QtScript/private/qscriptdeclarativeclass_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index 9636350..f4c9cdd 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -771,7 +771,7 @@ bool ProcessAST::visit(AST::UiSourceElement *node)
} else {
QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","QDeclarativeJS declaration outside Script element"));
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","JavaScript declaration outside Script element"));
error.setLine(node->firstSourceLocation().startLine);
error.setColumn(node->firstSourceLocation().startColumn);
_parser->_errors << error;
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index 0d5fcb0..8a43cec 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -19,7 +19,6 @@ SOURCES += \
$$PWD/qdeclarativeboundsignal.cpp \
$$PWD/qdeclarativedom.cpp \
$$PWD/qdeclarativerefcount.cpp \
- $$PWD/qdeclarativeprivate.cpp \
$$PWD/qdeclarativemetatype.cpp \
$$PWD/qdeclarativestringconverters.cpp \
$$PWD/qdeclarativeclassfactory.cpp \
@@ -81,7 +80,7 @@ HEADERS += \
$$PWD/qdeclarativedom_p.h \
$$PWD/qdeclarativedom_p_p.h \
$$PWD/qdeclarativerefcount_p.h \
- $$PWD/qdeclarativemetatype.h \
+ $$PWD/qdeclarativemetatype_p.h \
$$PWD/qdeclarativeengine.h \
$$PWD/qdeclarativecontext.h \
$$PWD/qdeclarativeexpression.h \