summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2010-03-02 15:00:23 +0100
committerJesper Thomschutz <jesper.thomschutz@nokia.com>2010-03-08 14:09:39 +0100
commit708dfcfcf58eb387407836ad2a2fa5e9de84b838 (patch)
tree4f86ed8aa7c160d4701189616c216027cf8faef4
parentf66d6f37e17ba979ff7851beb5e4daa85192fcac (diff)
Adapted example to use the import mechanism
(cherry picked from commit 7fd5ade07bd05ff6cb6f4e7cfa7a74081b803809)
-rw-r--r--examples/declarative/imageprovider/ImageProviderCore/qmldir2
-rw-r--r--examples/declarative/imageprovider/imageprovider.cpp (renamed from examples/declarative/imageprovider/main.cpp)49
-rw-r--r--examples/declarative/imageprovider/imageprovider.pro14
-rw-r--r--examples/declarative/imageprovider/imageprovider.qml (renamed from examples/declarative/imageprovider/view.qml)1
-rw-r--r--examples/declarative/imageprovider/imageprovider.qrc5
5 files changed, 40 insertions, 31 deletions
diff --git a/examples/declarative/imageprovider/ImageProviderCore/qmldir b/examples/declarative/imageprovider/ImageProviderCore/qmldir
new file mode 100644
index 0000000000..1028590a84
--- /dev/null
+++ b/examples/declarative/imageprovider/ImageProviderCore/qmldir
@@ -0,0 +1,2 @@
+plugin imageprovider
+
diff --git a/examples/declarative/imageprovider/main.cpp b/examples/declarative/imageprovider/imageprovider.cpp
index d9d4c1ad6a..253dbf5bd2 100644
--- a/examples/declarative/imageprovider/main.cpp
+++ b/examples/declarative/imageprovider/imageprovider.cpp
@@ -39,7 +39,8 @@
**
****************************************************************************/
-#include <QApplication>
+
+#include <qdeclarativeextensionplugin.h>
#include <qdeclarativeengine.h>
#include <qdeclarativecontext.h>
@@ -70,29 +71,37 @@ public:
}
};
-int main(int argc, char ** argv)
+
+class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin
{
- QApplication app(argc, argv);
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri) {
+ Q_UNUSED(uri);
+
+ }
- QDeclarativeView view;
+ void initializeEngine(QDeclarativeEngine *engine, const char *uri) {
+ Q_UNUSED(uri);
- view.engine()->addImageProvider("colors", new ColorImageProvider);
+ engine->addImageProvider("colors", new ColorImageProvider);
- QStringList dataList;
- dataList.append("image://colors/red");
- dataList.append("image://colors/green");
- dataList.append("image://colors/blue");
- dataList.append("image://colors/brown");
- dataList.append("image://colors/orange");
- dataList.append("image://colors/purple");
- dataList.append("image://colors/yellow");
+ QStringList dataList;
+ dataList.append("image://colors/red");
+ dataList.append("image://colors/green");
+ dataList.append("image://colors/blue");
+ dataList.append("image://colors/brown");
+ dataList.append("image://colors/orange");
+ dataList.append("image://colors/purple");
+ dataList.append("image://colors/yellow");
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+ QDeclarativeContext *ctxt = engine->rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+ }
- view.setSource(QUrl("qrc:view.qml"));
- view.show();
+};
+
+#include "imageprovider.moc"
+
+Q_EXPORT_PLUGIN(ImageProviderExtensionPlugin);
- return app.exec();
-}
-//![0]
diff --git a/examples/declarative/imageprovider/imageprovider.pro b/examples/declarative/imageprovider/imageprovider.pro
index 60423ab6b7..e403bf8df4 100644
--- a/examples/declarative/imageprovider/imageprovider.pro
+++ b/examples/declarative/imageprovider/imageprovider.pro
@@ -1,9 +1,11 @@
-TEMPLATE = app
-TARGET = imageprovider
-DEPENDPATH += .
-INCLUDEPATH += .
+TEMPLATE = lib
+TARGET = imageprovider
QT += declarative
+CONFIG += qt plugin
+
+TARGET = $$qtLibraryTarget($$TARGET)
+DESTDIR = ImageProviderCore
# Input
-SOURCES += main.cpp
-RESOURCES += imageprovider.qrc
+SOURCES += imageprovider.cpp
+
diff --git a/examples/declarative/imageprovider/view.qml b/examples/declarative/imageprovider/imageprovider.qml
index 2ab729d047..a1f2794dd2 100644
--- a/examples/declarative/imageprovider/view.qml
+++ b/examples/declarative/imageprovider/imageprovider.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import ImageProviderCore 1.0
//![0]
ListView {
width: 100
diff --git a/examples/declarative/imageprovider/imageprovider.qrc b/examples/declarative/imageprovider/imageprovider.qrc
deleted file mode 100644
index 17e9301471..0000000000
--- a/examples/declarative/imageprovider/imageprovider.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>view.qml</file>
-</qresource>
-</RCC>