summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-06-25 07:07:10 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-06-25 07:07:10 (GMT)
commit4b3933bc4d6c5e2ae4507e5df92c6f877e3f621e (patch)
treeaf9761cf776b4954deb9d1fdfa82a74e0711be51
parent9f020f8a737ee27cf5b7ce4a41e579a6872d9954 (diff)
downloadQt-4b3933bc4d6c5e2ae4507e5df92c6f877e3f621e.zip
Qt-4b3933bc4d6c5e2ae4507e5df92c6f877e3f621e.tar.gz
Qt-4b3933bc4d6c5e2ae4507e5df92c6f877e3f621e.tar.bz2
Expose extended type URLs through the QML DOM API
-rw-r--r--src/declarative/qml/qmlcompiler.cpp5
-rw-r--r--src/declarative/qml/qmlcomponent.cpp1
-rw-r--r--src/declarative/qml/qmldom.cpp10
-rw-r--r--src/declarative/qml/qmldom.h1
-rw-r--r--src/declarative/qml/qmlparser_p.h2
5 files changed, 18 insertions, 1 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 8297ac4..cb0c571 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -570,7 +570,10 @@ void QmlCompiler::compileTree(Object *tree)
bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt)
{
Q_ASSERT (obj->type != -1);
- obj->metatype = output->types.at(obj->type).metaObject();
+ const QmlCompiledData::TypeReference &tr = output->types.at(obj->type);
+ obj->metatype = tr.metaObject();
+ if (tr.component)
+ obj->url = tr.component->url();
if (output->types.at(obj->type).className == "Component") {
COMPILE_CHECK(compileComponent(obj, ctxt));
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index f90af4a..3429813 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -296,6 +296,7 @@ QmlComponent::QmlComponent(QmlEngine *engine, QmlCompiledComponent *cc, int star
cc->addref();
d->start = start;
d->count = count;
+ d->url = cc->url;
}
/*!
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index d2608c8..42b40b6 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -791,6 +791,16 @@ int QmlDomObject::length() const
return 0;
}
+// Returns the URL of the type, if it is an external type, or an empty URL if
+// not
+QUrl QmlDomObject::url() const
+{
+ if (d && d->object)
+ return d->object->url;
+ else
+ return QUrl();
+}
+
QmlDomBasicValuePrivate::QmlDomBasicValuePrivate()
: value(0)
{
diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h
index fde35a8..ab3e39f 100644
--- a/src/declarative/qml/qmldom.h
+++ b/src/declarative/qml/qmldom.h
@@ -143,6 +143,7 @@ public:
int position() const;
int length() const;
+ QUrl url() const;
private:
friend class QmlDomDocument;
friend class QmlDomComponent;
diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h
index a38ce69..78040da 100644
--- a/src/declarative/qml/qmlparser_p.h
+++ b/src/declarative/qml/qmlparser_p.h
@@ -102,6 +102,8 @@ namespace QmlParser
// QmlCompiledData::types array, or -1 if the object is a fetched
// object.
int type;
+ // The url of this object if it is an external type. Used by the DOM
+ QUrl url;
// The name of this type
QByteArray typeName;
// The id assigned to the object (if any).