OSDN Git Service

Load plugins at the beginning of the meta info initializing
authorMarco Bubke <marco.bubke@nokia.com>
Tue, 18 May 2010 14:38:09 +0000 (16:38 +0200)
committerKai Koehne <kai.koehne@nokia.com>
Fri, 28 May 2010 14:38:29 +0000 (16:38 +0200)
Reviewed-by: kkoehne
src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp
tests/auto/qml/qmldesigner/coretests/testcore.cpp

index 1d01df7..7bf4944 100644 (file)
@@ -68,6 +68,7 @@ public:
     void clear();
 
     void initialize();
+    void loadPlugins(QDeclarativeEngine *engine);
     void parseQmlTypes();
     void parseNonQmlTypes();
     void parseValueTypes();
@@ -112,6 +113,7 @@ void MetaInfoPrivate::initialize()
     QDeclarativeEngine engine;
     Q_UNUSED(engine);
 
+    loadPlugins(&engine);
     parseQmlTypes();
     parseNonQmlTypes();
     parseValueTypes();
@@ -120,7 +122,25 @@ void MetaInfoPrivate::initialize()
     m_isInitialized = true;
 }
 
+void MetaInfoPrivate::loadPlugins(QDeclarativeEngine *engine)
+{
+    // hack to load plugins
+    QDeclarativeComponent pluginComponent(engine);
+
+    QStringList pluginList;
+    pluginList += "import Qt 4.7";
+    pluginList += "import org.webkit 1.0";
+
+    // load maybe useful plugins
+    pluginList += "import Qt.labs.folderlistmodel 1.0";
+    pluginList += "import Qt.labs.gestures 1.0";
+    pluginList += "import Qt.multimedia 4.7";
+    pluginList += "import Qt.labs.particles 1.0";
 
+    QString componentString = QString("%1\n Item {}\n").arg(pluginList.join("\n"));
+
+    pluginComponent.setData(componentString.toLatin1(), QUrl());
+}
 
 void MetaInfoPrivate::parseProperties(NodeMetaInfo &nodeMetaInfo, const QMetaObject *qMetaObject) const
 {
index 3330097..a702214 100644 (file)
@@ -3606,6 +3606,12 @@ void TestCore::testMetaInfo()
 {
     QScopedPointer<Model> model(Model::create("Qt/Item"));
     QVERIFY(model.data());
+
+    // test whether default type is registered
+    QVERIFY(model->metaInfo().hasNodeMetaInfo("Qt/Item", 4, 7));
+
+    // test whether types from plugins are loaded
+    QVERIFY(model->metaInfo().hasNodeMetaInfo("org.webkit/WebView", 1, 0));
 }
 
 void TestCore::testMetaInfoSimpleType()