diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-05-14 06:08:33 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-05-14 06:08:33 (GMT) |
commit | 0a27e429eed494a39d3bbb8cf67c50be035329bb (patch) | |
tree | 38f926a1c16667b1c19f3e858c342f33b296634f /src/declarative | |
parent | b7f710a79b3d5f529dde8ad43ee4e0b78100674f (diff) | |
parent | 3de4816d054b92a9dbac3c7830b52ca66fa052e3 (diff) | |
download | Qt-0a27e429eed494a39d3bbb8cf67c50be035329bb.zip Qt-0a27e429eed494a39d3bbb8cf67c50be035329bb.tar.gz Qt-0a27e429eed494a39d3bbb8cf67c50be035329bb.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/declarative.pro | 1 | ||||
-rw-r--r-- | src/declarative/fx/qfxgridview.cpp | 17 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 83 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler_p.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlinstruction.cpp | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlinstruction_p.h | 7 | ||||
-rw-r--r-- | src/declarative/qml/qmlvme.cpp | 33 |
7 files changed, 70 insertions, 75 deletions
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro index e960f0f..0c51fc3 100644 --- a/src/declarative/declarative.pro +++ b/src/declarative/declarative.pro @@ -10,6 +10,7 @@ solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2 unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtXml # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage +# LIBS += -lgcov include(../qbase.pri) diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 0f848d6..876172d 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -409,7 +409,8 @@ void QFxGridViewPrivate::refill(qreal from, qreal to) FxGridItem *item = 0; while (modelIndex < model->count() && rowPos <= to) { //qDebug() << "refill: append item" << modelIndex; - item = getItem(modelIndex); + if (!(item = getItem(modelIndex))) + break; item->setPosition(colPos, rowPos); visibleItems.append(item); colPos += colSize(); @@ -431,7 +432,8 @@ void QFxGridViewPrivate::refill(qreal from, qreal to) } while (visibleIndex > 0 && rowPos + rowSize() - 1 >= from){ //qDebug() << "refill: prepend item" << visibleIndex-1 << "top pos" << rowPos << colPos; - item = getItem(visibleIndex-1); + if (!(item = getItem(visibleIndex-1))) + break; --visibleIndex; item->setPosition(colPos, rowPos); visibleItems.prepend(item); @@ -629,14 +631,17 @@ void QFxGridViewPrivate::updateCurrent(int modelIndex) currentItem = visibleItem(modelIndex); if (!currentItem) { currentItem = getItem(modelIndex); - currentItem->setPosition(colPosAt(modelIndex), rowPosAt(modelIndex)); + if (currentItem) + currentItem->setPosition(colPosAt(modelIndex), rowPosAt(modelIndex)); } currentIndex = modelIndex; fixCurrentVisibility = true; - if (oldCurrentItem && oldCurrentItem->item != currentItem->item) + if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item)) oldCurrentItem->attached->setIsCurrentItem(false); - currentItem->item->setFocus(true); - currentItem->attached->setIsCurrentItem(true); + if (currentItem) { + currentItem->item->setFocus(true); + currentItem->attached->setIsCurrentItem(true); + } updateHighlight(); emit q->currentIndexChanged(); // Release the old current item diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index ed520c1..b205efb 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -725,51 +725,82 @@ bool QmlCompiler::compileFetchedObject(Object *obj, int ctxt) return true; } +int QmlCompiler::signalByName(const QMetaObject *mo, const QByteArray &name) +{ + int methods = mo->methodCount(); + for (int ii = methods - 1; ii >= 0; --ii) { + QMetaMethod method = mo->method(ii); + QByteArray methodName = method.signature(); + int idx = methodName.indexOf('('); + methodName = methodName.left(idx); + + if (methodName == name) + return ii; + } + return -1; +} + bool QmlCompiler::compileSignal(Property *prop, Object *obj) { + Q_ASSERT(obj->metaObject()); + if (prop->values.isEmpty() && !prop->value) return true; if (prop->value || prop->values.count() > 1) COMPILE_EXCEPTION("Incorrectly specified signal"); - if (prop->values.at(0)->object) { - int pr = output->indexForByteArray(prop->name); + QByteArray name = prop->name; + Q_ASSERT(name.startsWith("on")); + name = name.mid(2); + if(name[0] >= 'A' && name[0] <= 'Z') + name[0] = name[0] - 'A' + 'a'; - bool rv = compileObject(prop->values.at(0)->object, 0); + int sigIdx = signalByName(obj->metaObject(), name); - if (rv) { - QmlInstruction assign; - assign.type = QmlInstruction::AssignSignalObject; - assign.line = prop->values.at(0)->location.start.line; - assign.assignSignalObject.signal = pr; + if (sigIdx == -1) { - output->bytecode << assign; + COMPILE_CHECK(compileProperty(prop, obj, 0)); - prop->values.at(0)->type = Value::SignalObject; - } + } else { - return rv; + if (prop->values.at(0)->object) { + int pr = output->indexForByteArray(prop->name); - } else { - QString script = prop->values.at(0)->value.asScript().trimmed(); - if (script.isEmpty()) - return true; + bool rv = compileObject(prop->values.at(0)->object, 0); + + if (rv) { + QmlInstruction assign; + assign.type = QmlInstruction::AssignSignalObject; + assign.line = prop->values.at(0)->location.start.line; + assign.assignSignalObject.signal = pr; - int idx = output->indexForString(script); - int pr = output->indexForByteArray(prop->name); + output->bytecode << assign; - QmlInstruction assign; - assign.type = QmlInstruction::AssignSignal; - assign.line = prop->values.at(0)->location.start.line; - assign.assignSignal.signal = pr; - assign.assignSignal.value = idx; + prop->values.at(0)->type = Value::SignalObject; + } - output->bytecode << assign; + return rv; - prop->values.at(0)->type = Value::SignalExpression; - } + } else { + QString script = prop->values.at(0)->value.asScript().trimmed(); + if (script.isEmpty()) + return true; + int idx = output->indexForString(script); + + QmlInstruction store; + store.line = prop->values.at(0)->location.start.line; + store.type = QmlInstruction::StoreSignal; + store.storeSignal.signalIndex = sigIdx; + store.storeSignal.value = idx; + + output->bytecode << store; + + prop->values.at(0)->type = Value::SignalExpression; + } + } + return true; } diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index 246dd70..64400c5 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -139,6 +139,7 @@ private: bool compileFetchedObject(QmlParser::Object *obj, int); bool compileSignal(QmlParser::Property *prop, QmlParser::Object *obj); bool testProperty(QmlParser::Property *prop, QmlParser::Object *obj); + int signalByName(const QMetaObject *, const QByteArray &name); bool compileProperty(QmlParser::Property *prop, QmlParser::Object *obj, int); bool compileIdProperty(QmlParser::Property *prop, QmlParser::Object *obj); diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp index 0617913..6b49359 100644 --- a/src/declarative/qml/qmlinstruction.cpp +++ b/src/declarative/qml/qmlinstruction.cpp @@ -127,9 +127,6 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx) case QmlInstruction::AssignConstant: qWarning() << idx << "\t" << line << "\t" << "ASSIGN_CONSTANT\t" << instr->assignConstant.property << "\t" << instr->assignConstant.constant << "\t\t" << datas.at(instr->assignConstant.property) << primitives.at(instr->assignConstant.constant); break; - case QmlInstruction::AssignSignal: - qWarning() << idx << "\t" << line << "\t" << "ASSIGN_SIGNAL\t\t" << instr->assignSignal.signal << "\t" << instr->assignSignal.value << "\t\t" << datas.at(instr->assignSignal.signal) << primitives.at(instr->assignSignal.value); - break; case QmlInstruction::AssignSignalObject: qWarning() << idx << "\t" << line << "\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal << "\t\t\t" << datas.at(instr->assignSignalObject.signal); break; diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index f465e9f..f06f0e6 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -112,10 +112,7 @@ public: // // AssignConstant - Store a value in a property. Will resolve into // a Store* instruction. - // AssignSignal - Set a signal handler on the property. Will resolve - // into a Store*Signal instruction. AssignConstant, /* assignConstant */ - AssignSignal, /* assignSignal */ AssignSignalObject, /* assignSignalObject */ AssignCustomType, /* assignCustomType */ @@ -273,10 +270,6 @@ public: } storeSignal; struct { int signal; - int value; - } assignSignal; - struct { - int signal; } assignSignalObject; struct { int count; diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index dc9ef06..51534e7 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -88,7 +88,6 @@ Q_DECLARE_PERFORMANCE_LOG(QFxCompiler) { Q_DECLARE_PERFORMANCE_METRIC(InstrStoreSignal); Q_DECLARE_PERFORMANCE_METRIC(InstrStoreObjectQmlList); Q_DECLARE_PERFORMANCE_METRIC(InstrAssignConstant); - Q_DECLARE_PERFORMANCE_METRIC(InstrAssignSignal); Q_DECLARE_PERFORMANCE_METRIC(InstrAssignSignalObject); Q_DECLARE_PERFORMANCE_METRIC(InstrAssignBinding); Q_DECLARE_PERFORMANCE_METRIC(InstrAssignCompiledBinding); @@ -138,7 +137,6 @@ Q_DEFINE_PERFORMANCE_LOG(QFxCompiler, "QFxCompiler") { Q_DEFINE_PERFORMANCE_METRIC(InstrStoreSignal, "StoreSignal"); Q_DEFINE_PERFORMANCE_METRIC(InstrStoreObjectQmlList, "StoreObjectQmlList"); Q_DEFINE_PERFORMANCE_METRIC(InstrAssignConstant, "AssignConstant"); - Q_DEFINE_PERFORMANCE_METRIC(InstrAssignSignal, "AssignSignal"); Q_DEFINE_PERFORMANCE_METRIC(InstrAssignSignalObject, "AssignSignalObject"); Q_DEFINE_PERFORMANCE_METRIC(InstrAssignBinding, "AssignBinding"); Q_DEFINE_PERFORMANCE_METRIC(InstrAssignCompiledBinding, "AssignCompiledBinding"); @@ -356,37 +354,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in } break; - case QmlInstruction::AssignSignal: - { -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxCompilerTimer<QFxCompiler::InstrAssignSignal> cc; -#endif - // Fixup instruction - QObject *target = stack.top(); - int sigIdx = instr.assignSignal.signal; - const QByteArray &pr = datas.at(sigIdx); - - QmlMetaProperty prop(target, QLatin1String(pr)); - if (prop.type() & QmlMetaProperty::SignalProperty) { - int coreIdx = prop.coreIndex(); - int primRef = instr.assignSignal.value; - instr.type = QmlInstruction::StoreSignal; - instr.storeSignal.signalIndex = coreIdx; - instr.storeSignal.value = primRef; - --ii; - } else if (prop.type() & QmlMetaProperty::Property) { - int prop = sigIdx; - int primRef = instr.assignSignal.value; - instr.type = QmlInstruction::AssignConstant; - instr.assignConstant.property = prop; - instr.assignConstant.constant = primRef; - --ii; - } else { - VME_EXCEPTION("Cannot assign a signal to property" << pr); - } - } - break; - case QmlInstruction::AssignSignalObject: { #ifdef Q_ENABLE_PERFORMANCE_LOG |