From 7cad0e52c5a020bd29635e9912fd8946a6b48124 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 15 Jan 2013 14:26:59 -0800 Subject: Move the model classes from QtQuick to QtQml This is needed for proper support of non-GUI instantiators in QtQml. Only private C++ classes are affected. Aside from name changes, model classes now operate on QObjects instead of QQuickItems, leading to minor changes in the implementation of QtQuick classes using them. The old QML type names will still be registered in the QtQuick import for the forseeable future, but pointing to the new classes. The new QML types will be added in a second commit. Classes Affected: QQuickVisualDataGroup -> QQmlDataGroup QQuickVisualDataModel -> QQmlDelegateModel QQuickVisualItemModel -> QQmlObjectModel QQuickVisualModel -> QQmlInstanceModel QQuickChangeSet -> QQmlChangeSet QQuickListAccessor -> QQmlListAccessor QQuickListCompositor -> QQmlListCompositor QQuickPackage -> QQuickPackage (just moved for now) Change-Id: Ia19e630e53bfa9e5d459e289596cd11df1ea3930 Reviewed-by: Andrew den Exter --- .../quick/qquickgridview/tst_qquickgridview.cpp | 1 - .../quick/qquicklistview/tst_qquicklistview.cpp | 8 +- .../tst_qquickvisualdatamodel.cpp | 264 ++++++++++----------- 3 files changed, 136 insertions(+), 137 deletions(-) (limited to 'tests/auto/quick') diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index aee4e0d119..5c0bbb1e21 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -51,7 +51,6 @@ #include #include #include -#include #include #include "../../shared/util.h" #include "../shared/viewtestutil.h" diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index a1b2536b0b..9bcf9d6333 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include "../../shared/util.h" #include "../shared/viewtestutil.h" @@ -2767,7 +2767,7 @@ void tst_QQuickListView::itemList() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != 0); - QQuickVisualItemModel *model = window->rootObject()->findChild("itemModel"); + QQmlObjectModel *model = window->rootObject()->findChild("itemModel"); QTRY_VERIFY(model != 0); QTRY_VERIFY(model->count() == 3); @@ -2808,7 +2808,7 @@ void tst_QQuickListView::itemListFlicker() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != 0); - QQuickVisualItemModel *model = window->rootObject()->findChild("itemModel"); + QQmlObjectModel *model = window->rootObject()->findChild("itemModel"); QTRY_VERIFY(model != 0); QTRY_VERIFY(model->count() == 3); @@ -4605,7 +4605,7 @@ void tst_QQuickListView::rightToLeft() QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - QQuickVisualItemModel *model = window->rootObject()->findChild("itemModel"); + QQmlObjectModel *model = window->rootObject()->findChild("itemModel"); QTRY_VERIFY(model != 0); QTRY_VERIFY(model->count() == 3); diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp index 74c557871f..f97b0f35a6 100644 --- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp +++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp @@ -52,9 +52,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include #include @@ -360,21 +360,21 @@ public: int indexCreated; public Q_SLOTS: - void initItem(int index, QQuickItem *item) + void initItem(int index, QObject *item) { - itemInitialized = item; + itemInitialized = qobject_cast(item); indexInitialized = index; } - void createdItem(int index, QQuickItem *item) + void createdItem(int index, QObject *item) { - itemCreated = item; + itemCreated = qobject_cast(item); indexCreated = index; } - void destroyingItem(QQuickItem *item) + void destroyingItem(QObject *item) { - itemDestroyed = item; + itemDestroyed = qobject_cast(item); } }; @@ -452,9 +452,9 @@ private: template void get_verify( const SingleRoleModel &model, - QQuickVisualDataModel *visualModel, - QQuickVisualDataGroup *visibleItems, - QQuickVisualDataGroup *selectedItems, + QQmlDelegateModel *visualModel, + QQmlDataGroup *visibleItems, + QQmlDataGroup *selectedItems, const int (&mIndex)[N], const int (&iIndex)[N], const int (&vIndex)[N], @@ -467,7 +467,7 @@ private: QQmlEngine engine; }; -Q_DECLARE_METATYPE(QQuickChangeSet) +Q_DECLARE_METATYPE(QQmlChangeSet) template static T evaluate(QObject *scope, const QString &expression) { @@ -489,7 +489,7 @@ template <> void evaluate(QObject *scope, const QString &expression) void tst_qquickvisualdatamodel::initTestCase() { QQmlDataTest::initTestCase(); - qRegisterMetaType(); + qRegisterMetaType(); qmlRegisterType("tst_qquickvisualdatamodel", 1, 0, "SingleRoleModel"); qmlRegisterType("tst_qquickvisualdatamodel", 1, 0, "DataObject"); @@ -517,7 +517,7 @@ void tst_qquickvisualdatamodel::rootIndex() engine.rootContext()->setContextProperty("myModel", &model); - QQuickVisualDataModel *obj = qobject_cast(c.create()); + QQmlDelegateModel *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QMetaObject::invokeMethod(obj, "setRoot"); @@ -611,7 +611,7 @@ void tst_qquickvisualdatamodel::childChanged() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QQuickVisualDataModel *vdm = listview->findChild("visualModel"); + QQmlDelegateModel *vdm = listview->findChild("visualModel"); vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0)))); QCOMPARE(listview->count(), 1); @@ -922,7 +922,7 @@ void tst_qquickvisualdatamodel::noDelegate() QQuickListView *listview = qobject_cast(view.rootObject()); QVERIFY(listview != 0); - QQuickVisualDataModel *vdm = listview->findChild("visualModel"); + QQmlDelegateModel *vdm = listview->findChild("visualModel"); QVERIFY(vdm != 0); QCOMPARE(vdm->count(), 3); @@ -1052,15 +1052,15 @@ void tst_qquickvisualdatamodel::qaimRowsMoved() SingleRoleModel model(list); engine.rootContext()->setContextProperty("myModel", &model); - QQuickVisualDataModel *obj = qobject_cast(c.create()); + QQmlDelegateModel *obj = qobject_cast(c.create()); QVERIFY(obj != 0); - QSignalSpy spy(obj, SIGNAL(modelUpdated(QQuickChangeSet,bool))); + QSignalSpy spy(obj, SIGNAL(modelUpdated(QQmlChangeSet,bool))); model.emitMove(sourceFirst, sourceLast, destinationChild); QCOMPARE(spy.count(), 1); QCOMPARE(spy[0].count(), 2); - QQuickChangeSet changeSet = spy[0][0].value(); + QQmlChangeSet changeSet = spy[0][0].value(); QCOMPARE(changeSet.removes().count(), 1); QCOMPARE(changeSet.removes().at(0).index, expectFrom); QCOMPARE(changeSet.removes().at(0).count, expectCount); @@ -1115,11 +1115,11 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved() QQmlComponent component(&engine, testFileUrl("visualdatamodel.qml")); QScopedPointer object(component.create()); - QQuickVisualDataModel *vdm = qobject_cast(object.data()); + QQmlDelegateModel *vdm = qobject_cast(object.data()); QVERIFY(vdm); - QSignalSpy spy(vdm, SIGNAL(modelUpdated(QQuickChangeSet,bool))); - QQuickChangeSet changeSet; + QSignalSpy spy(vdm, SIGNAL(modelUpdated(QQmlChangeSet,bool))); + QQmlChangeSet changeSet; QCOMPARE(vdm->count(), 4); @@ -1127,7 +1127,7 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved() model.move(QModelIndex(), 1, model.index(0, 0), 3, 2); QCOMPARE(vdm->count(), 2); QCOMPARE(spy.count(), 1); - changeSet = spy.last().at(0).value(); + changeSet = spy.last().at(0).value(); QCOMPARE(changeSet.removes().count(), 1); QCOMPARE(changeSet.removes().at(0).index, 1); QCOMPARE(changeSet.removes().at(0).count, 2); @@ -1137,7 +1137,7 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved() model.move(model.index(0, 0), 4, QModelIndex(), 2, 1); QCOMPARE(vdm->count(), 3); QCOMPARE(spy.count(), 2); - changeSet = spy.last().at(0).value(); + changeSet = spy.last().at(0).value(); QCOMPARE(changeSet.removes().count(), 0); QCOMPARE(changeSet.inserts().count(), 1); QCOMPARE(changeSet.inserts().at(0).index, 2); @@ -1147,11 +1147,11 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved() QCOMPARE(vdm->rootIndex().value(), model.index(2, 0)); QCOMPARE(vdm->count(), 3); QCOMPARE(spy.count(), 4); - changeSet = spy.at(2).at(0).value(); + changeSet = spy.at(2).at(0).value(); QCOMPARE(changeSet.removes().count(), 1); QCOMPARE(changeSet.removes().at(0).index, 0); QCOMPARE(changeSet.removes().at(0).count, 3); - changeSet = spy.last().at(0).value(); + changeSet = spy.last().at(0).value(); QCOMPARE(changeSet.inserts().count(), 1); QCOMPARE(changeSet.inserts().at(0).index, 0); QCOMPARE(changeSet.inserts().at(0).count, 3); @@ -1182,7 +1182,7 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved() QCOMPARE(vdm->rootIndex().value(), QModelIndex()); QCOMPARE(vdm->count(), 0); QCOMPARE(spy.count(), 5); - changeSet = spy.last().at(0).value(); + changeSet = spy.last().at(0).value(); QCOMPARE(changeSet.removes().count(), 1); QCOMPARE(changeSet.removes().at(0).index, 0); QCOMPARE(changeSet.removes().at(0).count, 3); @@ -1192,7 +1192,7 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved() QCOMPARE(vdm->rootIndex().value(), QModelIndex()); QCOMPARE(vdm->count(), 2); QCOMPARE(spy.count(), 6); - changeSet = spy.last().at(0).value(); + changeSet = spy.last().at(0).value(); QCOMPARE(changeSet.removes().count(), 0); QCOMPARE(changeSet.inserts().count(), 1); QCOMPARE(changeSet.inserts().at(0).index, 0); @@ -1211,17 +1211,17 @@ void tst_qquickvisualdatamodel::watchedRoles() QQmlComponent component(&engine, testFileUrl("visualdatamodel.qml")); QScopedPointer object(component.create()); - QQuickVisualDataModel *vdm = qobject_cast(object.data()); + QQmlDelegateModel *vdm = qobject_cast(object.data()); QVERIFY(vdm); // VisualDataModel doesn't initialize model data until the first item is requested. - QQuickItem *item = vdm->item(0); + QQuickItem *item = qobject_cast(vdm->object(0)); QVERIFY(item); vdm->release(item); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // Ensure released items are deleted before test exits. - QSignalSpy spy(vdm, SIGNAL(modelUpdated(QQuickChangeSet,bool))); - QQuickChangeSet changeSet; + QSignalSpy spy(vdm, SIGNAL(modelUpdated(QQmlChangeSet,bool))); + QQmlChangeSet changeSet; QCOMPARE(vdm->count(), 30); @@ -1238,13 +1238,13 @@ void tst_qquickvisualdatamodel::watchedRoles() emit model.dataChanged(model.index(0), model.index(4)); QCOMPARE(spy.count(), 1); - changeSet = spy.last().at(0).value(); + changeSet = spy.last().at(0).value(); QCOMPARE(changeSet.changes().at(0).index, 0); QCOMPARE(changeSet.changes().at(0).count, 5); emit model.dataChanged(model.index(1), model.index(6), QVector() << QaimModel::Name); QCOMPARE(spy.count(), 2); - changeSet = spy.last().at(0).value(); + changeSet = spy.last().at(0).value(); QCOMPARE(changeSet.changes().at(0).index, 1); QCOMPARE(changeSet.changes().at(0).count, 6); @@ -1255,7 +1255,7 @@ void tst_qquickvisualdatamodel::watchedRoles() emit model.dataChanged(model.index(0), model.index(4)); QCOMPARE(spy.count(), 3); - changeSet = spy.last().at(0).value(); + changeSet = spy.last().at(0).value(); QCOMPARE(changeSet.changes().at(0).index, 0); QCOMPARE(changeSet.changes().at(0).count, 5); @@ -1264,7 +1264,7 @@ void tst_qquickvisualdatamodel::watchedRoles() emit model.dataChanged(model.index(8), model.index(8), QVector() << QaimModel::Number); QCOMPARE(spy.count(), 4); - changeSet = spy.last().at(0).value(); + changeSet = spy.last().at(0).value(); QCOMPARE(changeSet.changes().at(0).index, 8); QCOMPARE(changeSet.changes().at(0).count, 1); @@ -1272,19 +1272,19 @@ void tst_qquickvisualdatamodel::watchedRoles() emit model.dataChanged(model.index(0), model.index(4)); QCOMPARE(spy.count(), 5); - changeSet = spy.last().at(0).value(); + changeSet = spy.last().at(0).value(); QCOMPARE(changeSet.changes().at(0).index, 0); QCOMPARE(changeSet.changes().at(0).count, 5); emit model.dataChanged(model.index(1), model.index(6), QVector() << QaimModel::Name); QCOMPARE(spy.count(), 6); - changeSet = spy.last().at(0).value(); + changeSet = spy.last().at(0).value(); QCOMPARE(changeSet.changes().at(0).index, 1); QCOMPARE(changeSet.changes().at(0).count, 6); emit model.dataChanged(model.index(8), model.index(8), QVector() << QaimModel::Number); QCOMPARE(spy.count(), 7); - changeSet = spy.last().at(0).value(); + changeSet = spy.last().at(0).value(); QCOMPARE(changeSet.changes().at(0).index, 8); QCOMPARE(changeSet.changes().at(0).count, 1); } @@ -1301,29 +1301,29 @@ void tst_qquickvisualdatamodel::hasModelChildren() QQmlComponent component(&engine, testFileUrl("visualdatamodel.qml")); QScopedPointer object(component.create()); - QQuickVisualDataModel *vdm = qobject_cast(object.data()); + QQmlDelegateModel *vdm = qobject_cast(object.data()); QVERIFY(vdm); QCOMPARE(vdm->count(), 4); QQuickItem *item = 0; - item = vdm->item(0); + item = qobject_cast(vdm->object(0)); QVERIFY(item); QCOMPARE(item->property("modelChildren").toBool(), true); vdm->release(item); - item = vdm->item(1); + item = qobject_cast(vdm->object(1)); QVERIFY(item); QCOMPARE(item->property("modelChildren").toBool(), false); vdm->release(item); - item = vdm->item(2); + item = qobject_cast(vdm->object(2)); QVERIFY(item); QCOMPARE(item->property("modelChildren").toBool(), true); vdm->release(item); - item = vdm->item(3); + item = qobject_cast(vdm->object(3)); QVERIFY(item); QCOMPARE(item->property("modelChildren").toBool(), false); vdm->release(item); @@ -1351,14 +1351,14 @@ void tst_qquickvisualdatamodel::setValue() QQmlComponent component(&engine, testFileUrl("visualdatamodel.qml")); QScopedPointer object(component.create()); - QQuickVisualDataModel *vdm = qobject_cast(object.data()); + QQmlDelegateModel *vdm = qobject_cast(object.data()); QVERIFY(vdm); QCOMPARE(vdm->count(), 3); QQuickItem *item = 0; - item = vdm->item(0); + item = qobject_cast(vdm->object(0)); QVERIFY(item); QCOMPARE(evaluate(item, "display"), QString("Row 1 Item")); evaluate(item, "display = 'Changed Item 1'"); @@ -1412,7 +1412,7 @@ void tst_qquickvisualdatamodel::remove() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QQuickVisualDataModel *visualModel = qobject_cast(qvariant_cast(listview->model())); + QQmlDelegateModel *visualModel = qobject_cast(qvariant_cast(listview->model())); QVERIFY(visualModel); { @@ -1521,7 +1521,7 @@ void tst_qquickvisualdatamodel::move() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QQuickVisualDataModel *visualModel = qobject_cast(qvariant_cast(listview->model())); + QQmlDelegateModel *visualModel = qobject_cast(qvariant_cast(listview->model())); QVERIFY(visualModel); { @@ -1710,13 +1710,13 @@ void tst_qquickvisualdatamodel::groups() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QQuickVisualDataModel *visualModel = listview->findChild("visualModel"); + QQmlDelegateModel *visualModel = listview->findChild("visualModel"); QVERIFY(visualModel); - QQuickVisualDataGroup *visibleItems = listview->findChild("visibleItems"); + QQmlDataGroup *visibleItems = listview->findChild("visibleItems"); QVERIFY(visibleItems); - QQuickVisualDataGroup *selectedItems = listview->findChild("selectedItems"); + QQmlDataGroup *selectedItems = listview->findChild("selectedItems"); QVERIFY(selectedItems); const bool f = false; @@ -1939,9 +1939,9 @@ void tst_qquickvisualdatamodel::groups() template void tst_qquickvisualdatamodel::get_verify( const SingleRoleModel &model, - QQuickVisualDataModel *visualModel, - QQuickVisualDataGroup *visibleItems, - QQuickVisualDataGroup *selectedItems, + QQmlDelegateModel *visualModel, + QQmlDataGroup *visibleItems, + QQmlDataGroup *selectedItems, const int (&mIndex)[N], const int (&iIndex)[N], const int (&vIndex)[N], @@ -2030,13 +2030,13 @@ void tst_qquickvisualdatamodel::get() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QQuickVisualDataModel *visualModel = qobject_cast(qvariant_cast(listview->model())); + QQmlDelegateModel *visualModel = qobject_cast(qvariant_cast(listview->model())); QVERIFY(visualModel); - QQuickVisualDataGroup *visibleItems = visualModel->findChild("visibleItems"); + QQmlDataGroup *visibleItems = visualModel->findChild("visibleItems"); QVERIFY(visibleItems); - QQuickVisualDataGroup *selectedItems = visualModel->findChild("selectedItems"); + QQmlDataGroup *selectedItems = visualModel->findChild("selectedItems"); QVERIFY(selectedItems); QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(ctxt->engine()); @@ -2154,7 +2154,7 @@ void tst_qquickvisualdatamodel::get() void tst_qquickvisualdatamodel::invalidGroups() { QUrl source = testFileUrl("groups-invalid.qml"); - QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("Group names must start with a lower case letter")).toUtf8()); + QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQmlDataGroup::tr("Group names must start with a lower case letter")).toUtf8()); QQmlComponent component(&engine, source); QScopedPointer object(component.create()); @@ -2326,7 +2326,7 @@ void tst_qquickvisualdatamodel::create() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QQuickVisualDataModel *visualModel = qobject_cast(qvariant_cast(listview->model())); + QQmlDelegateModel *visualModel = qobject_cast(qvariant_cast(listview->model())); QVERIFY(visualModel); QCOMPARE(listview->count(), 20); @@ -2440,7 +2440,7 @@ void tst_qquickvisualdatamodel::incompleteModel() QScopedPointer object(component.beginCreate(engine.rootContext())); - QQuickVisualDataModel *model = qobject_cast(object.data()); + QQmlDelegateModel *model = qobject_cast(object.data()); QVERIFY(model); QSignalSpy itemsSpy(model->items(), SIGNAL(countChanged())); @@ -3665,67 +3665,67 @@ void tst_qquickvisualdatamodel::warnings_data() QTest::newRow("insert < 0") << testFileUrl("listmodelproperties.qml") << QString("items.insert(-2, {\"number\": \"eight\"})") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("insert: index out of range")) << 4; QTest::newRow("insert > length") << testFileUrl("listmodelproperties.qml") << QString("items.insert(8, {\"number\": \"eight\"})") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("insert: index out of range")) << 4; QTest::newRow("create < 0") << testFileUrl("listmodelproperties.qml") << QString("items.create(-2, {\"number\": \"eight\"})") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("create: index out of range")) << 4; QTest::newRow("create > length") << testFileUrl("listmodelproperties.qml") << QString("items.create(8, {\"number\": \"eight\"})") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("create: index out of range")) << 4; QTest::newRow("resolve from < 0") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(-2, 3)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: from index out of range")) << 4; QTest::newRow("resolve from > length") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(8, 3)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: from index out of range")) << 4; QTest::newRow("resolve to < 0") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(3, -2)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: to index out of range")) << 4; QTest::newRow("resolve to > length") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(3, 8)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: to index out of range")) << 4; QTest::newRow("resolve from invalid index") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(\"two\", 3)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index invalid")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: from index invalid")) << 4; QTest::newRow("resolve to invalid index") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(3, \"two\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index invalid")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: to index invalid")) << 4; QTest::newRow("resolve already resolved item") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(3, 2)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from is not an unresolved item")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: from is not an unresolved item")) << 4; QTest::newRow("resolve already resolved item") @@ -3733,193 +3733,193 @@ void tst_qquickvisualdatamodel::warnings_data() << QString("{ items.insert(0, {\"number\": \"eight\"});" "items.insert(1, {\"number\": \"seven\"});" "items.resolve(0, 1)}") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to is not a model item")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("resolve: to is not a model item")) << 6; QTest::newRow("remove index < 0") << testFileUrl("listmodelproperties.qml") << QString("items.remove(-2, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("remove: index out of range")) << 4; QTest::newRow("remove index == length") << testFileUrl("listmodelproperties.qml") << QString("items.remove(4, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("remove: index out of range")) << 4; QTest::newRow("remove index > length") << testFileUrl("listmodelproperties.qml") << QString("items.remove(9, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("remove: index out of range")) << 4; QTest::newRow("remove invalid index") << testFileUrl("listmodelproperties.qml") << QString("items.remove(\"nine\", 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid index")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("remove: invalid index")) << 4; QTest::newRow("remove count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.remove(1, -2)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("remove: invalid count")) << 4; QTest::newRow("remove index + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.remove(2, 4, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("remove: invalid count")) << 4; QTest::newRow("addGroups index < 0") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(-2, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("addGroups: index out of range")) << 4; QTest::newRow("addGroups index == length") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(4, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("addGroups: index out of range")) << 4; QTest::newRow("addGroups index > length") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(9, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("addGroups: index out of range")) << 4; QTest::newRow("addGroups count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(1, -2, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("addGroups: invalid count")) << 4; QTest::newRow("addGroups index + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(2, 4, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("addGroups: invalid count")) << 4; QTest::newRow("removeGroups index < 0") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(-2, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("removeGroups: index out of range")) << 4; QTest::newRow("removeGroups index == length") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(4, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("removeGroups: index out of range")) << 4; QTest::newRow("removeGroups index > length") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(9, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("removeGroups: index out of range")) << 4; QTest::newRow("removeGroups count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(1, -2, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("removeGroups: invalid count")) << 4; QTest::newRow("removeGroups index + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(2, 4, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("removeGroups: invalid count")) << 4; QTest::newRow("setGroups index < 0") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(-2, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("setGroups: index out of range")) << 4; QTest::newRow("setGroups index == length") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(4, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("setGroups: index out of range")) << 4; QTest::newRow("setGroups index > length") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(9, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("setGroups: index out of range")) << 4; QTest::newRow("setGroups count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(1, -2, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("setGroups: invalid count")) << 4; QTest::newRow("setGroups index + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(2, 4, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("setGroups: invalid count")) << 4; QTest::newRow("move from < 0") << testFileUrl("listmodelproperties.qml") << QString("items.move(-2, 1, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("move: from index out of range")) << 4; QTest::newRow("move from == length") << testFileUrl("listmodelproperties.qml") << QString("items.move(4, 1, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("move: from index out of range")) << 4; QTest::newRow("move from > length") << testFileUrl("listmodelproperties.qml") << QString("items.move(9, 1, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("move: from index out of range")) << 4; QTest::newRow("move invalid from") << testFileUrl("listmodelproperties.qml") << QString("items.move(\"nine\", 1, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid from index")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("move: invalid from index")) << 4; QTest::newRow("move to < 0") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, -2, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("move: to index out of range")) << 4; QTest::newRow("move to == length") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, 4, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("move: to index out of range")) << 4; QTest::newRow("move to > length") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, 9, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("move: to index out of range")) << 4; QTest::newRow("move invalid to") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, \"nine\", 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid to index")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("move: invalid to index")) << 4; QTest::newRow("move count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, 1, -2)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid count")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("move: invalid count")) << 4; QTest::newRow("move from + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.move(2, 1, 4)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) + << (": QML VisualDataGroup: " + QQmlDataGroup::tr("move: from index out of range")) << 4; } @@ -3961,19 +3961,19 @@ void tst_qquickvisualdatamodel::invalidAttachment() QCOMPARE(component.errors().count(), 0); QVariant property = object->property("invalidVdm"); - QCOMPARE(property.userType(), qMetaTypeId()); - QVERIFY(!property.value()); + QCOMPARE(property.userType(), qMetaTypeId()); + QVERIFY(!property.value()); QQuickItem *item = findItem(static_cast(object.data()), "delegate"); QVERIFY(item); property = item->property("validVdm"); - QCOMPARE(property.userType(), qMetaTypeId()); - QVERIFY(property.value()); + QCOMPARE(property.userType(), qMetaTypeId()); + QVERIFY(property.value()); property = item->property("invalidVdm"); - QCOMPARE(property.userType(), qMetaTypeId()); - QVERIFY(!property.value()); + QCOMPARE(property.userType(), qMetaTypeId()); + QVERIFY(!property.value()); } void tst_qquickvisualdatamodel::asynchronousInsert_data() @@ -4005,15 +4005,15 @@ void tst_qquickvisualdatamodel::asynchronousInsert() engine.rootContext()->setContextProperty("myModel", &model); - QQuickVisualDataModel *visualModel = qobject_cast(c.create()); + QQmlDelegateModel *visualModel = qobject_cast(c.create()); QVERIFY(visualModel); ItemRequester requester; - connect(visualModel, SIGNAL(initItem(int,QQuickItem*)), &requester, SLOT(initItem(int,QQuickItem*))); - connect(visualModel, SIGNAL(createdItem(int,QQuickItem*)), &requester, SLOT(createdItem(int,QQuickItem*))); - connect(visualModel, SIGNAL(destroyingItem(QQuickItem*)), &requester, SLOT(destroyingItem(QQuickItem*))); + connect(visualModel, SIGNAL(initItem(int,QObject*)), &requester, SLOT(initItem(int,QObject*))); + connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*))); + connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*))); - QQuickItem *item = visualModel->item(requestIndex, true); + QQuickItem *item = qobject_cast(visualModel->object(requestIndex, true)); QVERIFY(!item); QVERIFY(!requester.itemInitialized); @@ -4025,7 +4025,7 @@ void tst_qquickvisualdatamodel::asynchronousInsert() newItems.append(qMakePair(QLatin1String("New item") + QString::number(i), QString(QLatin1String("")))); model.insertItems(insertIndex, newItems); - item = visualModel->item(completeIndex, false); + item = qobject_cast(visualModel->object(completeIndex, false)); QVERIFY(item); QCOMPARE(requester.itemInitialized, item); @@ -4070,15 +4070,15 @@ void tst_qquickvisualdatamodel::asynchronousRemove() engine.rootContext()->setContextProperty("myModel", &model); - QQuickVisualDataModel *visualModel = qobject_cast(c.create()); + QQmlDelegateModel *visualModel = qobject_cast(c.create()); QVERIFY(visualModel); ItemRequester requester; - connect(visualModel, SIGNAL(initItem(int,QQuickItem*)), &requester, SLOT(initItem(int,QQuickItem*))); - connect(visualModel, SIGNAL(createdItem(int,QQuickItem*)), &requester, SLOT(createdItem(int,QQuickItem*))); - connect(visualModel, SIGNAL(destroyingItem(QQuickItem*)), &requester, SLOT(destroyingItem(QQuickItem*))); + connect(visualModel, SIGNAL(initItem(int,QObject*)), &requester, SLOT(initItem(int,QObject*))); + connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*))); + connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*))); - QQuickItem *item = visualModel->item(requestIndex, true); + QQuickItem *item = qobject_cast(visualModel->object(requestIndex, true)); QVERIFY(!item); QVERIFY(!requester.itemInitialized); @@ -4098,7 +4098,7 @@ void tst_qquickvisualdatamodel::asynchronousRemove() QCOMPARE(requester.itemCreated, requester.itemInitialized); QCOMPARE(requester.itemDestroyed, requester.itemInitialized); } else { - item = visualModel->item(completeIndex, false); + item = qobject_cast(visualModel->object(completeIndex, false)); QVERIFY(item); QCOMPARE(requester.itemInitialized, item); @@ -4148,15 +4148,15 @@ void tst_qquickvisualdatamodel::asynchronousMove() engine.rootContext()->setContextProperty("myModel", &model); - QQuickVisualDataModel *visualModel = qobject_cast(c.create()); + QQmlDelegateModel *visualModel = qobject_cast(c.create()); QVERIFY(visualModel); ItemRequester requester; - connect(visualModel, SIGNAL(initItem(int,QQuickItem*)), &requester, SLOT(initItem(int,QQuickItem*))); - connect(visualModel, SIGNAL(createdItem(int,QQuickItem*)), &requester, SLOT(createdItem(int,QQuickItem*))); - connect(visualModel, SIGNAL(destroyingItem(QQuickItem*)), &requester, SLOT(destroyingItem(QQuickItem*))); + connect(visualModel, SIGNAL(initItem(int,QObject*)), &requester, SLOT(initItem(int,QObject*))); + connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*))); + connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*))); - QQuickItem *item = visualModel->item(requestIndex, true); + QQuickItem *item = qobject_cast(visualModel->object(requestIndex, true)); QVERIFY(!item); QVERIFY(!requester.itemInitialized); @@ -4165,7 +4165,7 @@ void tst_qquickvisualdatamodel::asynchronousMove() model.moveItems(from, to, count); - item = visualModel->item(completeIndex, false); + item = qobject_cast(visualModel->object(completeIndex, false)); QVERIFY(item); @@ -4196,10 +4196,10 @@ void tst_qquickvisualdatamodel::asynchronousCancel() engine.rootContext()->setContextProperty("myModel", &model); - QQuickVisualDataModel *visualModel = qobject_cast(c.create()); + QQmlDelegateModel *visualModel = qobject_cast(c.create()); QVERIFY(visualModel); - QQuickItem *item = visualModel->item(requestIndex, true); + QQuickItem *item = qobject_cast(visualModel->object(requestIndex, true)); QVERIFY(!item); QCOMPARE(controller.incubatingObjectCount(), 1); @@ -4221,10 +4221,10 @@ void tst_qquickvisualdatamodel::invalidContext() QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml")); - QQuickVisualDataModel *visualModel = qobject_cast(c.create(context.data())); + QQmlDelegateModel *visualModel = qobject_cast(c.create(context.data())); QVERIFY(visualModel); - QQuickItem *item = visualModel->item(4, false); + QQuickItem *item = qobject_cast(visualModel->object(4, false)); QVERIFY(item); visualModel->release(item); @@ -4232,7 +4232,7 @@ void tst_qquickvisualdatamodel::invalidContext() model.insertItem(4, "new item", ""); - item = visualModel->item(4, false); + item = qobject_cast(visualModel->object(4, false)); QVERIFY(!item); } -- cgit v1.2.3