summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmldom.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2009-07-15 01:09:31 (GMT)
committerKai Koehne <kai.koehne@nokia.com>2009-07-15 02:02:32 (GMT)
commit68e47e91af6edca3c714cc3258b65dd88c0ee1e4 (patch)
tree914ff8bba8e702673a40e55411a47b74522e8016 /src/declarative/qml/qmldom.cpp
parentfa0159762ce65c99907dbcb68d1c10e1a126468f (diff)
downloadQt-68e47e91af6edca3c714cc3258b65dd88c0ee1e4.zip
Qt-68e47e91af6edca3c714cc3258b65dd88c0ee1e4.tar.gz
Qt-68e47e91af6edca3c714cc3258b65dd88c0ee1e4.tar.bz2
Expose qml import statements in QmlDom
Diffstat (limited to 'src/declarative/qml/qmldom.cpp')
-rw-r--r--src/declarative/qml/qmldom.cpp98
1 files changed, 94 insertions, 4 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