summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Alpert <aalpert@blackberry.com>2013-05-03 18:11:27 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-15 00:35:03 (GMT)
commit85462598d5adef315e77c88339e469bcb46b97b1 (patch)
tree0af5ef335a763a51440570f9297ba953c04da6c0 /src
parent583f6e11f13bd92737abf550b5979a52c208ae25 (diff)
downloadQt-85462598d5adef315e77c88339e469bcb46b97b1.zip
Qt-85462598d5adef315e77c88339e469bcb46b97b1.tar.gz
Qt-85462598d5adef315e77c88339e469bcb46b97b1.tar.bz2
Backport qmlRegisterUncreatableType with version template
Otherwise it is not possible to extend or add uncreatable types safely. Change-Id: I22e81bb46a69efcec3522454d5ad465099b2555b Reviewed-by: Christopher Adams <chris.adams@jollamobile.com> Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qdeclarativeprivate.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h
index 263d9b8..7fc9830 100644
--- a/src/declarative/qml/qdeclarativeprivate.h
+++ b/src/declarative/qml/qdeclarativeprivate.h
@@ -56,6 +56,10 @@
#include <QtCore/qglobal.h>
#include <QtCore/qvariant.h>
#include <QtCore/qurl.h>
+#include <QtDeclarative/QDeclarativeListProperty>
+#include <QtDeclarative/QDeclarativeParserStatus>
+#include <QtDeclarative/QDeclarativePropertyValueSource>
+#include <QtDeclarative/QDeclarativePropertyValueInterceptor>
QT_BEGIN_HEADER
@@ -279,6 +283,47 @@ namespace QDeclarativePrivate
return qmlregister(QDeclarativePrivate::ComponentRegistration, &type);
}
+ /*!
+ \internal
+ \fn int qmlRegisterUncreatableType(const char *url, const char *uri, int versionMajor, int versionMinor, const char *qmlName);
+ \relates QDeclarativeEngine
+
+ This overload is backported from Qt5, and allows uncreatable types to be versioned.
+ */
+ template<typename T, int metaObjectRevision>
+ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
+ {
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 1,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ 0, 0,
+ reason,
+
+ 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,
+ metaObjectRevision
+ };
+
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
+ }
+
}