summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlvme.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-06-21 23:16:08 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-06-21 23:16:08 (GMT)
commit511d86e88b33380116f27d5f6a2a0754e8f62fa0 (patch)
tree6fdcb11b5270984112bc2563738c24d2891595d4 /src/declarative/qml/qmlvme.cpp
parentaae3c899b10bee2dd64bb00bb2832620a47cff87 (diff)
parentfbf9db1fc6b500bfe05fdfca121986687d73d5c6 (diff)
downloadQt-511d86e88b33380116f27d5f6a2a0754e8f62fa0.zip
Qt-511d86e88b33380116f27d5f6a2a0754e8f62fa0.tar.gz
Qt-511d86e88b33380116f27d5f6a2a0754e8f62fa0.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml/qmlvme.cpp')
-rw-r--r--src/declarative/qml/qmlvme.cpp69
1 files changed, 57 insertions, 12 deletions
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 3a66c69..a3ee4e5 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -44,6 +44,7 @@
#include <private/qmlboundsignal_p.h>
#include <private/qmlstringconverters_p.h>
#include "private/qmetaobjectbuilder_p.h"
+#include "private/qmldeclarativedata_p.h"
#include <qml.h>
#include <private/qmlcustomparser_p.h>
#include <qperformancelog.h>
@@ -88,16 +89,11 @@ QmlVME::QmlVME()
struct ListInstance
{
ListInstance() {}
- /*
- ListInstance(const QVariant &l, int t)
- : list(l), type(t), qmlListInterface(0) {}
- */
ListInstance(QList<void *> *q, int t)
- : type(t), qListInterface(q) {}
+ : type(t), qListInterface(q), qmlListInterface(0) {}
ListInstance(QmlPrivate::ListInterface *q, int t)
- : type(t), qmlListInterface(q) {}
+ : type(t), qListInterface(0), qmlListInterface(q) {}
- //QVariant list;
int type;
QList<void *> *qListInterface;
QmlPrivate::ListInterface *qmlListInterface;
@@ -105,6 +101,35 @@ struct ListInstance
QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, int count)
{
+ QStack<QObject *> stack;
+
+ if (start == -1) start = 0;
+ if (count == -1) count = comp->bytecode.count();
+
+ return run(stack, ctxt, comp, start, count);
+}
+
+void QmlVME::runDeferred(QObject *object)
+{
+ QmlInstanceDeclarativeData *data = QmlInstanceDeclarativeData::get(object);
+
+ if (!data || !data->context || !data->deferredComponent)
+ return;
+
+ QmlContext *ctxt = data->context;
+ ctxt->activate();
+ QmlCompiledComponent *comp = data->deferredComponent;
+ int start = data->deferredIdx + 1;
+ int count = data->deferredComponent->bytecode.at(data->deferredIdx).defer.deferCount;
+ QStack<QObject *> stack;
+ stack.push(object);
+
+ run(stack, ctxt, comp, start, count);
+ ctxt->deactivate();
+}
+
+QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComponent *comp, int start, int count)
+{
// XXX - All instances of QmlContext::activeContext() here should be
// replaced with the use of ctxt. However, this cannot be done until
// behaviours stop modifying the active context and expecting the
@@ -125,7 +150,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
QmlEnginePrivate::SimpleList<QmlBindableValue> bindValues;
QmlEnginePrivate::SimpleList<QmlParserStatus> parserStatus;
- QStack<QObject *> stack;
QStack<ListInstance> qliststack;
QStack<QmlMetaProperty> pushedProperties;
@@ -133,9 +157,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
vmeErrors.clear();
- if (start == -1) start = 0;
- if (count == -1) count = comp->bytecode.count();
-
for (int ii = start; !isError() && ii < (start + count); ++ii) {
QmlInstruction &instr = comp->bytecode[ii];
@@ -172,7 +193,17 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
}
if (!stack.isEmpty()) {
QObject *parent = stack.top();
- o->setParent(parent);
+ if (o->isWidgetType()) {
+ QWidget *widget = static_cast<QWidget*>(o);
+ if (parent->isWidgetType()) {
+ QWidget *parentWidget = static_cast<QWidget*>(parent);
+ widget->setParent(parentWidget);
+ } else {
+ // TODO: parent might be a layout
+ }
+ } else {
+ o->setParent(parent);
+ }
}
stack.push(o);
}
@@ -745,6 +776,20 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
}
break;
+ case QmlInstruction::Defer:
+ {
+ if (instr.defer.deferCount) {
+ QObject *target = stack.top();
+ QmlInstanceDeclarativeData *data =
+ QmlInstanceDeclarativeData::get(target, true);
+ comp->addref();
+ data->deferredComponent = comp;
+ data->deferredIdx = ii;
+ ii += instr.defer.deferCount;
+ }
+ }
+ break;
+
case QmlInstruction::PopFetchedObject:
{
stack.pop();