summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlengine.cpp
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-10-29 03:52:36 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-10-29 04:06:09 (GMT)
commit220eea1b5a978cf62e27878e7d9b2e1f4d10e91e (patch)
tree0cdb8ba932cedd3b2f0f1b45b92c4c095a36862c /src/declarative/qml/qmlengine.cpp
parentbfbded95056d43a65b2c9ef1fa90bfd40adc6472 (diff)
downloadQt-220eea1b5a978cf62e27878e7d9b2e1f4d10e91e.zip
Qt-220eea1b5a978cf62e27878e7d9b2e1f4d10e91e.tar.gz
Qt-220eea1b5a978cf62e27878e7d9b2e1f4d10e91e.tar.bz2
Merge QmlComponentJS into QmlComponent
createComponent() and Component{} are now the same, and so Component{}s can now be passed around for use in script. Also this commit fixes the minor bug QT-2386
Diffstat (limited to 'src/declarative/qml/qmlengine.cpp')
-rw-r--r--src/declarative/qml/qmlengine.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 3da8aa9..84186d4 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -75,8 +75,8 @@
#include <QtGui/qcolor.h>
#include <QtGui/qvector3d.h>
#include <QtGui/qsound.h>
+#include <QGraphicsObject>
#include <qmlcomponent.h>
-#include <private/qmlcomponentjs_p.h>
#include <private/qmlmetaproperty_p.h>
#include <private/qmlbinding_p.h>
#include <private/qmlvme_p.h>
@@ -651,7 +651,7 @@ QmlContext *QmlEnginePrivate::getContext(QScriptContext *ctxt)
QScriptValue QmlEnginePrivate::createComponent(QScriptContext *ctxt,
QScriptEngine *engine)
{
- QmlComponentJS* c;
+ QmlComponent* c;
QmlEnginePrivate *activeEnginePriv =
static_cast<QmlScriptEngine*>(engine)->p;
@@ -659,14 +659,14 @@ QScriptValue QmlEnginePrivate::createComponent(QScriptContext *ctxt,
QmlContext* context = activeEnginePriv->getContext(ctxt);
if(ctxt->argumentCount() != 1) {
- c = new QmlComponentJS(activeEngine);
+ c = new QmlComponent(activeEngine);
}else{
QUrl url = QUrl(context->resolvedUrl(ctxt->argument(0).toString()));
if(!url.isValid())
url = QUrl(ctxt->argument(0).toString());
- c = new QmlComponentJS(activeEngine, url, activeEngine);
+ c = new QmlComponent(activeEngine, url, activeEngine);
}
- c->setContext(context);
+ c->setCreationContext(context);
return engine->newQObject(c);
}
@@ -708,8 +708,6 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi
QUrl url;
if(ctxt->argumentCount() > 2)
url = QUrl(ctxt->argument(2).toString());
- else
- url = QUrl(QLatin1String("DynamicQML"));
QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1));
QmlContext *qmlCtxt = qmlContext(parentArg);
if (url.isEmpty()) {
@@ -719,6 +717,7 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi
}
QmlComponent component(activeEngine, qml.toUtf8(), url);
+
if(component.isError()) {
QList<QmlError> errors = component.errors();
qWarning() <<"QmlEngine::createQmlObject():";
@@ -741,7 +740,10 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi
if(obj) {
obj->setParent(parentArg);
- obj->setProperty("parent", QVariant::fromValue<QObject*>(parentArg));
+ QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(obj);
+ QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parentArg);
+ if(gobj && gparent)
+ gobj->setParentItem(gparent);
return qmlScriptObject(obj, activeEngine);
}
return engine->nullValue();