diff options
-rw-r--r-- | demos/declarative/flickr/content/ImageDetails.qml | 15 | ||||
-rw-r--r-- | doc/src/declarative/modules.qdoc | 1 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 2 | ||||
-rw-r--r-- | src/declarative/fx/qfxpainteditem.cpp | 10 | ||||
-rw-r--r-- | src/declarative/fx/qfxwebview.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlbindablevalue.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcomponent.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompositetypemanager.cpp | 25 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompositetypemanager_p.h | 5 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontext.cpp | 29 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontext.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 241 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.h | 23 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine_p.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetatype.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlscriptparser.cpp | 15 | ||||
-rw-r--r-- | src/declarative/qml/qmlscriptparser_p.h | 11 | ||||
-rw-r--r-- | src/declarative/util/qmlscript.cpp | 5 | ||||
-rw-r--r-- | tools/qmlviewer/main.cpp | 4 | ||||
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 5 |
20 files changed, 184 insertions, 219 deletions
diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index 6adb397..f53a43b 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -89,6 +89,7 @@ Flipable { // Center image if it is smaller than the flickable area. x: ImageContainer.width > width*scale ? (ImageContainer.width - width*scale) / 2 : 0 y: ImageContainer.height > height*scale ? (ImageContainer.height - height*scale) / 2 : 0 + smooth: !Flick.moving onStatusChanged : { // Default scale shows the entire image. if (status == 0 && width != 0) { @@ -135,7 +136,19 @@ Flipable { transitions: [ Transition { - NumberAnimation { easing: "easeInOutQuad"; properties: "rotation"; duration: 500 } + SequentialAnimation { + SetPropertyAction { + target: BigImage + property: "smooth" + value: false + } + NumberAnimation { easing: "easeInOutQuad"; properties: "rotation"; duration: 500 } + SetPropertyAction { + target: BigImage + property: "smooth" + value: !Flick.moving + } + } } ] } diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc index 194be40..60cf2a4 100644 --- a/doc/src/declarative/modules.qdoc +++ b/doc/src/declarative/modules.qdoc @@ -25,6 +25,7 @@ The import statement cannot be used by remote content. Ideas for full module support.... +See QT-558. * Modularity within applications diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 223af60..bd4def4 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1982,7 +1982,7 @@ void QFxItem::newChild(const QString &type) { Q_D(QFxItem); - QUrl url = qmlContext(this)->resolvedUri(QUrl(type)); + QUrl url = qmlContext(this)->resolvedUrl(QUrl(type)); if (url.isEmpty()) return; diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 65589f2..0a13dc4 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -232,10 +232,10 @@ void QFxPaintedItem::paintGLContents(GLPainter &p) #if defined(QFX_RENDER_QPAINTER) bool oldAntiAliasing = p.testRenderHint(QPainter::Antialiasing); bool oldSmoothPixmap = p.testRenderHint(QPainter::SmoothPixmapTransform); - if (d->smooth) { - p.setRenderHints(QPainter::Antialiasing, true); + if (oldAntiAliasing) + p.setRenderHints(QPainter::Antialiasing, false); // cannot stitch properly otherwise + if (d->smooth) p.setRenderHints(QPainter::SmoothPixmapTransform, true); - } QRectF clipf = p.clipRegion().boundingRect(); if (clipf.isEmpty()) clipf = mapToScene(content); // ### Inefficient: Maps toScene and then fromScene @@ -330,10 +330,10 @@ void QFxPaintedItem::paintGLContents(GLPainter &p) glDisableClientState(GL_TEXTURE_COORD_ARRAY); #endif #if defined(QFX_RENDER_QPAINTER) - if (d->smooth) { + if (oldAntiAliasing) p.setRenderHints(QPainter::Antialiasing, oldAntiAliasing); + if (d->smooth) p.setRenderHints(QPainter::SmoothPixmapTransform, oldSmoothPixmap); - } #endif } diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 3ab64bc..c6a8ebf 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -1006,7 +1006,7 @@ QFxWebView *QFxWebPage::view() QObject *QFxWebPage::createPlugin(const QString &, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) { - QUrl comp = qmlContext(view())->resolvedUri(url); + QUrl comp = qmlContext(view())->resolvedUrl(url); return new QWidget_Dummy_Plugin(comp,view(),paramNames,paramValues); } diff --git a/src/declarative/qml/qmlbindablevalue.cpp b/src/declarative/qml/qmlbindablevalue.cpp index 8e74250..6dda5e3 100644 --- a/src/declarative/qml/qmlbindablevalue.cpp +++ b/src/declarative/qml/qmlbindablevalue.cpp @@ -152,7 +152,7 @@ void QmlBindableValue::update() } if (d->property.propertyType() == QVariant::Url && - value.canConvert(QVariant::String) && !value.isNull()) + (value.type() == QVariant::String || value.type() == QVariant::ByteArray) && !value.isNull()) value.setValue(context()->resolvedUrl(QUrl(value.toString()))); d->property.write(value); diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index a9f5442..6b83c1f 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -122,7 +122,7 @@ void QmlComponentPrivate::typeDataReady() void QmlComponentPrivate::fromTypeData(QmlCompositeTypeData *data) { - url = QUrl(data->url); + url = data->imports.baseUrl(); QmlCompiledComponent *c = data->toCompiledComponent(engine); if (!c) { diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index ef77803..413f820 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -88,7 +88,7 @@ QmlComponent *QmlCompositeTypeData::toComponent(QmlEngine *engine) component = new QmlComponent(engine, cc, -1, -1, 0); } else { component = new QmlComponent(engine, 0); - component->d_func()->url = QUrl(url); + component->d_func()->url = imports.baseUrl(); component->d_func()->errors = errors; } @@ -103,8 +103,8 @@ QmlCompositeTypeData::toCompiledComponent(QmlEngine *engine) if (status == Complete && !compiledComponent) { compiledComponent = new QmlCompiledComponent; - compiledComponent->url = QUrl(url); - compiledComponent->name = url.toLatin1(); // ### + compiledComponent->url = imports.baseUrl(); + compiledComponent->name = compiledComponent->url.toString().toLatin1(); // ### QmlCompiler compiler; if (!compiler.compile(engine, this, compiledComponent)) { @@ -143,7 +143,7 @@ QmlCompositeTypeData *QmlCompositeTypeManager::get(const QUrl &url) if (!unit) { unit = new QmlCompositeTypeData; unit->status = QmlCompositeTypeData::Waiting; - unit->url = url.toString(); + unit->imports.setBaseUrl(url); components.insert(url.toString(), unit); loadSource(unit); @@ -158,7 +158,7 @@ QmlCompositeTypeManager::getImmediate(const QByteArray &data, const QUrl &url) { QmlCompositeTypeData *unit = new QmlCompositeTypeData; unit->status = QmlCompositeTypeData::Waiting; - unit->url = url.toString(); + unit->imports.setBaseUrl(url); setData(unit, data, url); return unit; } @@ -209,7 +209,7 @@ void QmlCompositeTypeManager::replyFinished() void QmlCompositeTypeManager::loadSource(QmlCompositeTypeData *unit) { - QUrl url(unit->url); + QUrl url(unit->imports.baseUrl()); if (url.scheme() == QLatin1String("file")) { @@ -250,8 +250,9 @@ void QmlCompositeTypeManager::setData(QmlCompositeTypeData *unit, doComplete(unit); } else { - - engine->addNameSpacePaths(unit->data.nameSpacePaths()); + foreach (QmlScriptParser::Import imp, unit->data.imports()) { + engine->addImport(&unit->imports, imp.uri, imp.as, imp.version_major, imp.version_minor); + } compile(unit); } @@ -313,19 +314,19 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) continue; } - ref.type = QmlMetaType::qmlType(type); + ref.type = engine->resolveBuiltInType(unit->imports, type); if (ref.type) { unit->types << ref; continue; } - QUrl url = engine->componentUrl(QUrl(QLatin1String(type + ".qml")), QUrl(unit->url)); + QUrl url = engine->resolveType(unit->imports, QLatin1String(type)); QmlCompositeTypeData *urlUnit = components.value(url.toString()); if (!urlUnit) { urlUnit = new QmlCompositeTypeData; urlUnit->status = QmlCompositeTypeData::Waiting; - urlUnit->url = url.toString(); + urlUnit->imports.setBaseUrl(url); components.insert(url.toString(), urlUnit); loadSource(urlUnit); @@ -338,7 +339,7 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) unit->status = QmlCompositeTypeData::Error; { QmlError error; - error.setUrl(QUrl(unit->url)); + error.setUrl(unit->imports.baseUrl()); error.setDescription(tr("Type %1 unavailable").arg(QLatin1String(type))); unit->errors << error; } diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h index 96e77d6..a393da4 100644 --- a/src/declarative/qml/qmlcompositetypemanager_p.h +++ b/src/declarative/qml/qmlcompositetypemanager_p.h @@ -57,10 +57,10 @@ #include <private/qmlscriptparser_p.h> #include <private/qmlrefcount_p.h> #include <QtDeclarative/qmlerror.h> +#include <QtDeclarative/qmlengine.h> QT_BEGIN_NAMESPACE -class QmlEngine; class QmlCompiledComponent; class QmlComponentPrivate; class QmlComponent; @@ -86,7 +86,8 @@ struct QmlCompositeTypeData : public QmlRefCount QList<QmlError> errors; - QString url; + QmlEngine::Imports imports; + QList<QmlCompositeTypeData *> dependants; // Return a QmlComponent if the QmlCompositeTypeData is not in the Waiting diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index b590596..e97d2e9 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -449,35 +449,6 @@ QUrl QmlContext::resolvedUrl(const QUrl &src) } /*! - Resolves the component URI \a src relative to the URL of the - containing component, and according to the - \l {QmlEngine::nameSpacePaths()} {namespace paths} of the - context's engine, returning the resolved URL. - - \sa QmlEngine::componentUrl(), setBaseUrl() -*/ -QUrl QmlContext::resolvedUri(const QUrl &src) -{ - QmlContext *ctxt = this; - if (src.isRelative()) { - if (ctxt) { - while(ctxt) { - if (ctxt->d_func()->url.isValid()) - break; - else - ctxt = ctxt->parentContext(); - } - - if (ctxt) - return ctxt->d_func()->engine->componentUrl(src, ctxt->d_func()->url); - } - return QUrl(); - } else { - return ctxt->d_func()->engine->componentUrl(src, QUrl()); - } -} - -/*! Explicitly sets the url both resolveUri() and resolveUrl() will use for relative references to \a baseUrl. diff --git a/src/declarative/qml/qmlcontext.h b/src/declarative/qml/qmlcontext.h index f5858cb..e0b6d7b 100644 --- a/src/declarative/qml/qmlcontext.h +++ b/src/declarative/qml/qmlcontext.h @@ -77,7 +77,6 @@ public: static QmlContext *activeContext(); - QUrl resolvedUri(const QUrl &); QUrl resolvedUrl(const QUrl &); void setBaseUrl(const QUrl &); diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index d88d11f..4acdd0c 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -483,132 +483,6 @@ QmlContext *QmlEngine::activeContext() } /*! - Sets the mappings from namespace URIs to URL to \a map. - - \sa nameSpacePaths() -*/ -void QmlEngine::setNameSpacePaths(const QMap<QString,QString>& map) -{ - Q_D(QmlEngine); - d->nameSpacePaths = map; -} - -/*! - Adds mappings (given by \a map) from namespace URIs to URL. - - \sa nameSpacePaths() -*/ -void QmlEngine::addNameSpacePaths(const QMap<QString,QString>& map) -{ - Q_D(QmlEngine); - d->nameSpacePaths.unite(map); -} - -/*! - Adds a mapping from namespace URI \a ns to URL \a path. - - \sa nameSpacePaths() -*/ -void QmlEngine::addNameSpacePath(const QString& ns, const QString& path) -{ - Q_D(QmlEngine); - d->nameSpacePaths.insertMulti(ns,path); -} - -/*! - Returns the mapping from namespace URIs to URLs. - - Currently, only the empty namespace is supported - (i.e. types cannot be qualified with a namespace). - - The QML \c import statement can be used to import a directory of - components into the empty namespace. - - \qml - import "MyModuleDirectory" - \endqml - - This is also possible from C++: - - \code - engine->addNameSpacePath("","file:///opt/abcdef"); - \endcode - - \sa componentUrl() -*/ -QMap<QString,QString> QmlEngine::nameSpacePaths() const -{ - Q_D(const QmlEngine); - return d->nameSpacePaths; -} - -/*! - Returns the URL for the component source \a src, as mapped - by the nameSpacePaths(), resolved relative to \a baseUrl. - - \sa nameSpacePaths() -*/ -QUrl QmlEngine::componentUrl(const QUrl& src, const QUrl& baseUrl) const -{ - Q_D(const QmlEngine); - - // Find the most-specific namespace matching src. - // For files, multiple paths can be given, the first found is used. - QUrl r; - QMap<QString, QString>::const_iterator i = d->nameSpacePaths.constBegin(); - QString rns=QLatin1String(":"); // ns of r, if file found, initial an imposible namespace - QString srcstring = src.toString(); - while (i != d->nameSpacePaths.constEnd()) { - QString ns = i.key(); - QString path = i.value(); - if (ns != rns) { - if (srcstring.startsWith(ns) && (ns.length()==0 || srcstring[ns.length()]==QLatin1Char('/'))) { - QString file = ns.length()==0 ? srcstring : srcstring.mid(ns.length()+1); - QUrl cr = baseUrl.resolved(QUrl(path + QLatin1String("/") + file)); - QString lf = cr.toLocalFile(); - if (lf.isEmpty() || QFile::exists(lf)) { - r = cr; - rns = ns; - } - } - } - ++i; - } - if (r.isEmpty()) - r = baseUrl.resolved(src); - return r; -} - -/*! - 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. @@ -1223,4 +1097,119 @@ void QmlObjectScriptClass::setProperty(QScriptValue &object, scriptEngine->currentContext()->setActivationObject(oldact); } + +class QmlImportsPrivate { +public: + void add(const QString& uri, const QString& prefix, int version_major, int version_minor) + { + TypeSet *s; + if (prefix.isEmpty()) { + s = &unqualifiedset; + } else { + s = set.value(prefix); + if (!s) + set.insert(prefix,(s=new TypeSet)); + } + QString url = uri; + s->urls.append(url); + s->vmaj.append(version_major); + s->vmin.append(version_minor); + } + + QUrl find(const QString& base, const QString& type) + { + TypeSet *s = 0; + int dot = type.indexOf(QLatin1Char('.')); + if (dot >= 0) { + while (!s) { + s = set.value(type.left(dot)); + int ndot = type.indexOf(QLatin1Char('.'),dot+1); + if (ndot > 0) + dot = ndot; + else + break; + } + } else { + s = &unqualifiedset; + } + QString unqualifiedtype = type.mid(dot+1); + QUrl baseUrl(base); + if (s) { + for (int i=0; i<s->urls.count(); ++i) { + QUrl url = baseUrl.resolved(QUrl(s->urls.at(i) +QLatin1String("/")+ unqualifiedtype + QLatin1String(".qml"))); + // XXX search non-files too! (eg. zip files, see QT-524) + QFileInfo f(url.toLocalFile()); + if (f.exists()) + return url; + } + } + return baseUrl.resolved(QUrl(type + QLatin1String(".qml"))); + } + + QmlType *findBuiltin(const QString& base, const QByteArray& type) + { + // XXX import only have one space of imports! + TypeSet *s = 0; + int dot = type.indexOf('.'); + if (dot >= 0) { + while (!s) { + s = set.value(QString::fromLatin1(type.left(dot))); + int ndot = type.indexOf('.',dot+1); + if (ndot > 0) + dot = ndot; + else + break; + } + } else { + s = &unqualifiedset; + } + QByteArray unqualifiedtype = dot < 0 ? type : type.mid(dot+1); // common-case opt (QString::mid works fine, but slower) + if (s) { + for (int i=0; i<s->urls.count(); ++i) { + QmlType *t = QmlMetaType::qmlType(s->urls.at(i).toLatin1()+"/"+unqualifiedtype); + if (t) return t; + } + } + return QmlMetaType::qmlType(type); + } + +private: + struct TypeSet { + QStringList urls; + QList<int> vmaj; + QList<int> vmin; + }; + TypeSet unqualifiedset; + QHash<QString,TypeSet* > set; +}; + +QmlEngine::Imports::Imports() : + d(new QmlImportsPrivate) +{ +} + +QmlEngine::Imports::~Imports() +{ +} + +void QmlEngine::Imports::setBaseUrl(const QUrl& url) +{ + base = url; +} + +void QmlEngine::addImport(Imports* imports, const QString& uri, const QString& prefix, int version_major, int version_minor) const +{ + imports->d->add(uri,prefix,version_major,version_minor); +} + +QUrl QmlEngine::resolveType(const Imports& imports, const QString& type) const +{ + return imports.d->find(imports.base,type); +} + +QmlType* QmlEngine::resolveBuiltInType(const Imports& imports, const QByteArray& type) const +{ + return imports.d->findBuiltin(imports.base,type); +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h index 9e0ac87..0c9da39 100644 --- a/src/declarative/qml/qmlengine.h +++ b/src/declarative/qml/qmlengine.h @@ -42,6 +42,7 @@ #ifndef QMLENGINE_H #define QMLENGINE_H +#include <QtCore/qurl.h> #include <QtCore/qobject.h> #include <QtCore/qmap.h> #include <QtScript/qscriptvalue.h> @@ -54,8 +55,10 @@ QT_MODULE(Declarative) class QmlComponent; class QmlEnginePrivate; +class QmlImportsPrivate; class QmlExpression; class QmlContext; +class QmlType; class QUrl; class QScriptEngine; class QScriptContext; @@ -74,13 +77,19 @@ public: void clearComponentCache(); - void setNameSpacePaths(const QMap<QString,QString>& map); - void addNameSpacePaths(const QMap<QString,QString>& map); - void addNameSpacePath(const QString&,const QString&); - QMap<QString,QString> nameSpacePaths() const; - QUrl componentUrl(const QUrl& src, const QUrl& baseUrl) const; - - QList<QUrl> componentSearchPath(const QByteArray &qml, const QUrl &url) const; + struct Imports { + Imports(); + ~Imports(); + void setBaseUrl(const QUrl& url); + QUrl baseUrl() const { return base; } + private: + friend class QmlEngine; + QUrl base; + QmlImportsPrivate *d; + }; + void addImport(Imports*, const QString& uri, const QString& prefix, int version_major, int version_minor) const; + QUrl resolveType(const Imports&, const QString& type) const; + QmlType* resolveBuiltInType(const Imports& imports, const QByteArray& type) const; void setNetworkAccessManager(QNetworkAccessManager *); QNetworkAccessManager *networkAccessManager() const; diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 9171fbb..9a8b9fb 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -164,7 +164,6 @@ public: mutable QNetworkAccessManager *networkAccessManager; QmlCompositeTypeManager typeManager; - QMap<QString,QString> nameSpacePaths; mutable quint32 uniqueId; quint32 getUniqueId() const { diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index b15f711..e6c7376 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -423,8 +423,10 @@ int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Fun QmlMetaTypeData *data = metaTypeData(); QString name = QLatin1String(cname); + for (int ii = 0; ii < name.count(); ++ii) { - if (!name.at(ii).isLetterOrNumber()) { + QChar ch = name.at(ii); + if (!ch.isLetterOrNumber() && ch != QChar::fromLatin1('/')) { qWarning("QmlMetaType: Invalid QML name %s", cname); return -1; } diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index d1ad540..cf4691f 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -468,7 +468,6 @@ bool ProcessAST::visit(AST::UiImport *node) if (node->fileName) { import.type = QmlScriptParser::Import::File; uri = node->fileName->asString(); - _parser->addNamespacePath(uri); } else { import.type = QmlScriptParser::Import::Library; uri = asString(node->importUri); @@ -482,6 +481,9 @@ bool ProcessAST::visit(AST::UiImport *node) import.location = location(startLoc, endLoc); import.uri = uri; + // XXX not parsed yet... + import.version_major = 0; + import.version_minor = 0; _parser->_imports << import; @@ -852,11 +854,6 @@ bool QmlScriptParser::parse(const QByteArray &qmldata, const QUrl &url) return _errors.isEmpty(); } -QMap<QString,QString> QmlScriptParser::nameSpacePaths() const -{ - return _nameSpacePaths; -} - QStringList QmlScriptParser::types() const { return _typeNames; @@ -883,7 +880,6 @@ void QmlScriptParser::clear() root->release(); root = 0; } - _nameSpacePaths.clear(); _typeNames.clear(); _errors.clear(); @@ -912,9 +908,4 @@ void QmlScriptParser::setTree(Object *tree) root = tree; } -void QmlScriptParser::addNamespacePath(const QString &path) -{ - _nameSpacePaths.insertMulti(QString(), path); -} - QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h index 5e30914..065c1c0 100644 --- a/src/declarative/qml/qmlscriptparser_p.h +++ b/src/declarative/qml/qmlscriptparser_p.h @@ -72,13 +72,16 @@ public: class Import { public: - Import() : type(Library) {} + Import() : type(Library), version_major(0), version_minor(0) {} enum Type { Library, File }; Type type; QString uri; - QString as; + QString as; // prefix for qualification + int version_major; + int version_minor; + QmlParser::LocationSpan location; }; @@ -87,7 +90,6 @@ public: bool parse(const QByteArray &data, const QUrl &url = QUrl()); - QMap<QString,QString> nameSpacePaths() const; QStringList types() const; QmlParser::Object *tree() const; @@ -104,12 +106,9 @@ public: void setScriptFile(const QString &filename) {_scriptFile = filename; } QString scriptFile() const { return _scriptFile; } - void addNamespacePath(const QString &path); - // ### private: QList<QmlError> _errors; - QMap<QString,QString> _nameSpacePaths; QmlParser::Object *root; QList<Import> _imports; QStringList _typeNames; diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp index 07cc1d5..8d03804 100644 --- a/src/declarative/util/qmlscript.cpp +++ b/src/declarative/util/qmlscript.cpp @@ -148,9 +148,8 @@ void QmlScript::setSource(const QUrl &source) Q_D(QmlScript); if (d->url == source) return; - d->url = source; - Q_ASSERT(!source.isRelative()); - + d->url = qmlContext(this)->resolvedUrl(source); + #ifndef QT_NO_LOCALFILE_OPTIMIZED_QML if (d->url.scheme() == QLatin1String("file")) { QFile file(d->url.toLocalFile()); diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index 0b370fb..335c609 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -124,8 +124,6 @@ int main(int argc, char ** argv) usage(); translationFile = argv[i + 1]; ++i; - } else if (arg == "-L") { - libraries << QString(argv[++i]); } else if (arg[0] != '-') { fileName = arg; } else if (1 || arg == "-help") { @@ -140,8 +138,6 @@ int main(int argc, char ** argv) } QmlViewer viewer(testMode, testDir, 0, frameless ? Qt::FramelessWindowHint : Qt::Widget); - foreach (QString lib, libraries) - viewer.addLibraryPath(lib); viewer.setCacheEnabled(cache); viewer.setRecordFile(recordfile); if (period>0) diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index db0dc18..e212391 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -325,11 +325,6 @@ void QmlViewer::toggleRecording() setRecording(recording); } -void QmlViewer::addLibraryPath(const QString& lib) -{ - canvas->engine()->addNameSpacePath("",lib); -} - void QmlViewer::reload() { openQml(currentFileName); |