summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-05-19 08:08:09 (GMT)
committerRoberto Raggi <roberto.raggi@nokia.com>2009-05-19 08:08:09 (GMT)
commit23c781b67c838b120e7fba42bc9008d38f191330 (patch)
tree4254e4dfd099ad7066b4b02330c1edbee8398086 /src/declarative/qml
parent6e8f112492dec917cdcd9bc50b992eca5d41b998 (diff)
parent6db78166ddfe935a0c968a6e6205a10253d50138 (diff)
downloadQt-23c781b67c838b120e7fba42bc9008d38f191330.zip
Qt-23c781b67c838b120e7fba42bc9008d38f191330.tar.gz
Qt-23c781b67c838b120e7fba42bc9008d38f191330.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qmlengine.cpp29
-rw-r--r--src/declarative/qml/qmlengine.h2
2 files changed, 31 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 0209c1d..425cba4 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -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.
diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h
index fde84d4..9382389 100644
--- a/src/declarative/qml/qmlengine.h
+++ b/src/declarative/qml/qmlengine.h
@@ -78,6 +78,8 @@ public:
QMap<QString,QString> nameSpacePaths() const;
QUrl componentUrl(const QUrl& src, const QUrl& baseUrl) const;
+ QList<QUrl> componentSearchPath(const QByteArray &qml, const QUrl &url) const;
+
void setNetworkAccessManager(QNetworkAccessManager *);
QNetworkAccessManager *networkAccessManager() const;