@@ -31,13 +31,33 @@
31#include "MouseTouchAdaptor.h"
31#include "MouseTouchAdaptor.h"
33namespace {
33namespace {
35+void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
37+ QStringList importPathList = engine->importPathList();
38+ for (int i = paths.count() -1; i >= 0; i--) {
40+ const QString& path = paths[i];
41+ QStringList::iterator iter = qFind(importPathList.begin(), importPathList.end(), path);
42+ if (iter == importPathList.end())
43+ importPathList.prepend(path);
45+ engine->setImportPathList(importPathList);
34/* When you append and import path to the list of import paths it will be the *last*
48/* When you append and import path to the list of import paths it will be the *last*
35 place where Qt will search for QML modules.
49 place where Qt will search for QML modules.
36 The usual QQmlEngine::addImportPath() actually prepends the given path.*/
50 The usual QQmlEngine::addImportPath() actually prepends the given path.*/
37−void appendImportPath(QQmlEngine *engine, const QString &path)
51+void appendImportPaths(QQmlEngine *engine, const QStringList &paths)
39 QStringList importPathList = engine->importPathList();
53 QStringList importPathList = engine->importPathList();
54+ Q_FOREACH(const QString& path, paths) {
56+ QStringList::iterator iter = qFind(importPathList.begin(), importPathList.end(), path);
57+ if (iter == importPathList.end())
40− importPathList.append(path);
58+ importPathList.append(path);
60+ importPathList.append(paths);
41 engine->setImportPathList(importPathList);
61 engine->setImportPathList(importPathList);
@@ -88,7 +108,7 @@ int main(int argc, char** argv)
88 QQuickView* view = new QQuickView();
108 QQuickView* view = new QQuickView();
89 view->setResizeMode(QQuickView::SizeRootObjectToView);
109 view->setResizeMode(QQuickView::SizeRootObjectToView);
90 view->setTitle("Qml Phone Shell");
110 view->setTitle("Qml Phone Shell");
91− view->engine()->setBaseUrl(QUrl::fromLocalFile(shellAppDirectory()));
111+ view->engine()->setBaseUrl(QUrl::fromLocalFile(::shellAppDirectory()));
92 if (args.contains(QLatin1String("-frameless"))) {
112 if (args.contains(QLatin1String("-frameless"))) {
93 view->setFlags(Qt::FramelessWindowHint);
113 view->setFlags(Qt::FramelessWindowHint);
@@ -114,9 +134,9 @@ int main(int argc, char** argv)
114 QObject::connect(view->engine(), SIGNAL(quit()), qApp, SLOT(quit()));
134 QObject::connect(view->engine(), SIGNAL(quit()), qApp, SLOT(quit()));
116 QUrl source("Shell.qml");
136 QUrl source("Shell.qml");
117− view->engine()->addImportPath(shellAppDirectory());
137+ prependImportPaths(view->engine(), QStringList() << ::shellAppDirectory());
118− view->engine()->addImportPath(shellImportPath());
138+ prependImportPaths(view->engine(), ::shellImportPaths());
119− appendImportPath(view->engine(), fakePluginsImportPath());
139+ appendImportPaths(view->engine(), QStringList() << ::fakePluginsImportPath());
120 view->setSource(source);
140 view->setSource(source);
121 view->setColor("transparent");
141 view->setColor("transparent");