summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2010-03-17 16:13:00 (GMT)
committermae <qt-info@nokia.com>2010-03-17 16:14:52 (GMT)
commit47fb07c9fdf47584ae55f3412102bbeef5576b04 (patch)
tree772bde723eb4abbc8a7699ac9f2a15953d390267 /src/declarative/qml
parentb3cddbcf92a20585fd6fcd0a6c200c5e94b8669f (diff)
downloadQt-47fb07c9fdf47584ae55f3412102bbeef5576b04.zip
Qt-47fb07c9fdf47584ae55f3412102bbeef5576b04.tar.gz
Qt-47fb07c9fdf47584ae55f3412102bbeef5576b04.tar.bz2
Improve implicit "." import
The change moves the implicit "." import to the very end, i.e. the first lookup. It also gets the content of a remote qmldir from the resources.
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp37
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp7
2 files changed, 28 insertions, 16 deletions
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
index 5f80000..5014323 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -511,22 +511,6 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData
int waiting = 0;
- /*
- For local urls, add an implicit import "." to the beginning of a file. This will trigger
- the loading of the qmldir and the import of any native types from available plugins.
- */
- QUrl baseUrl = unit->imports.baseUrl();
- if (!toLocalFileOrQrc(baseUrl).isEmpty()) {
- QDeclarativeEnginePrivate::get(engine)->
- addToImport(&unit->imports,
- QString(),
- QLatin1String("."),
- QString(),
- -1, -1,
- QDeclarativeScriptParser::Import::File);
-
- }
-
foreach (QDeclarativeScriptParser::Import imp, unit->data.imports()) {
QString qmldircontentnetwork;
@@ -568,6 +552,27 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData
}
}
+ /*
+ For local urls, add an implicit import "." as first lookup. This will also trigger
+ the loading of the qmldir and the import of any native types from available plugins.
+ */
+ {
+
+ QString qmldircontentnetwork;
+ if (QDeclarativeCompositeTypeResource *resource
+ = resources.value(unit->imports.baseUrl().resolved(QUrl(QLatin1String("./qmldir")))))
+ qmldircontentnetwork = QString::fromUtf8(resource->data);
+
+ QDeclarativeEnginePrivate::get(engine)->
+ addToImport(&unit->imports,
+ qmldircontentnetwork,
+ QLatin1String("."),
+ QString(),
+ -1, -1,
+ QDeclarativeScriptParser::Import::File);
+ }
+
+
QList<QDeclarativeScriptParser::TypeReference*> types = unit->data.referencedTypes();
for (int ii = 0; ii < types.count(); ++ii) {
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 4449404..ce4a9f1 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1587,6 +1587,8 @@ public:
}
url = base.resolved(QUrl(url)).toString();
+ if (url.endsWith(QLatin1Char('/')))
+ url.chop(1);
}
s->uris.prepend(uri);
@@ -1623,6 +1625,11 @@ public:
}
}
+
+
+ /* now comes really nasty code. It makes "private" types load in the remote case, but
+ it does this by breaking the import order. This must go. Instead private types must
+ be marked private in the qmldir. */
if (url_return) {
*url_return = base.resolved(QUrl(QString::fromUtf8(type + ".qml")));
return true;