summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-07 04:01:07 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-07 04:01:07 (GMT)
commitc380aeefbfa2cd1aa2d1d21f45101bfb058a40de (patch)
tree873d7b2f476273dedc8aa0347d7367f5c2e1de5a
parent1d27a2ace38d1098ef639086330a6fb88d8833d9 (diff)
downloadQt-c380aeefbfa2cd1aa2d1d21f45101bfb058a40de.zip
Qt-c380aeefbfa2cd1aa2d1d21f45101bfb058a40de.tar.gz
Qt-c380aeefbfa2cd1aa2d1d21f45101bfb058a40de.tar.bz2
Disallow creation of attached objects Keys and KeyNavigation
Also adds qmlRegisterUncreatableType<>() to allow registration of named types that cannot be created. Task-number: QTBUG-9575
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp5
-rw-r--r--src/declarative/qml/qdeclarative.h32
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp34
3 files changed, 36 insertions, 35 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
index 7989a27..35a4d00 100644
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -101,8 +101,6 @@ void QDeclarativeItemModule::defineModule()
qmlRegisterType<QDeclarativeGridView>("Qt",4,6,"GridView");
qmlRegisterType<QDeclarativeImage>("Qt",4,6,"Image");
qmlRegisterType<QDeclarativeItem>("Qt",4,6,"Item");
- qmlRegisterType<QDeclarativeKeyNavigationAttached>("Qt",4,6,"KeyNavigation");
- qmlRegisterType<QDeclarativeKeysAttached>("Qt",4,6,"Keys");
qmlRegisterType<QDeclarativeLayoutItem>("Qt",4,6,"LayoutItem");
qmlRegisterType<QDeclarativeListView>("Qt",4,6,"ListView");
qmlRegisterType<QDeclarativeLoader>("Qt",4,6,"Loader");
@@ -151,4 +149,7 @@ void QDeclarativeItemModule::defineModule()
#ifdef QT_WEBKIT_LIB
qmlRegisterType<QDeclarativeWebSettings>();
#endif
+
+ qmlRegisterUncreatableType<QDeclarativeKeyNavigationAttached>("Qt",4,6,"KeyNavigation");
+ qmlRegisterUncreatableType<QDeclarativeKeysAttached>("Qt",4,6,"Keys");
}
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
index 7c7f6e5..6e36d4f 100644
--- a/src/declarative/qml/qdeclarative.h
+++ b/src/declarative/qml/qdeclarative.h
@@ -119,6 +119,38 @@ int qmlRegisterType()
}
template<typename T>
+int qmlRegisterUncreatableType(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()),
+ 0, 0,
+
+ 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>
int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
{
QByteArray name(T::staticMetaObject.className());
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index d4c72bd..218a90b 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -71,38 +71,6 @@
#include "private/qdeclarativexmllistmodel_p.h"
#endif
-template<typename T>
-int qmlRegisterTypeEnums(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()),
- 0, 0,
-
- "Qt", 4, 6, 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);
-}
-
void QDeclarativeUtilModule::defineModule()
{
qmlRegisterType<QDeclarativeAnchorAnimation>("Qt",4,6,"AnchorAnimation");
@@ -142,7 +110,7 @@ void QDeclarativeUtilModule::defineModule()
qmlRegisterType<QDeclarativeStateOperation>();
qmlRegisterType<QDeclarativeAnchorSet>();
- qmlRegisterTypeEnums<QDeclarativeAbstractAnimation>("Animation");
+ qmlRegisterUncreatableType<QDeclarativeAbstractAnimation>("Qt",4,6,"Animation");
qmlRegisterCustomType<QDeclarativeListModel>("Qt", 4,6, "ListModel", "QDeclarativeListModel",
new QDeclarativeListModelParser);