@@ -31,13 +31,33 @@
3131#include "MouseTouchAdaptor.h"
3232
3333namespace {
34+
35+void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
36+{
37+ QStringList importPathList = engine->importPathList();
38+ for (int i = paths.count() -1; i >= 0; i--) {
39+ // don't duplicate
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);
44+ }
45+ engine->setImportPathList(importPathList);
46+}
47+
3448/* When you append and import path to the list of import paths it will be the *last*
3549 place where Qt will search for QML modules.
3650 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)
3852{
3953 QStringList importPathList = engine->importPathList();
40− importPathList.append(path);
54+ Q_FOREACH(const QString& path, paths) {
55+ // don't duplicate
56+ QStringList::iterator iter = qFind(importPathList.begin(), importPathList.end(), path);
57+ if (iter == importPathList.end())
58+ importPathList.append(path);
59+ }
60+ importPathList.append(paths);
4161 engine->setImportPathList(importPathList);
4262}
4363
@@ -88,7 +108,7 @@ int main(int argc, char** argv)
88108 QQuickView* view = new QQuickView();
89109 view->setResizeMode(QQuickView::SizeRootObjectToView);
90110 view->setTitle("Qml Phone Shell");
91− view->engine()->setBaseUrl(QUrl::fromLocalFile(shellAppDirectory()));
111+ view->engine()->setBaseUrl(QUrl::fromLocalFile(::shellAppDirectory()));
92112 if (args.contains(QLatin1String("-frameless"))) {
93113 view->setFlags(Qt::FramelessWindowHint);
94114 }
@@ -114,9 +134,9 @@ int main(int argc, char** argv)
114134 QObject::connect(view->engine(), SIGNAL(quit()), qApp, SLOT(quit()));
115135
116136 QUrl source("Shell.qml");
117− view->engine()->addImportPath(shellAppDirectory());
118− view->engine()->addImportPath(shellImportPath());
119− appendImportPath(view->engine(), fakePluginsImportPath());
137+ prependImportPaths(view->engine(), QStringList() << ::shellAppDirectory());
138+ prependImportPaths(view->engine(), ::shellImportPaths());
139+ appendImportPaths(view->engine(), QStringList() << ::fakePluginsImportPath());
120140 view->setSource(source);
121141 view->setColor("transparent");
122142