summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlengine.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-05-20 01:45:05 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-05-20 01:45:05 (GMT)
commit07908701ea4e8c998cee111b3e11aeff1bf26bf7 (patch)
tree4e8da6b8809f95d42915071a192ebae89cca96fd /src/declarative/qml/qmlengine.cpp
parente6fa564cb2f562eaca675872c08af14614a76283 (diff)
parent7f872ea70d357788bbda18f28d4765d5c3a1510e (diff)
downloadQt-07908701ea4e8c998cee111b3e11aeff1bf26bf7.zip
Qt-07908701ea4e8c998cee111b3e11aeff1bf26bf7.tar.gz
Qt-07908701ea4e8c998cee111b3e11aeff1bf26bf7.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml/qmlengine.cpp')
-rw-r--r--src/declarative/qml/qmlengine.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 0209c1d..c0ea463 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -425,8 +425,8 @@ bool QmlEnginePrivate::loadCache(QmlBasicScriptNodeCache &cache, const QString &
\code
QmlEngine engine;
- QmlComponent component("Text { text: \"Hello world!\" }");
- QFxItem *item = qobject_cast<QFxItem *>(component.create(&engine));
+ QmlComponent component(&engine, "Text { text: \"Hello world!\" }");
+ QFxItem *item = qobject_cast<QFxItem *>(component.create());
//add item to view, etc
...
@@ -615,6 +615,35 @@ QUrl QmlEngine::componentUrl(const QUrl& src, const QUrl& baseUrl) const
}
/*!
+ Returns the list of base urls the engine browses to find sub-components.
+
+ The search path consists of the base of the \a url, and, in the case of local files,
+ the directories imported using the "import" statement in \a qml.
+ */
+QList<QUrl> QmlEngine::componentSearchPath(const QByteArray &qml, const QUrl &url) const
+{
+ QList<QUrl> searchPath;
+
+ searchPath << url.resolved(QUrl(QLatin1String(".")));
+
+ if (QFileInfo(url.toLocalFile()).exists()) {
+ QmlScriptParser parser;
+ if (parser.parse(qml, url)) {
+ for (int i = 0; i < parser.imports().size(); ++i) {
+ QUrl importUrl = QUrl(parser.imports().at(i).uri);
+ if (importUrl.isRelative()) {
+ searchPath << url.resolved(importUrl);
+ } else {
+ searchPath << importUrl;
+ }
+ }
+ }
+ }
+
+ return searchPath;
+}
+
+/*!
Sets the common QNetworkAccessManager, \a network, used by all QML elements instantiated
by this engine.