diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-04-08 03:12:01 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-04-08 03:12:01 (GMT) |
commit | b6aa652b96922dc0faa291879441f8746d8f8a39 (patch) | |
tree | bbfc139d7035d25e58ca6966dfee23660111c50f | |
parent | ccb6235ae842b7e63997210e5169cc00f4e0e5e8 (diff) | |
parent | dcce90c4d9c8d010d7fc45c33048ff00e468b89c (diff) | |
download | Qt-b6aa652b96922dc0faa291879441f8746d8f8a39.zip Qt-b6aa652b96922dc0faa291879441f8746d8f8a39.tar.gz Qt-b6aa652b96922dc0faa291879441f8746d8f8a39.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
9 files changed, 89 insertions, 55 deletions
diff --git a/src/declarative/3rdparty/qlistmodelinterface.cpp b/src/declarative/3rdparty/qlistmodelinterface.cpp index 20501a0..98d6a5b 100644 --- a/src/declarative/3rdparty/qlistmodelinterface.cpp +++ b/src/declarative/3rdparty/qlistmodelinterface.cpp @@ -106,10 +106,4 @@ QT_BEGIN_NAMESPACE \a roles changed. */ -/*! \fn void QListModelInterface::modelReset() - Emit this signal when all of the model data has changed. - This is more efficient than forcing the receivier to handle multiple - inserted and removed signals etc. -*/ - QT_END_NAMESPACE diff --git a/src/declarative/3rdparty/qlistmodelinterface_p.h b/src/declarative/3rdparty/qlistmodelinterface_p.h index da91d12..07592ad 100644 --- a/src/declarative/3rdparty/qlistmodelinterface_p.h +++ b/src/declarative/3rdparty/qlistmodelinterface_p.h @@ -72,7 +72,6 @@ class Q_DECLARATIVE_EXPORT QListModelInterface : public QObject void itemsRemoved(int index, int count); void itemsMoved(int from, int to, int count); void itemsChanged(int index, int count, const QList<int> &roles); - void modelReset(); protected: QListModelInterface(QObjectPrivate &dd, QObject *parent) diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 174459b..dfd9c0c 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -662,7 +662,6 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) this, SLOT(_q_itemsRemoved(int,int))); QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsMoved(int,int,int)), this, SLOT(_q_itemsMoved(int,int,int))); - QObject::disconnect(d->m_listModelInterface, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); d->m_listModelInterface = 0; } else if (d->m_abstractItemModel) { QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsInserted(const QModelIndex &,int,int)), @@ -706,7 +705,6 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) this, SLOT(_q_itemsRemoved(int,int))); QObject::connect(d->m_listModelInterface, SIGNAL(itemsMoved(int,int,int)), this, SLOT(_q_itemsMoved(int,int,int))); - QObject::connect(d->m_listModelInterface, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); d->m_metaDataCacheable = true; if (d->m_delegate && d->m_listModelInterface->count()) emit itemsInserted(0, d->m_listModelInterface->count()); diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp index 53143d5..07b0798 100644 --- a/src/declarative/qml/qdeclarativecompiledbindings.cpp +++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp @@ -137,7 +137,7 @@ public: Subscription *subscriptions; QScriptDeclarativeClass::PersistentIdentifier *identifiers; - void run(Binding *); + void run(Binding *, QDeclarativePropertyPrivate::WriteFlags flags); const char *programData; Binding *m_bindings; @@ -147,7 +147,7 @@ public: void init(); void run(int instr, QDeclarativeContextData *context, - QDeclarativeDelayedError *error, QObject *scope, QObject *output); + QDeclarativeDelayedError *error, QObject *scope, QObject *output, QDeclarativePropertyPrivate::WriteFlags storeFlags); inline void unsubscribe(int subIndex); @@ -246,9 +246,9 @@ int QDeclarativeCompiledBindingsPrivate::Binding::propertyIndex() return property & 0xFFFF; } -void QDeclarativeCompiledBindingsPrivate::Binding::update(QDeclarativePropertyPrivate::WriteFlags) +void QDeclarativeCompiledBindingsPrivate::Binding::update(QDeclarativePropertyPrivate::WriteFlags flags) { - parent->run(this); + parent->run(this, flags); } void QDeclarativeCompiledBindingsPrivate::Binding::destroy() @@ -270,13 +270,13 @@ int QDeclarativeCompiledBindings::qt_metacall(QMetaObject::Call c, int id, void quint32 count = *reeval; ++reeval; for (quint32 ii = 0; ii < count; ++ii) { - d->run(d->m_bindings + reeval[ii]); + d->run(d->m_bindings + reeval[ii], QDeclarativePropertyPrivate::DontRemoveBinding); } } return -1; } -void QDeclarativeCompiledBindingsPrivate::run(Binding *binding) +void QDeclarativeCompiledBindingsPrivate::run(Binding *binding, QDeclarativePropertyPrivate::WriteFlags flags) { Q_Q(QDeclarativeCompiledBindings); @@ -319,12 +319,11 @@ void QDeclarativeCompiledBindingsPrivate::run(Binding *binding) vt->read(binding->target, binding->property & 0xFFFF); QObject *target = vt; - run(binding->index, context, binding, binding->scope, target); + run(binding->index, context, binding, binding->scope, target, flags); - vt->write(binding->target, binding->property & 0xFFFF, - QDeclarativePropertyPrivate::DontRemoveBinding); + vt->write(binding->target, binding->property & 0xFFFF, flags); } else { - run(binding->index, context, binding, binding->scope, binding->target); + run(binding->index, context, binding, binding->scope, binding->target, flags); } binding->updating = false; } @@ -1085,14 +1084,13 @@ static void dumpInstruction(const Instr *instr) void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, QDeclarativeContextData *context, QDeclarativeDelayedError *error, - QObject *scope, QObject *output) + QObject *scope, QObject *output, QDeclarativePropertyPrivate::WriteFlags storeFlags) { Q_Q(QDeclarativeCompiledBindings); error->removeError(); Register registers[32]; - int storeFlags = 0; QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(context->engine); Program *program = (Program *)programData; diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 11c7305..b33af06 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -878,22 +878,21 @@ void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult & } } if (!hasKeys) { - if (!(origCount == 0 && d->size == 0)) - emit modelReset(); + if (!(origCount == 0 && d->size == 0)) { + emit itemsRemoved(0, origCount); + emit itemsInserted(0, d->size); + emit countChanged(); + } } else { - if (result.removed.count() == 1 && result.removed[0].first == 0 - && result.removed[0].second == origCount) { - emit modelReset(); - } else { - for (int i=0; i<result.removed.count(); i++) - emit itemsRemoved(result.removed[i].first, result.removed[i].second); - for (int i=0; i<result.inserted.count(); i++) - emit itemsInserted(result.inserted[i].first, result.inserted[i].second); - if (sizeChanged) - emit countChanged(); - } + for (int i=0; i<result.removed.count(); i++) + emit itemsRemoved(result.removed[i].first, result.removed[i].second); + for (int i=0; i<result.inserted.count(); i++) + emit itemsInserted(result.inserted[i].first, result.inserted[i].second); + + if (sizeChanged) + emit countChanged(); } emit statusChanged(d->status); diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h index fd410a7..7b85476 100644 --- a/src/declarative/util/qdeclarativexmllistmodel_p.h +++ b/src/declarative/util/qdeclarativexmllistmodel_p.h @@ -124,7 +124,6 @@ Q_SIGNALS: void xmlChanged(); void queryChanged(); void namespaceDeclarationsChanged(); - void modelReset(); public Q_SLOTS: // ### need to use/expose Expiry to guess when to call this? diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml b/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml new file mode 100644 index 0000000..f3ff620 --- /dev/null +++ b/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml @@ -0,0 +1,17 @@ +import Qt 4.7 + +Rectangle { + width: 400 + height: 400 + + Rectangle { + objectName: "innerRect" + height: 100; width: 100; color: "green" + property real targetX: 100 + + x: targetX + Behavior on x { + NumberAnimation {} + } + } +} diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 26c8231..4c9c9ca 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -68,6 +68,7 @@ private slots: void reassignedAnimation(); void disabled(); void dontStart(); + void startup(); }; void tst_qdeclarativebehaviors::simpleBehavior() @@ -326,6 +327,21 @@ void tst_qdeclarativebehaviors::dontStart() delete rect; } +void tst_qdeclarativebehaviors::startup() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml")); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect); + + QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect"); + QVERIFY(innerRect); + + QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately + + delete rect; +} + QTEST_MAIN(tst_qdeclarativebehaviors) #include "tst_qdeclarativebehaviors.moc" diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index ba0f9a7..74da79e 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -378,16 +378,17 @@ void tst_qdeclarativexmllistmodel::reload() QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); QSignalSpy spyCount(model, SIGNAL(countChanged())); - QSignalSpy spyReset(model, SIGNAL(modelReset())); model->reload(); - QTRY_COMPARE(spyReset.count(), 1); - QCOMPARE(spyCount.count(), 0); - QCOMPARE(spyInsert.count(), 0); - QCOMPARE(spyRemove.count(), 0); + QTRY_COMPARE(spyCount.count(), 1); + QTRY_COMPARE(spyInsert.count(), 1); + QTRY_COMPARE(spyRemove.count(), 1); + + QCOMPARE(spyInsert[0][0].toInt(), 0); + QCOMPARE(spyInsert[0][1].toInt(), 9); - QCOMPARE(model->data(0, model->roles().first()).toString(), QString("Polly")); - QCOMPARE(model->data(model->count()-1, model->roles().first()).toString(), QString("Tiny")); + QCOMPARE(spyRemove[0][0].toInt(), 0); + QCOMPARE(spyRemove[0][1].toInt(), 9); delete model; } @@ -415,15 +416,15 @@ void tst_qdeclarativexmllistmodel::useKeys() QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); QSignalSpy spyCount(model, SIGNAL(countChanged())); - QSignalSpy spyReset(model, SIGNAL(modelReset())); model->setXml(newXml); - if (insertRanges.isEmpty() && removeRanges.isEmpty()) { - QTRY_COMPARE(spyReset.count(), 1); + if (oldCount != newData.count()) { + QTRY_COMPARE(model->count(), newData.count()); + QCOMPARE(spyCount.count(), 1); } else { QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0); - QCOMPARE(spyCount.count() == 0, oldCount == newData.count()); + QCOMPARE(spyCount.count(), 0); } QList<int> roles = model->roles(); @@ -512,14 +513,21 @@ void tst_qdeclarativexmllistmodel::useKeys_data() << makeItemXmlAndData("", &modelData) << modelData << QList<QDeclarativeXmlListRange>() - << QList<QDeclarativeXmlListRange>(); + << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 3)); QTest::newRow("replace item") << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 << makeItemXmlAndData("name=ZZZ,age=25,sport=Football", &modelData) << modelData - << QList<QDeclarativeXmlListRange>() - << QList<QDeclarativeXmlListRange>(); + << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1)) + << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1)); + + QTest::newRow("add and remove simultaneously, in different spots") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4 + << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData) + << modelData + << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1)) + << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2)); QTest::newRow("insert at start, remove at end i.e. rss feed") << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 3 @@ -539,8 +547,8 @@ void tst_qdeclarativexmllistmodel::useKeys_data() << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35") << 2 << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) << modelData - << QList<QDeclarativeXmlListRange>() - << QList<QDeclarativeXmlListRange>(); + << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2)) + << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2)); } void tst_qdeclarativexmllistmodel::noKeysValueChanges() @@ -600,14 +608,20 @@ void tst_qdeclarativexmllistmodel::keysChanged() QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); QSignalSpy spyCount(model, SIGNAL(countChanged())); - QSignalSpy spyReset(model, SIGNAL(modelReset())); QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey")); model->setXml(xml); - QTRY_COMPARE(spyReset.count(), 1); - QCOMPARE(spyInsert.count(), 0); - QCOMPARE(spyRemove.count(), 0); + QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0); + + QCOMPARE(spyInsert.count(), 1); + QCOMPARE(spyInsert[0][0].toInt(), 0); + QCOMPARE(spyInsert[0][1].toInt(), 2); + + QCOMPARE(spyRemove.count(), 1); + QCOMPARE(spyRemove[0][0].toInt(), 0); + QCOMPARE(spyRemove[0][1].toInt(), 2); + QCOMPARE(spyCount.count(), 0); delete model; |