summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlmoduleplugin.cpp
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-02-01 05:00:28 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-02-01 05:00:28 (GMT)
commit6c51b1c9e456f39d4e75303fe74d348e7f859e1b (patch)
tree5c7bcd5a6c4fe009a6ee7b6ef625d3f643dc1347 /src/declarative/qml/qmlmoduleplugin.cpp
parent7e85c6dc7ba0aaa6dfcad40dc0e9df0e2adb3741 (diff)
downloadQt-6c51b1c9e456f39d4e75303fe74d348e7f859e1b.zip
Qt-6c51b1c9e456f39d4e75303fe74d348e7f859e1b.tar.gz
Qt-6c51b1c9e456f39d4e75303fe74d348e7f859e1b.tar.bz2
Don't use statics for type definition, at least for plugin modules.
Task-number: QT-2798
Diffstat (limited to 'src/declarative/qml/qmlmoduleplugin.cpp')
-rw-r--r--src/declarative/qml/qmlmoduleplugin.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/declarative/qml/qmlmoduleplugin.cpp b/src/declarative/qml/qmlmoduleplugin.cpp
index 3346ec7..2f2cb25 100644
--- a/src/declarative/qml/qmlmoduleplugin.cpp
+++ b/src/declarative/qml/qmlmoduleplugin.cpp
@@ -59,11 +59,12 @@ QT_BEGIN_NAMESPACE
exporting the class with the Q_EXPORT_PLUGIN2() macro. See \l{How
to Create Qt Plugins} for details.
- The plugin should register QML types with QML_DEFINE_TYPE.
-
The strings returned by keys() should be the list of URIs of modules
that the plugin registers.
+ The plugin should register QML types with qmlRegisterType() when the
+ defineModule() method is called.
+
\sa examples/declarative/plugins
*/
@@ -86,4 +87,25 @@ QmlModulePlugin::~QmlModulePlugin()
{
}
+/*!
+ \fn void QmlModulePlugin::defineModule(const QString& uri)
+
+ Subclasses must override this function to register types
+ of the module \a uri, which will be one of the strings returned by keys().
+
+ The plugin registers QML types with qmlRegisterType():
+
+ \code
+ qmlRegisterType<MyClass>("com.nokia.MyModule", 1, 0, "MyType", "MyClass");
+ \endcode
+*/
+
+void QmlModulePlugin::defineModuleOnce(const QString& uri)
+{
+ if (!defined.contains(uri)) {
+ defined += uri;
+ defineModule(uri);
+ }
+}
+
QT_END_NAMESPACE