diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-07-15 03:38:20 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-07-15 03:38:20 (GMT) |
commit | 45cbfefe9d68152841beb6474c94eece0a085eb5 (patch) | |
tree | 6fc89f7c35182f0e2492bf61ec9d441f03bec6ec /src | |
parent | 8ea9cf839ed2bc5cd8a152fc6f10400e24242924 (diff) | |
parent | 68e47e91af6edca3c714cc3258b65dd88c0ee1e4 (diff) | |
download | Qt-45cbfefe9d68152841beb6474c94eece0a085eb5.zip Qt-45cbfefe9d68152841beb6474c94eece0a085eb5.tar.gz Qt-45cbfefe9d68152841beb6474c94eece0a085eb5.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/qmldom.cpp | 98 | ||||
-rw-r--r-- | src/declarative/qml/qmldom.h | 25 | ||||
-rw-r--r-- | src/declarative/qml/qmldom_p.h | 17 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 9 |
4 files changed, 138 insertions, 11 deletions
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 648eb36..e293a93 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -145,9 +145,9 @@ int QmlDomDocument::version() const } /*! - Return the URIs listed by "import <dir>" in the qml. + Returns all import statements in qml. */ -QList<QUrl> QmlDomDocument::imports() const +QList<QmlDomImport> QmlDomDocument::imports() const { return d->imports; } @@ -191,7 +191,13 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl } for (int i = 0; i < td->data.imports().size(); ++i) { - d->imports += QUrl(td->data.imports().at(i).uri); + QmlScriptParser::Import parserImport = td->data.imports().at(i); + QmlDomImport domImport; + domImport.d->type = static_cast<QmlDomImportPrivate::Type>(parserImport.type); + domImport.d->uri = parserImport.uri; + domImport.d->qualifier = parserImport.qualifier; + domImport.d->version = parserImport.version; + d->imports += domImport; } if (td->data.tree()) { @@ -207,7 +213,6 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl return true; } - /*! Returns the last load errors. The load errors will be reset after a successful call to load(). @@ -1767,4 +1772,89 @@ void QmlDomComponent::setComponentRoot(const QmlDomObject &root) qWarning("QmlDomComponent::setComponentRoot(const QmlDomObject &): Not implemented"); } + +QmlDomImportPrivate::QmlDomImportPrivate() +: type(File) +{ +} + +QmlDomImportPrivate::QmlDomImportPrivate(const QmlDomImportPrivate &other) +: QSharedData(other) +{ +} + +QmlDomImportPrivate::~QmlDomImportPrivate() +{ +} + +/*! + \class QmlDomImport + \internal + \brief The QmlDomImport class represents an import statement. +*/ + +/*! + Construct an empty QmlDomImport. +*/ +QmlDomImport::QmlDomImport() +: d(new QmlDomImportPrivate) +{ +} + +/*! + Create a copy of \a other QmlDomImport. +*/ +QmlDomImport::QmlDomImport(const QmlDomImport &other) +: d(other.d) +{ +} + +/*! + Destroy the QmlDomImport. +*/ +QmlDomImport::~QmlDomImport() +{ +} + +/*! + Assign \a other to this QmlDomImport. +*/ +QmlDomImport &QmlDomImport::operator=(const QmlDomImport &other) +{ + d = other.d; + return *this; +} + +/*! + Returns the type of the import. + */ +QmlDomImport::Type QmlDomImport::type() const +{ + return static_cast<QmlDomImport::Type>(d->type); +} + +/*! + Returns the URI of the import (e.g. 'subdir' or 'com.nokia.Qt') + */ +QString QmlDomImport::uri() const +{ + return d->uri; +} + +/*! + Returns the version specified by the import. An empty string if no version was specified. + */ +QString QmlDomImport::version() const +{ + return d->version; +} + +/*! + Returns the (optional) qualifier string (the token following the 'as' keyword) of the import. + */ +QString QmlDomImport::qualifier() const +{ + return d->qualifier; +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h index ef9fe25..456202a 100644 --- a/src/declarative/qml/qmldom.h +++ b/src/declarative/qml/qmldom.h @@ -59,9 +59,11 @@ class QmlDomList; class QmlDomValue; class QmlEngine; class QmlDomComponent; +class QmlDomImport; class QIODevice; class QmlDomDocumentPrivate; + class Q_DECLARATIVE_EXPORT QmlDomDocument { public: @@ -71,7 +73,7 @@ public: QmlDomDocument &operator=(const QmlDomDocument &); int version() const; - QList<QUrl> imports() const; + QList<QmlDomImport> imports() const; QList<QmlError> errors() const; bool load(QmlEngine *, const QByteArray &, const QUrl & = QUrl()); @@ -304,6 +306,27 @@ private: QSharedDataPointer<QmlDomValuePrivate> d; }; +class QmlDomImportPrivate; +class Q_DECLARATIVE_EXPORT QmlDomImport +{ +public: + enum Type { Library, File }; + + QmlDomImport(); + QmlDomImport(const QmlDomImport &); + ~QmlDomImport(); + QmlDomImport &operator=(const QmlDomImport &); + + Type type() const; + QString uri() const; + QString version() const; + QString qualifier() const; + +private: + friend class QmlDomDocument; + QSharedDataPointer<QmlDomImportPrivate> d; +}; + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h index 5345c44..b15844a 100644 --- a/src/declarative/qml/qmldom_p.h +++ b/src/declarative/qml/qmldom_p.h @@ -66,7 +66,7 @@ public: ~QmlDomDocumentPrivate(); QList<QmlError> errors; - QList<QUrl> imports; + QList<QmlDomImport> imports; QmlParser::Object *root; QList<int> automaticSemicolonOffsets; }; @@ -129,6 +129,21 @@ public: QmlParser::Value *value; }; +class QmlDomImportPrivate : public QSharedData +{ +public: + QmlDomImportPrivate(); + QmlDomImportPrivate(const QmlDomImportPrivate &); + ~QmlDomImportPrivate(); + + enum Type { Library, File }; + + Type type; + QString uri; + QString version; + QString qualifier; +}; + QT_END_NAMESPACE #endif // QMLDOM_P_H diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index b0369e3..46c8b30 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -1155,7 +1155,7 @@ public: return true; } - QUrl find(const QString& base, const QString& type) + QUrl find(const QUrl& base, const QString& type) { TypeSet *s = 0; int slash = type.indexOf(QLatin1Char('/')); @@ -1172,10 +1172,9 @@ public: s = &unqualifiedset; } QString unqualifiedtype = type.mid(slash+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"))); + QUrl url = base.resolved(QUrl(s->urls.at(i) +QLatin1String("/")+ unqualifiedtype + QLatin1String(".qml"))); QString version = s->versions.at(i); // XXX search non-files too! (eg. zip files, see QT-524) QFileInfo f(url.toLocalFile()); @@ -1209,10 +1208,10 @@ public: } } } - return baseUrl.resolved(QUrl(type + QLatin1String(".qml"))); + return base.resolved(QUrl(type + QLatin1String(".qml"))); } - QmlType *findBuiltin(const QString&, const QByteArray& type) + QmlType *findBuiltin(const QUrl& base, const QByteArray& type) { TypeSet *s = 0; int slash = type.indexOf('/'); |