summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlcomponent.cpp
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-10-30 05:24:51 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-10-30 05:24:51 (GMT)
commit46eec6d54bad7a686b3dd5cd6e4aa8577d38740d (patch)
treee4c828d1d1456b3fafe74a339562263b3f2c156d /src/declarative/qml/qmlcomponent.cpp
parentd85d7addc5084ee7d5de31dec562437f9c31c35d (diff)
parentd788c0127b86d8245aa0a8e2472562f444d98ee9 (diff)
downloadQt-46eec6d54bad7a686b3dd5cd6e4aa8577d38740d.zip
Qt-46eec6d54bad7a686b3dd5cd6e4aa8577d38740d.tar.gz
Qt-46eec6d54bad7a686b3dd5cd6e4aa8577d38740d.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts: src/declarative/qml/qmlcomponentjs.cpp src/declarative/qml/qmlcomponentjs_p.h src/declarative/qml/qmlcomponentjs_p_p.h
Diffstat (limited to 'src/declarative/qml/qmlcomponent.cpp')
-rw-r--r--src/declarative/qml/qmlcomponent.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index 65af9a5..63f3cfb 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -409,6 +409,9 @@ valid for components created directly from QML.
*/
QmlContext *QmlComponent::creationContext() const
{
+ Q_D(const QmlComponent);
+ if(d->creationContext)
+ return d->creationContext;
QmlDeclarativeData *ddata = QmlDeclarativeData::get(this);
if (ddata)
return ddata->context;
@@ -417,6 +420,17 @@ QmlContext *QmlComponent::creationContext() const
}
/*!
+ \internal
+ Sets the QmlContext the component was created in. This is only
+ desirable for components created in QML script.
+*/
+void QmlComponent::setCreationContext(QmlContext* c)
+{
+ Q_D(QmlComponent);
+ d->creationContext = c;
+}
+
+/*!
Load the QmlComponent from the provided \a url.
*/
void QmlComponent::loadUrl(const QUrl &url)
@@ -462,6 +476,24 @@ QList<QmlError> QmlComponent::errors() const
}
/*!
+ \internal
+ errorsString is only meant as a way to get the errors in script
+*/
+QString QmlComponent::errorsString() const
+{
+ Q_D(const QmlComponent);
+ QString ret;
+ if(!isError())
+ return ret;
+ foreach(const QmlError &e, d->errors) {
+ ret += e.url().toString() + QLatin1String(":") +
+ QString::number(e.line()) + QLatin1String(" ") +
+ e.description() + QLatin1String("\n");
+ }
+ return ret;
+}
+
+/*!
Return the component URL. This is the URL passed to either the constructor,
or the loadUrl() or setData() methods.
*/
@@ -481,6 +513,22 @@ QmlComponent::QmlComponent(QmlComponentPrivate &dd, QObject *parent)
/*!
+ \internal
+ A version of create which returns a scriptObject, for use in script
+*/
+QScriptValue QmlComponent::createObject()
+{
+ Q_D(QmlComponent);
+ QmlContext* ctxt = creationContext();
+ if(!ctxt){
+ qWarning() << QLatin1String("createObject can only be used in QML");
+ return QScriptValue();
+ }
+ QObject* ret = create(ctxt);
+ return QmlEnginePrivate::qmlScriptObject(ret, d->engine);
+}
+
+/*!
Create an object instance from this component. Returns 0 if creation
failed. \a context specifies the context within which to create the object
instance.