diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-07-10 17:01:52 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-25 02:15:15 +0200 |
commit | 7daab8039abc32ab5be5706a08cb58905fe0e0b6 (patch) | |
tree | 9ceb8afdeb37ac4d9bc089545e73e31040b847e4 /tests/auto | |
parent | b355aacb6e5c4f9b7ebb317125409ea0959d11d6 (diff) |
Remove QListModelInterface.
Implement ListModel and XmlListModel using QAbstractListModel
instead.
Task-number: QTBUG-15728
Change-Id: I14e03d90883d341f4b1d89c1e9fc9dc1534fde78
Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
Diffstat (limited to 'tests/auto')
10 files changed, 251 insertions, 518 deletions
diff --git a/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp b/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp index e4045ebe88..4c1a472269 100644 --- a/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp +++ b/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp @@ -86,7 +86,10 @@ class tst_qquicklistmodel : public QQmlDataTest { Q_OBJECT public: - tst_qquicklistmodel() {} + tst_qquicklistmodel() + { + qRegisterMetaType<QVector<int> >(); + } private: int roleFromName(const QQuickListModel *model, const QString &roleName); @@ -146,7 +149,7 @@ bool tst_qquicklistmodel::compareVariantList(const QVariantList &testList, QVari return false; const QVariantMap &map = testVariant.toMap(); - const QList<int> &roles = model->roles(); + const QHash<int, QByteArray> roleNames = model->roleNames(); QVariantMap::const_iterator it = map.begin(); QVariantMap::const_iterator end = map.end(); @@ -155,14 +158,7 @@ bool tst_qquicklistmodel::compareVariantList(const QVariantList &testList, QVari const QString &testKey = it.key(); const QVariant &testData = it.value(); - int roleIndex = -1; - for (int j=0 ; j < roles.count() ; ++j) { - if (model->toString(roles[j]).compare(testKey) == 0) { - roleIndex = j; - break; - } - } - + int roleIndex = roleNames.key(testKey.toUtf8(), -1); if (roleIndex == -1) return false; @@ -184,12 +180,7 @@ bool tst_qquicklistmodel::compareVariantList(const QVariantList &testList, QVari int tst_qquicklistmodel::roleFromName(const QQuickListModel *model, const QString &roleName) { - QList<int> roles = model->roles(); - for (int i=0; i<roles.count(); i++) { - if (model->toString(roles[i]) == roleName) - return roles[i]; - } - return -1; + return model->roleNames().key(roleName.toUtf8(), -1); } void tst_qquicklistmodel::static_types_data() @@ -720,11 +711,11 @@ void tst_qquicklistmodel::set() RUNEXPR("model.set(0, {test:true})"); QCOMPARE(RUNEXPR("model.get(0).test").toBool(), true); // triggers creation of model cache - QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(true)); + QCOMPARE(model.data(0, 0), qVariantFromValue(true)); RUNEXPR("model.set(0, {test:false})"); QCOMPARE(RUNEXPR("model.get(0).test").toBool(), false); // tests model cache is updated - QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(false)); + QCOMPARE(model.data(0, 0), qVariantFromValue(false)); QString warning = QString::fromLatin1("<Unknown File>: Can't create role for unsupported data type"); if (isValidErrorMessage(warning, dynamicRoles)) @@ -759,7 +750,7 @@ void tst_qquicklistmodel::get() RUNEXPR("model.append({roleC: {} })"); RUNEXPR("model.append({roleD: [ { a:1, b:2 }, { c: 3 } ] })"); - QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList<int>))); + QSignalSpy spy(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); QQmlExpression expr(engine.rootContext(), model, expression); expr.evaluate(); QVERIFY(!expr.hasError()); @@ -777,9 +768,9 @@ void tst_qquicklistmodel::get() QCOMPARE(spy.count(), 1); QList<QVariant> spyResult = spy.takeFirst(); - QCOMPARE(spyResult.at(0).toInt(), index); - QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time - QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role)); + QCOMPARE(spyResult.at(0).value<QModelIndex>(), model->index(index, 0, QModelIndex())); + QCOMPARE(spyResult.at(1).value<QModelIndex>(), model->index(index, 0, QModelIndex())); // only 1 item is modified at a time + QCOMPARE(spyResult.at(2).value<QVector<int> >(), (QVector<int>() << role)); delete model; } @@ -887,7 +878,7 @@ void tst_qquicklistmodel::get_nested() QString extendedExpression = QString("get(%1).%2.%3").arg(outerListIndex).arg(outerListRoleName).arg(expression); QQmlExpression expr(engine.rootContext(), model, extendedExpression); - QSignalSpy spy(childModel, SIGNAL(itemsChanged(int, int, QList<int>))); + QSignalSpy spy(childModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); expr.evaluate(); QVERIFY(!expr.hasError()); @@ -901,9 +892,9 @@ void tst_qquicklistmodel::get_nested() QCOMPARE(spy.count(), 1); QList<QVariant> spyResult = spy.takeFirst(); - QCOMPARE(spyResult.at(0).toInt(), index); - QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time - QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role)); + QCOMPARE(spyResult.at(0).value<QModelIndex>(), childModel->index(index, 0, QModelIndex())); + QCOMPARE(spyResult.at(1).value<QModelIndex>(), childModel->index(index, 0, QModelIndex())); // only 1 item is modified at a time + QCOMPARE(spyResult.at(2).value<QVector<int> >(), (QVector<int>() << role)); } delete model; @@ -978,7 +969,7 @@ void tst_qquicklistmodel::property_changes() QObject *connectionsObject = component.create(); QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString())); - QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList<int>))); + QSignalSpy spyItemsChanged(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); expr.setExpression(script_change); expr.evaluate(); @@ -990,8 +981,8 @@ void tst_qquicklistmodel::property_changes() // test itemsChanged() is emitted correctly if (itemsChanged) { QCOMPARE(spyItemsChanged.count(), 1); - QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex); - QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1); + QCOMPARE(spyItemsChanged.at(0).at(0).value<QModelIndex>(), model.index(listIndex, 0, QModelIndex())); + QCOMPARE(spyItemsChanged.at(0).at(1).value<QModelIndex>(), model.index(listIndex, 0, QModelIndex())); } else { QCOMPARE(spyItemsChanged.count(), 0); } @@ -1111,13 +1102,13 @@ void tst_qquicklistmodel::clear() // clearing does not remove the roles RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\", propertyC: \"value c\"})"); - QList<int> roles = model.roles(); + QHash<int, QByteArray> roleNames = model.roleNames(); model.clear(); QCOMPARE(model.count(), 0); - QCOMPARE(model.roles(), roles); - QCOMPARE(model.toString(roles[0]), QString("propertyA")); - QCOMPARE(model.toString(roles[1]), QString("propertyB")); - QCOMPARE(model.toString(roles[2]), QString("propertyC")); + QCOMPARE(model.roleNames(), roleNames); + QCOMPARE(roleNames[0], QByteArray("propertyA")); + QCOMPARE(roleNames[1], QByteArray("propertyB")); + QCOMPARE(roleNames[2], QByteArray("propertyC")); } void tst_qquicklistmodel::signal_handlers_data() diff --git a/tests/auto/qml/qquicklistmodelworkerscript/tst_qquicklistmodelworkerscript.cpp b/tests/auto/qml/qquicklistmodelworkerscript/tst_qquicklistmodelworkerscript.cpp index c5d16e53f4..8227eb587b 100644 --- a/tests/auto/qml/qquicklistmodelworkerscript/tst_qquicklistmodelworkerscript.cpp +++ b/tests/auto/qml/qquicklistmodelworkerscript/tst_qquicklistmodelworkerscript.cpp @@ -85,7 +85,10 @@ class tst_qquicklistmodelworkerscript : public QQmlDataTest { Q_OBJECT public: - tst_qquicklistmodelworkerscript() {} + tst_qquicklistmodelworkerscript() + { + qRegisterMetaType<QVector<int> >(); + } private: int roleFromName(const QQuickListModel *model, const QString &roleName); @@ -133,7 +136,7 @@ bool tst_qquicklistmodelworkerscript::compareVariantList(const QVariantList &tes return false; const QVariantMap &map = testVariant.toMap(); - const QList<int> &roles = model->roles(); + const QHash<int, QByteArray> roleNames = model->roleNames(); QVariantMap::const_iterator it = map.begin(); QVariantMap::const_iterator end = map.end(); @@ -142,18 +145,11 @@ bool tst_qquicklistmodelworkerscript::compareVariantList(const QVariantList &tes const QString &testKey = it.key(); const QVariant &testData = it.value(); - int roleIndex = -1; - for (int j=0 ; j < roles.count() ; ++j) { - if (model->toString(roles[j]).compare(testKey) == 0) { - roleIndex = j; - break; - } - } - + int roleIndex = roleNames.key(testKey.toUtf8(), -1); if (roleIndex == -1) return false; - const QVariant &modelData = model->data(i, roleIndex); + const QVariant &modelData = model->data(model->index(i, 0, QModelIndex()), roleIndex); if (testData.type() == QVariant::List) { const QVariantList &subList = testData.toList(); @@ -171,12 +167,7 @@ bool tst_qquicklistmodelworkerscript::compareVariantList(const QVariantList &tes int tst_qquicklistmodelworkerscript::roleFromName(const QQuickListModel *model, const QString &roleName) { - QList<int> roles = model->roles(); - for (int i=0; i<roles.count(); i++) { - if (model->toString(roles[i]) == roleName) - return roles[i]; - } - return -1; + return model->roleNames().key(roleName.toUtf8(), -1); } QQuickItem *tst_qquicklistmodelworkerscript::createWorkerTest(QQmlEngine *eng, QQmlComponent *component, QQuickListModel *model) @@ -497,7 +488,7 @@ void tst_qquicklistmodelworkerscript::get_worker() int role = roleFromName(&model, roleName); QVERIFY(role >= 0); - QSignalSpy spy(&model, SIGNAL(itemsChanged(int, int, QList<int>))); + QSignalSpy spy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); // in the worker thread, change the model data and call sync() QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", @@ -515,9 +506,9 @@ void tst_qquicklistmodelworkerscript::get_worker() QCOMPARE(spy.count(), 1); QList<QVariant> spyResult = spy.takeFirst(); - QCOMPARE(spyResult.at(0).toInt(), index); - QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time - QVERIFY(spyResult.at(2).value<QList<int> >().contains(role)); + QCOMPARE(spyResult.at(0).value<QModelIndex>(), model.index(index, 0, QModelIndex())); + QCOMPARE(spyResult.at(1).value<QModelIndex>(), model.index(index, 0, QModelIndex())); // only 1 item is modified at a time + QVERIFY(spyResult.at(2).value<QVector<int> >().contains(role)); delete item; } @@ -621,7 +612,7 @@ void tst_qquicklistmodelworkerscript::property_changes_worker() expr.evaluate(); QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString())); - QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList<int>))); + QSignalSpy spyItemsChanged(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, QStringList(script_change)))); @@ -630,8 +621,8 @@ void tst_qquicklistmodelworkerscript::property_changes_worker() // test itemsChanged() is emitted correctly if (itemsChanged) { QCOMPARE(spyItemsChanged.count(), 1); - QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex); - QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1); + QCOMPARE(spyItemsChanged.at(0).at(0).value<QModelIndex>(), model.index(listIndex, 0, QModelIndex())); + QCOMPARE(spyItemsChanged.at(0).at(1).value<QModelIndex>(), model.index(listIndex, 0, QModelIndex())); } else { QCOMPARE(spyItemsChanged.count(), 0); } @@ -674,8 +665,8 @@ void tst_qquicklistmodelworkerscript::worker_sync() QVERIFY(childModel); QVERIFY(childModel->count() == 1); - QSignalSpy spyModelInserted(&model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyChildInserted(childModel, SIGNAL(itemsInserted(int,int))); + QSignalSpy spyModelInserted(&model, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy spyChildInserted(childModel, SIGNAL(rowsInserted(QModelIndex,int,int))); QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker")); waitForWorker(item); @@ -729,7 +720,7 @@ void tst_qquicklistmodelworkerscript::worker_remove_element() QQuickItem *item = createWorkerTest(&eng, &component, &model); QVERIFY(item != 0); - QSignalSpy spyModelRemoved(&model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyModelRemoved(&model, SIGNAL(rowsRemoved(QModelIndex,int,int))); QVERIFY(model.count() == 0); QVERIFY(spyModelRemoved.count() == 0); @@ -792,7 +783,7 @@ void tst_qquicklistmodelworkerscript::worker_remove_list() QQuickItem *item = createWorkerTest(&eng, &component, &model); QVERIFY(item != 0); - QSignalSpy spyModelRemoved(&model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyModelRemoved(&model, SIGNAL(rowsRemoved(QModelIndex,int,int))); QVERIFY(model.count() == 0); QVERIFY(spyModelRemoved.count() == 0); diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index ef4b27b767..c8991ccc7a 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -53,7 +53,6 @@ #include <QtQuick/private/qquicktext_p.h> #include <QtQuick/private/qquickvisualitemmodel_p.h> #include <QtQml/private/qquicklistmodel_p.h> -#include <QtQml/private/qlistmodelinterface_p.h> #include "../../shared/util.h" #include "../shared/viewtestutil.h" #include "../shared/visualtestutil.h" @@ -1832,7 +1831,7 @@ void tst_QQuickGridView::currentIndex() QCOMPARE(gridview->contentY(), 400.0); // changing model should reset currentIndex to 0 - QmlListModel model; + QaimModel model; for (int i = 0; i < 60; i++) model.addItem("Item" + QString::number(i), QString::number(i)); ctxt->setContextProperty("testModel", &model); @@ -1947,7 +1946,7 @@ void tst_QQuickGridView::keyNavigation() QFETCH(int, indexUpFrom7); QFETCH(int, indexDownFrom7); - QmlListModel model; + QaimModel model; for (int i = 0; i < 18; i++) model.addItem("Item" + QString::number(i), ""); @@ -3577,8 +3576,9 @@ void tst_QQuickGridView::extents() QQuickView *window = getView(); - QmlListModel model; + QaimModel model; QQmlContext *ctxt = window->rootContext(); + ctxt->setContextProperty("testModel", &model); window->setSource(testFileUrl("headerfooter.qml")); window->show(); @@ -3940,7 +3940,7 @@ void tst_QQuickGridView::resizeGrid_data() void tst_QQuickGridView::changeColumnCount() { - QmlListModel model; + QaimModel model; for (int i = 0; i < 40; i++) model.addItem("Item" + QString::number(i), ""); @@ -5620,7 +5620,7 @@ void tst_QQuickGridView::multipleTransitions() QPointF removeTargets_transitionTo(-100, 300); QPointF removeDisplaced_transitionFrom(100, 300); - QmlListModel model; + QaimModel model; for (int i = 0; i < initialCount; i++) model.addItem("Original item" + QString::number(i), ""); @@ -5795,7 +5795,7 @@ void tst_QQuickGridView::multipleDisplaced() // moved from previously set positions, and not those that have moved from their current // item positions (which may e.g. still be changing from easing bounces in the last transition) - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Original item" + QString::number(i), ""); diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 50c4a0a1a8..0ca2c6a679 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -75,39 +75,29 @@ public: private slots: void init(); void cleanupTestCase(); - // Test both QListModelInterface and QAbstractItemModel model types - void qListModelInterface_items(); - void qListModelInterface_package_items(); + // Test QAbstractItemModel model types + void qAbstractItemModel_package_items(); void qAbstractItemModel_items(); - void qListModelInterface_changed(); - void qListModelInterface_package_changed(); + void qAbstractItemModel_package_changed(); void qAbstractItemModel_changed(); - void qListModelInterface_inserted(); - void qListModelInterface_inserted_more(); - void qListModelInterface_inserted_more_data(); - void qListModelInterface_package_inserted(); + void qAbstractItemModel_package_inserted(); void qAbstractItemModel_inserted(); void qAbstractItemModel_inserted_more(); void qAbstractItemModel_inserted_more_data(); void qAbstractItemModel_inserted_more_bottomToTop(); void qAbstractItemModel_inserted_more_bottomToTop_data(); - void qListModelInterface_removed(); - void qListModelInterface_removed_more(); - void qListModelInterface_removed_more_data(); - void qListModelInterface_package_removed(); + void qAbstractItemModel_package_removed(); void qAbstractItemModel_removed(); void qAbstractItemModel_removed_more(); void qAbstractItemModel_removed_more_data(); void qAbstractItemModel_removed_more_bottomToTop(); void qAbstractItemModel_removed_more_bottomToTop_data(); - void qListModelInterface_moved(); - void qListModelInterface_moved_data(); - void qListModelInterface_package_moved(); - void qListModelInterface_package_moved_data(); + void qAbstractItemModel_package_moved(); + void qAbstractItemModel_package_moved_data(); void qAbstractItemModel_moved(); void qAbstractItemModel_moved_data(); void qAbstractItemModel_moved_bottomToTop(); @@ -118,8 +108,7 @@ private slots: void multipleChanges_uncondensed() { multipleChanges(false); } void multipleChanges_uncondensed_data() { multipleChanges_data(); } - void qListModelInterface_clear(); - void qListModelInterface_package_clear(); + void qAbstractItemModel_package_clear(); void qAbstractItemModel_clear(); void qAbstractItemModel_clear_bottomToTop(); @@ -137,8 +126,7 @@ private slots: void enforceRange(); void enforceRange_withoutHighlight(); void spacing(); - void qListModelInterface_sections(); - void qListModelInterface_package_sections(); + void qAbstractItemModel_package_sections(); void qAbstractItemModel_sections(); void sectionsPositioning(); void sectionsDelegate(); @@ -740,7 +728,7 @@ void tst_QQuickListView::insertBeforeVisible() QQuickText *name; QQuickView *window = getView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), ""); @@ -1485,7 +1473,7 @@ void tst_QQuickListView::multipleChanges(bool condensed) QQuickView *window = getView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < startCount; i++) model.addItem("Item" + QString::number(i), ""); @@ -1733,7 +1721,7 @@ void tst_QQuickListView::swapWithFirstItem() { QQuickView *window = createView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), ""); @@ -1764,7 +1752,7 @@ void tst_QQuickListView::enforceRange() { QQuickView *window = createView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), ""); @@ -1804,7 +1792,7 @@ void tst_QQuickListView::enforceRange() QTRY_COMPARE(listview->currentIndex(), 6); // change model - QmlListModel model2; + QaimModel model2; for (int i = 0; i < 5; i++) model2.addItem("Item" + QString::number(i), ""); @@ -1823,7 +1811,7 @@ void tst_QQuickListView::enforceRange_withoutHighlight() QQuickView *window = createView(); - QmlListModel model; + QaimModel model; model.addItem("Item 0", "a"); model.addItem("Item 1", "b"); model.addItem("Item 2", "b"); @@ -1865,7 +1853,7 @@ void tst_QQuickListView::spacing() { QQuickView *window = createView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), ""); @@ -2024,7 +2012,7 @@ void tst_QQuickListView::sectionsDelegate() { QQuickView *window = createView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), QString::number(i/5)); @@ -2133,7 +2121,7 @@ void tst_QQuickListView::sectionsDragOutsideBounds() QQuickView *window = getView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 10; i++) model.addItem("Item" + QString::number(i), QString::number(i/5)); @@ -2181,7 +2169,7 @@ void tst_QQuickListView::sectionsDelegate_headerVisibility() QQuickView *window = createView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), QString::number(i/5)); @@ -2212,7 +2200,7 @@ void tst_QQuickListView::sectionsPositioning() { QQuickView *window = createView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), QString::number(i/5)); @@ -2358,7 +2346,7 @@ void tst_QQuickListView::sectionsPositioning() window->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart | QQuickViewSection::NextLabelAtEnd))); QTRY_VERIFY(findVisibleChild(contentItem, "sect_aaa")); // section header QTRY_VERIFY(findVisibleChild(contentItem, "sect_new")); // section footer - QmlListModel model1; + QaimModel model1; ctxt->setContextProperty("testModel", &model1); QTRY_VERIFY(!findVisibleChild(contentItem, "sect_aaa")); // section header QTRY_VERIFY(!findVisibleChild(contentItem, "sect_new")); // section footer @@ -2515,7 +2503,8 @@ void tst_QQuickListView::currentIndex_delayedItemCreation_data() void tst_QQuickListView::currentIndex() { - QmlListModel initModel; + QaimModel initModel; + for (int i = 0; i < 30; i++) initModel.addItem("Item" + QString::number(i), QString::number(i)); @@ -2545,7 +2534,7 @@ void tst_QQuickListView::currentIndex() QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); // changing model should reset currentIndex to 0 - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), QString::number(i)); ctxt->setContextProperty("testModel", &model); @@ -2610,7 +2599,7 @@ void tst_QQuickListView::currentIndex() void tst_QQuickListView::noCurrentIndex() { - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), QString::number(i)); @@ -2656,7 +2645,7 @@ void tst_QQuickListView::keyNavigation() QFETCH(QPointF, contentPosAtFirstItem); QFETCH(QPointF, contentPosAtLastItem); - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), ""); @@ -2863,7 +2852,7 @@ void tst_QQuickListView::cacheBuffer() { QQuickView *window = createView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 90; i++) model.addItem("Item" + QString::number(i), ""); @@ -2964,7 +2953,7 @@ void tst_QQuickListView::positionViewAtIndex() { QQuickView *window = createView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 40; i++) model.addItem("Item" + QString::number(i), ""); @@ -3390,7 +3379,7 @@ void tst_QQuickListView::QTBUG_11105() { QQuickView *window = createView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), ""); @@ -3422,7 +3411,7 @@ void tst_QQuickListView::QTBUG_11105() listview->positionViewAtIndex(20, QQuickListView::Beginning); QCOMPARE(listview->contentY(), 280.); - QmlListModel model2; + QaimModel model2; for (int i = 0; i < 5; i++) model2.addItem("Item" + QString::number(i), ""); @@ -3467,7 +3456,7 @@ void tst_QQuickListView::header() QFETCH(QPointF, firstDelegatePos); QFETCH(QPointF, resizeContentPos); - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), ""); @@ -3639,7 +3628,7 @@ void tst_QQuickListView::header_delayItemCreation() { QQuickView *window = createView(); - QmlListModel model; + QaimModel model; window->rootContext()->setContextProperty("setCurrentToZero", QVariant(false)); window->setSource(testFileUrl("fillModelOnComponentCompleted.qml")); @@ -3677,7 +3666,7 @@ void tst_QQuickListView::footer() QQuickView *window = getView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 3; i++) model.addItem("Item" + QString::number(i), ""); @@ -3868,8 +3857,9 @@ void tst_QQuickListView::extents() QQuickView *window = getView(); - QmlListModel model; + QaimModel model; QQmlContext *ctxt = window->rootContext(); + ctxt->setContextProperty("testModel", &model); window->setSource(testFileUrl("headerfooter.qml")); window->show(); @@ -3995,7 +3985,7 @@ void tst_QQuickListView::resizeView() { QQuickView *window = createView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 40; i++) model.addItem("Item" + QString::number(i), ""); @@ -4075,7 +4065,7 @@ void tst_QQuickListView::resizeViewAndRepaint() { QQuickView *window = createView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 40; i++) model.addItem("Item" + QString::number(i), ""); @@ -4110,7 +4100,7 @@ void tst_QQuickListView::sizeLessThan1() { QQuickView *window = createView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), ""); @@ -4251,7 +4241,7 @@ void tst_QQuickListView::resizeFirstDelegate() QQuickView *window = createView(); // bug only occurs when all items in the model are visible - QmlListModel model; + QaimModel model; for (int i = 0; i < 10; i++) model.addItem("Item" + QString::number(i), ""); @@ -4462,7 +4452,7 @@ void tst_QQuickListView::indexAt_itemAt() QQuickView *window = getView(); - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), ""); @@ -5014,14 +5004,9 @@ void tst_QQuickListView::snapToItem() releaseView(window); } -void tst_QQuickListView::qListModelInterface_items() +void tst_QQuickListView::qAbstractItemModel_package_items() { - items<QmlListModel>(testFileUrl("listviewtest.qml"), false); -} - -void tst_QQuickListView::qListModelInterface_package_items() -{ - items<QmlListModel>(testFileUrl("listviewtest-package.qml"), true); + items<QaimModel>(testFileUrl("listviewtest-package.qml"), true); } void tst_QQuickListView::qAbstractItemModel_items() @@ -5029,14 +5014,9 @@ void tst_QQuickListView::qAbstractItemModel_items() items<QaimModel>(testFileUrl("listviewtest.qml"), false); } -void tst_QQuickListView::qListModelInterface_changed() -{ - changed<QmlListModel>(testFileUrl("listviewtest.qml"), false); -} - -void tst_QQuickListView::qListModelInterface_package_changed() +void tst_QQuickListView::qAbstractItemModel_package_changed() { - changed<QmlListModel>(testFileUrl("listviewtest-package.qml"), true); + changed<QaimModel>(testFileUrl("listviewtest-package.qml"), true); } void tst_QQuickListView::qAbstractItemModel_changed() @@ -5044,24 +5024,9 @@ void tst_QQuickListView::qAbstractItemModel_changed() changed<QaimModel>(testFileUrl("listviewtest.qml"), false); } -void tst_QQuickListView::qListModelInterface_inserted() -{ - inserted<QmlListModel>(testFileUrl("listviewtest.qml")); -} - -void tst_QQuickListView::qListModelInterface_package_inserted() +void tst_QQuickListView::qAbstractItemModel_package_inserted() { - inserted<QmlListModel>(testFileUrl("listviewtest-package.qml")); -} - -void tst_QQuickListView::qListModelInterface_inserted_more() -{ - inserted_more<QmlListModel>(); -} - -void tst_QQuickListView::qListModelInterface_inserted_more_data() -{ - inserted_more_data(); + inserted<QaimModel>(testFileUrl("listviewtest-package.qml")); } void tst_QQuickListView::qAbstractItemModel_inserted() @@ -5089,26 +5054,10 @@ void tst_QQuickListView::qAbstractItemModel_inserted_more_bottomToTop_data() inserted_more_data(); } -void tst_QQuickListView::qListModelInterface_removed() -{ - removed<QmlListModel>(testFileUrl("listviewtest.qml"), false); - removed<QmlListModel>(testFileUrl("listviewtest.qml"), true); -} - -void tst_QQuickListView::qListModelInterface_removed_more() -{ - removed_more<QmlListModel>(testFileUrl("listviewtest.qml")); -} - -void tst_QQuickListView::qListModelInterface_removed_more_data() -{ - removed_more_data(); -} - -void tst_QQuickListView::qListModelInterface_package_removed() +void tst_QQuickListView::qAbstractItemModel_package_removed() { - removed<QmlListModel>(testFileUrl("listviewtest-package.qml"), false); - removed<QmlListModel>(testFileUrl("listviewtest-package.qml"), true); + removed<QaimModel>(testFileUrl("listviewtest-package.qml"), false); + removed<QaimModel>(testFileUrl("listviewtest-package.qml"), true); } void tst_QQuickListView::qAbstractItemModel_removed() @@ -5137,22 +5086,12 @@ void tst_QQuickListView::qAbstractItemModel_removed_more_bottomToTop_data() removed_more_data(); } -void tst_QQuickListView::qListModelInterface_moved() +void tst_QQuickListView::qAbstractItemModel_package_moved() { - moved<QmlListModel>(testFileUrl("listviewtest.qml")); + moved<QaimModel>(testFileUrl("listviewtest-package.qml")); } -void tst_QQuickListView::qListModelInterface_moved_data() -{ - moved_data(); -} - -void tst_QQuickListView::qListModelInterface_package_moved() -{ - moved<QmlListModel>(testFileUrl("listviewtest-package.qml")); -} - -void tst_QQuickListView::qListModelInterface_package_moved_data() +void tst_QQuickListView::qAbstractItemModel_package_moved_data() { moved_data(); } @@ -5177,14 +5116,9 @@ void tst_QQuickListView::qAbstractItemModel_moved_bottomToTop_data() moved_data(); } -void tst_QQuickListView::qListModelInterface_clear() +void tst_QQuickListView::qAbstractItemModel_package_clear() { - clear<QmlListModel>(testFileUrl("listviewtest.qml")); -} - -void tst_QQuickListView::qListModelInterface_package_clear() -{ - clear<QmlListModel>(testFileUrl("listviewtest-package.qml")); + clear<QaimModel>(testFileUrl("listviewtest-package.qml")); } void tst_QQuickListView::qAbstractItemModel_clear() @@ -5197,14 +5131,9 @@ void tst_QQuickListView::qAbstractItemModel_clear_bottomToTop() clear<QaimModel>(testFileUrl("listviewtest.qml"), QQuickItemView::BottomToTop); } -void tst_QQuickListView::qListModelInterface_sections() -{ - sections<QmlListModel>(testFileUrl("listview-sections.qml")); -} - -void tst_QQuickListView::qListModelInterface_package_sections() +void tst_QQuickListView::qAbstractItemModel_package_sections() { - sections<QmlListModel>(testFileUrl("listview-sections-package.qml")); + sections<QaimModel>(testFileUrl("listview-sections-package.qml")); } void tst_QQuickListView::qAbstractItemModel_sections() @@ -5427,7 +5356,7 @@ void tst_QQuickListView::snapOneItem() void tst_QQuickListView::unrequestedVisibility() { - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Item" + QString::number(i), QString::number(i)); @@ -6558,7 +6487,7 @@ void tst_QQuickListView::multipleTransitions() QPointF removeTargets_transitionTo(-100, 300); QPointF removeDisplaced_transitionFrom(100, 300); - QmlListModel model; + QaimModel model; for (int i = 0; i < initialCount; i++) model.addItem("Original item" + QString::number(i), ""); @@ -6724,7 +6653,7 @@ void tst_QQuickListView::multipleDisplaced() // moved from previously set positions, and not those that have moved from their current // item positions (which may e.g. still be changing from easing bounces in the last transition) - QmlListModel model; + QaimModel model; for (int i = 0; i < 30; i++) model.addItem("Original item" + QString::number(i), ""); @@ -6853,7 +6782,7 @@ void tst_QQuickListView::flickBeyondBounds() void tst_QQuickListView::destroyItemOnCreation() { - QmlListModel model; + QaimModel model; QQuickView *window = createView(); window->rootContext()->setContextProperty("testModel", &model); diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp index 3fb20f7f5c..32ec41bb13 100644 --- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp +++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ #include <QtTest/QtTest> -#include <private/qlistmodelinterface_p.h> #include <QtQuick/qquickview.h> #include <qqmlengine.h> #include <QtQuick/private/qquickrectangle_p.h> diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp index 0fb2416808..8e58a026f9 100644 --- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp +++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp @@ -41,7 +41,6 @@ #include <QtTest/QtTest> #include <QtTest/QSignalSpy> -#include <private/qlistmodelinterface_p.h> #include <QtQml/qqmlengine.h> #include <QtQuick/qquickview.h> #include <QtQml/qqmlcontext.h> diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp index 533085bbc7..0ec7e51fee 100644 --- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp +++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp @@ -877,7 +877,7 @@ void tst_qquickvisualdatamodel::packagesDestroyed() void tst_qquickvisualdatamodel::qaimRowsMoved() { // Test parameters passed in QAIM::rowsMoved() signal are converted correctly - // when translated and emitted as the QListModelInterface::itemsMoved() signal + // when translated to (from, to count) semantics. QFETCH(int, sourceFirst); QFETCH(int, sourceLast); QFETCH(int, destinationChild); @@ -3579,7 +3579,7 @@ void tst_qquickvisualdatamodel::asynchronousInsert() QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml")); - QmlListModel model; + QaimModel model; for (int i = 0; i < 8; i++) model.addItem("Original item" + QString::number(i), ""); @@ -3644,7 +3644,7 @@ void tst_qquickvisualdatamodel::asynchronousRemove() QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml")); - QmlListModel model; + QaimModel model; for (int i = 0; i < 8; i++) model.addItem("Original item" + QString::number(i), ""); @@ -3722,7 +3722,7 @@ void tst_qquickvisualdatamodel::asynchronousMove() QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml")); - QmlListModel model; + QaimModel model; for (int i = 0; i < 8; i++) model.addItem("Original item" + QString::number(i), ""); @@ -3770,7 +3770,7 @@ void tst_qquickvisualdatamodel::asynchronousCancel() QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml")); - QmlListModel model; + QaimModel model; for (int i = 0; i < 8; i++) model.addItem("Original item" + QString::number(i), ""); diff --git a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp index 4d337564c0..53df019609 100644 --- a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp +++ b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp @@ -56,7 +56,6 @@ #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> -#include <private/qlistmodelinterface_p.h> #include "../../../../src/imports/xmllistmodel/qqmlxmllistmodel_p.h" typedef QPair<int, int> QQuickXmlListRange; @@ -106,7 +105,7 @@ private slots: void roleCrash(); private: - QString errorString(QListModelInterface* model) { + QString errorString(QAbstractItemModel *model) { QString ret; QMetaObject::invokeMethod(model, "errorString", Q_RETURN_ARG(QString, ret)); return ret; @@ -196,14 +195,15 @@ QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent void tst_qquickxmllistmodel::buildModel() { QQmlComponent component(&engine, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); + QTRY_COMPARE(model->rowCount(), 9); - QCOMPARE(model->data(3, Qt::UserRole).toString(), QLatin1String("Spot")); - QCOMPARE(model->data(3, Qt::UserRole+1).toString(), QLatin1String("Dog")); - QCOMPARE(model->data(3, Qt::UserRole+2).toInt(), 9); - QCOMPARE(model->data(3, Qt::UserRole+3).toString(), QLatin1String("Medium")); + QModelIndex index = model->index(3, 0); + QCOMPARE(model->data(index, Qt::UserRole).toString(), QLatin1String("Spot")); + QCOMPARE(model->data(index, Qt::UserRole+1).toString(), QLatin1String("Dog")); + QCOMPARE(model->data(index, Qt::UserRole+2).toInt(), 9); + QCOMPARE(model->data(index, Qt::UserRole+3).toString(), QLatin1String("Medium")); delete model; } @@ -215,25 +215,20 @@ void tst_qquickxmllistmodel::testTypes() QFETCH(QVariant, expectedValue); QQmlComponent component(&engine, testFileUrl("testtypes.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); model->setProperty("xml",xml.toUtf8()); QMetaObject::invokeMethod(model, "reload"); - QTRY_COMPARE(model->count(), 1); + QTRY_COMPARE(model->rowCount(), 1); - int role = -1; - foreach (int i, model->roles()) { - if (model->toString(i) == roleName) { - role = i; - break; - } - } + int role = model->roleNames().key(roleName.toUtf8(), -1); QVERIFY(role >= 0); + QModelIndex index = model->index(0, 0); if (expectedValue.toString() == "nan") - QVERIFY(qIsNaN(model->data(0, role).toDouble())); + QVERIFY(qIsNaN(model->data(index, role).toDouble())); else - QCOMPARE(model->data(0, role), expectedValue); + QCOMPARE(model->data(index, role), expectedValue); delete model; } @@ -275,11 +270,11 @@ void tst_qquickxmllistmodel::testTypes_data() void tst_qquickxmllistmodel::cdata() { QQmlComponent component(&engine, testFileUrl("recipes.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 5); + QTRY_COMPARE(model->rowCount(), 5); - QVERIFY(model->data(2, Qt::UserRole+2).toString().startsWith(QLatin1String("<html>"))); + QVERIFY(model->data(model->index(2, 0), Qt::UserRole+2).toString().startsWith(QLatin1String("<html>"))); delete model; } @@ -287,10 +282,10 @@ void tst_qquickxmllistmodel::cdata() void tst_qquickxmllistmodel::attributes() { QQmlComponent component(&engine, testFileUrl("recipes.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 5); - QCOMPARE(model->data(2, Qt::UserRole).toString(), QLatin1String("Vegetable Soup")); + QTRY_COMPARE(model->rowCount(), 5); + QCOMPARE(model->data(model->index(2, 0), Qt::UserRole).toString(), QLatin1String("Vegetable Soup")); delete model; } @@ -298,16 +293,23 @@ void tst_qquickxmllistmodel::attributes() void tst_qquickxmllistmodel::roles() { QQmlComponent component(&engine, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - QList<int> roles = model->roles(); + QTRY_COMPARE(model->rowCount(), 9); + + QHash<int, QByteArray> roleNames = model->roleNames(); + QCOMPARE(roleNames.count(), 4); + QVERIFY(roleNames.key("name", -1) >= 0); + QVERIFY(roleNames.key("type", -1) >= 0); + QVERIFY(roleNames.key("age", -1) >= 0); + QVERIFY(roleNames.key("size", -1) >= 0); + + QSet<int> roles; + roles.insert(roleNames.key("name")); + roles.insert(roleNames.key("type")); + roles.insert(roleNames.key("age")); + roles.insert(roleNames.key("size")); QCOMPARE(roles.count(), 4); - QCOMPARE(model->toString(roles.at(0)), QLatin1String("name")); - QCOMPARE(model->toString(roles.at(1)), QLatin1String("type")); - QCOMPARE(model->toString(roles.at(2)), QLatin1String("age")); - QCOMPARE(model->toString(roles.at(3)), QLatin1String("size")); delete model; } @@ -319,18 +321,18 @@ void tst_qquickxmllistmodel::roleErrors() QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":10:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData()); //### make sure we receive all expected warning messages. - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - + QTRY_COMPARE(model->rowCount(), 9); + QModelIndex index = model->index(3, 0); //### should any of these return valid values? - QCOMPARE(model->data(3, Qt::UserRole), QVariant()); - QCOMPARE(model->data(3, Qt::UserRole+1), QVariant()); - QCOMPARE(model->data(3, Qt::UserRole+2), QVariant()); + QCOMPARE(model->data(index, Qt::UserRole), QVariant()); + QCOMPARE(model->data(index, Qt::UserRole+1), QVariant()); + QCOMPARE(model->data(index, Qt::UserRole+2), QVariant()); QEXPECT_FAIL("", "QTBUG-10797", Continue); - QCOMPARE(model->data(3, Qt::UserRole+3), QVariant()); + QCOMPARE(model->data(index, Qt::UserRole+3), QVariant()); delete model; } @@ -339,12 +341,12 @@ void tst_qquickxmllistmodel::uniqueRoleNames() { QQmlComponent component(&engine, testFileUrl("unique.qml")); QTest::ignoreMessage(QtWarningMsg, (testFileUrl("unique.qml").toString() + ":8:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData()); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); + QTRY_COMPARE(model->rowCount(), 9); - QList<int> roles = model->roles(); - QCOMPARE(roles.count(), 1); + QHash<int, QByteArray> roleNames = model->roleNames(); + QCOMPARE(roleNames.count(), 1); delete model; } @@ -356,7 +358,7 @@ void tst_qquickxmllistmodel::xml() QFETCH(int, count); QQmlComponent component(&engine, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QSignalSpy spy(model, SIGNAL(statusChanged(QQuickXmlListModel::Status))); QVERIFY(errorString(model).isEmpty()); @@ -369,7 +371,7 @@ void tst_qquickxmllistmodel::xml() QQuickXmlListModel::Ready); QVERIFY(errorString(model).isEmpty()); QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); - QCOMPARE(model->count(), 9); + QCOMPARE(model->rowCount(), 9); // if xml is empty (i.e. clearing) it won't have any effect if a source is set if (xml.isEmpty()) @@ -387,7 +389,7 @@ void tst_qquickxmllistmodel::xml() QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")), QQuickXmlListModel::Ready); QVERIFY(errorString(model).isEmpty()); - QCOMPARE(model->count(), count); + QCOMPARE(model->rowCount(), count); delete model; } @@ -411,7 +413,7 @@ void tst_qquickxmllistmodel::headers() qmlEng.setNetworkAccessManagerFactory(&factory); QQmlComponent component(&qmlEng, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")), QQuickXmlListModel::Ready); @@ -435,7 +437,7 @@ void tst_qquickxmllistmodel::source() QFETCH(QQuickXmlListModel::Status, status); QQmlComponent component(&engine, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QSignalSpy spy(model, SIGNAL(statusChanged(QQuickXmlListModel::Status))); QVERIFY(errorString(model).isEmpty()); @@ -447,7 +449,7 @@ void tst_qquickxmllistmodel::source() QQuickXmlListModel::Ready); QVERIFY(errorString(model).isEmpty()); QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); - QCOMPARE(model->count(), 9); + QCOMPARE(model->rowCount(), 9); model->setProperty("source",source); if (model->property("source").toString().isEmpty()) @@ -474,7 +476,7 @@ void tst_qquickxmllistmodel::source() } QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")), status); - QCOMPARE(model->count(), count); + QCOMPARE(model->rowCount(), count); if (status == QQuickXmlListModel::Ready) QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); @@ -506,15 +508,16 @@ void tst_qquickxmllistmodel::source_data() void tst_qquickxmllistmodel::data() { QQmlComponent component(&engine, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); for (int i=0; i<9; i++) { - for (int j=0; j<model->roles().count(); j++) { - QCOMPARE(model->data(i, j), QVariant()); + QModelIndex index = model->index(i, 0); + for (int j=0; j<model->roleNames().count(); j++) { + QCOMPARE(model->data(index, j), QVariant()); } } - QTRY_COMPARE(model->count(), 9); + QTRY_COMPARE(model->rowCount(), 9); delete model; } @@ -522,14 +525,14 @@ void tst_qquickxmllistmodel::data() void tst_qquickxmllistmodel::get() { QQmlComponent component(&engine, testFileUrl("get.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); QVERIFY(QMetaObject::invokeMethod(model, "runPreTest")); QCOMPARE(model->property("preTest").toBool(), true); - QTRY_COMPARE(model->count(), 9); + QTRY_COMPARE(model->rowCount(), 9); QVERIFY(QMetaObject::invokeMethod(model, "runPostTest")); QCOMPARE(model->property("postTest").toBool(), true); @@ -543,12 +546,12 @@ void tst_qquickxmllistmodel::reload() // reload() is called. QQmlComponent component(&engine, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); + QTRY_COMPARE(model->rowCount(), 9); - QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyInsert(model, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy spyRemove(model, SIGNAL(rowsRemoved(QModelIndex,int,int))); QSignalSpy spyCount(model, SIGNAL(countChanged())); //reload multiple times to test the xml query aborting QMetaObject::invokeMethod(model, "reload"); @@ -556,15 +559,15 @@ void tst_qquickxmllistmodel::reload() QCoreApplication::processEvents(); QMetaObject::invokeMethod(model, "reload"); QMetaObject::invokeMethod(model, "reload"); - QTRY_COMPARE(spyCount.count(), 1); + QTRY_COMPARE(spyCount.count(), 0); QTRY_COMPARE(spyInsert.count(), 1); QTRY_COMPARE(spyRemove.count(), 1); - QCOMPARE(spyInsert[0][0].toInt(), 0); - QCOMPARE(spyInsert[0][1].toInt(), 9); + QCOMPARE(spyInsert[0][1].toInt(), 0); + QCOMPARE(spyInsert[0][2].toInt(), 8); - QCOMPARE(spyRemove[0][0].toInt(), 0); - QCOMPARE(spyRemove[0][1].toInt(), 9); + QCOMPARE(spyRemove[0][1].toInt(), 0); + QCOMPARE(spyRemove[0][2].toInt(), 8); delete model; } @@ -583,42 +586,44 @@ void tst_qquickxmllistmodel::useKeys() QFETCH(QList<QQuickXmlListRange>, removeRanges); QQmlComponent component(&engine, testFileUrl("roleKeys.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); model->setProperty("xml",oldXml); - QTRY_COMPARE(model->count(), oldCount); + QTRY_COMPARE(model->rowCount(), oldCount); - QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyInsert(model, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy spyRemove(model, SIGNAL(rowsRemoved(QModelIndex,int,int))); QSignalSpy spyCount(model, SIGNAL(countChanged())); model->setProperty("xml",newXml); if (oldCount != newData.count()) { - QTRY_COMPARE(model->count(), newData.count()); + QTRY_COMPARE(model->rowCount(), newData.count()); QCOMPARE(spyCount.count(), 1); } else { QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0); QCOMPARE(spyCount.count(), 0); } - QList<int> roles = model->roles(); - for (int i=0; i<model->count(); i++) { + QList<int> roles = model->roleNames().keys(); + qSort(roles); + for (int i=0; i<model->rowCount(); i++) { + QModelIndex index = model->index(i, 0); for (int j=0; j<roles.count(); j++) - QCOMPARE(model->data(i, roles[j]), newData[i][j]); + QCOMPARE(model->data(index, roles.at(j)), newData[i][j]); } QCOMPARE(spyInsert.count(), insertRanges.count()); for (int i=0; i<spyInsert.count(); i++) { - QCOMPARE(spyInsert[i][0].toInt(), insertRanges[i].first); - QCOMPARE(spyInsert[i][1].toInt(), insertRanges[i].second); + QCOMPARE(spyInsert[i][1].toInt(), insertRanges[i].first); + QCOMPARE(spyInsert[i][2].toInt(), insertRanges[i].first + insertRanges[i].second - 1); } QCOMPARE(spyRemove.count(), removeRanges.count()); for (int i=0; i<spyRemove.count(); i++) { - QCOMPARE(spyRemove[i][0].toInt(), removeRanges[i].first); - QCOMPARE(spyRemove[i][1].toInt(), removeRanges[i].second); + QCOMPARE(spyRemove[i][1].toInt(), removeRanges[i].first); + QCOMPARE(spyRemove[i][2].toInt(), removeRanges[i].first + removeRanges[i].second - 1); } delete model; @@ -734,33 +739,35 @@ void tst_qquickxmllistmodel::noKeysValueChanges() // since 'sport' is not marked as a key. QQmlComponent component(&engine, testFileUrl("roleKeys.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); QString xml; xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics"); model->setProperty("xml",xml); - QTRY_COMPARE(model->count(), 2); + QTRY_COMPARE(model->rowCount(), 2); model->setProperty("xml",""); - QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyInsert(model, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy spyRemove(model, SIGNAL(rowsRemoved(QModelIndex,int,int))); QSignalSpy spyCount(model, SIGNAL(countChanged())); xml = makeItemXmlAndData("name=A,age=25,sport=AussieRules;name=B,age=35,sport=Athletics"); model->setProperty("xml",xml); + QList<int> roles = model->roleNames().keys(); + qSort(roles); // wait for the new xml data to be set, and verify no signals were emitted - QTRY_VERIFY(model->data(0, model->roles()[2]).toString() != QLatin1String("Football")); - QCOMPARE(model->data(0, model->roles()[2]).toString(), QLatin1String("AussieRules")); + QTRY_VERIFY(model->data(model->index(0, 0), roles.at(2)).toString() != QLatin1String("Football")); + QCOMPARE(model->data(model->index(0, 0), roles.at(2)).toString(), QLatin1String("AussieRules")); QVERIFY(spyInsert.count() == 0); QVERIFY(spyRemove.count() == 0); QVERIFY(spyCount.count() == 0); - QCOMPARE(model->count(), 2); + QCOMPARE(model->rowCount(), 2); delete model; } @@ -772,17 +779,17 @@ void tst_qquickxmllistmodel::keysChanged() // if no keys are set). QQmlComponent component(&engine, testFileUrl("roleKeys.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics"); model->setProperty("xml",xml); - QTRY_COMPARE(model->count(), 2); + QTRY_COMPARE(model->rowCount(), 2); model->setProperty("xml",""); - QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyInsert(model, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy spyRemove(model, SIGNAL(rowsRemoved(QModelIndex,int,int))); QSignalSpy spyCount(model, SIGNAL(countChanged())); QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey")); @@ -791,12 +798,12 @@ void tst_qquickxmllistmodel::keysChanged() 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(spyInsert[0][1].toInt(), 0); + QCOMPARE(spyInsert[0][2].toInt(), 1); QCOMPARE(spyRemove.count(), 1); - QCOMPARE(spyRemove[0][0].toInt(), 0); - QCOMPARE(spyRemove[0][1].toInt(), 2); + QCOMPARE(spyRemove[0][1].toInt(), 0); + QCOMPARE(spyRemove[0][2].toInt(), 1); QCOMPARE(spyCount.count(), 0); @@ -809,11 +816,11 @@ void tst_qquickxmllistmodel::threading() QQmlComponent component(&engine, testFileUrl("roleKeys.qml")); - QListModelInterface *m1 = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *m1 = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(m1 != 0); - QListModelInterface *m2 = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *m2 = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(m2 != 0); - QListModelInterface *m3 = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *m3 = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(m3 != 0); for (int dataCount=0; dataCount<xmlDataCount; dataCount++) { @@ -847,20 +854,29 @@ void tst_qquickxmllistmodel::threading() m3->setProperty("xml",makeItemXmlAndData(data3)); QCoreApplication::processEvents(); - QTRY_VERIFY(m1->count() == dataCount && m2->count() == dataCount && m3->count() == dataCount); + QTRY_VERIFY(m1->rowCount() == dataCount && m2->rowCount() == dataCount && m3->rowCount() == dataCount); for (int i=0; i<dataCount; i++) { - QCOMPARE(m1->data(i, m1->roles()[0]).toString(), QString("A" + QString::number(i))); - QCOMPARE(m1->data(i, m1->roles()[1]).toString(), QString("1" + QString::number(i))); - QCOMPARE(m1->data(i, m1->roles()[2]).toString(), QString("Football")); - - QCOMPARE(m2->data(i, m2->roles()[0]).toString(), QString("B" + QString::number(i))); - QCOMPARE(m2->data(i, m2->roles()[1]).toString(), QString("2" + QString::number(i))); - QCOMPARE(m2->data(i, m2->roles()[2]).toString(), QString("Athletics")); - - QCOMPARE(m3->data(i, m3->roles()[0]).toString(), QString("C" + QString::number(i))); - QCOMPARE(m3->data(i, m3->roles()[1]).toString(), QString("3" + QString::number(i))); - QCOMPARE(m3->data(i, m3->roles()[2]).toString(), QString("Curling")); + QModelIndex index = m1->index(i, 0); + QList<int> roles = m1->roleNames().keys(); + qSort(roles); + QCOMPARE(m1->data(index, roles.at(0)).toString(), QString("A" + QString::number(i))); + QCOMPARE(m1->data(index, roles.at(1)).toString(), QString("1" + QString::number(i))); + QCOMPARE(m1->data(index, roles.at(2)).toString(), QString("Football")); + + index = m2->index(i, 0); + roles = m2->roleNames().keys(); + qSort(roles); + QCOMPARE(m2->data(index, roles.at(0)).toString(), QString("B" + QString::number(i))); + QCOMPARE(m2->data(index, roles.at(1)).toString(), QString("2" + QString::number(i))); + QCOMPARE(m2->data(index, roles.at(2)).toString(), QString("Athletics")); + + index = m3->index(i, 0); + roles = m3->roleNames().keys(); + qSort(roles); + QCOMPARE(m3->data(index, roles.at(0)).toString(), QString("C" + QString::number(i))); + QCOMPARE(m3->data(index, roles.at(1)).toString(), QString("3" + QString::number(i))); + QCOMPARE(m3->data(index, roles.at(2)).toString(), QString("Curling")); } } @@ -881,9 +897,9 @@ void tst_qquickxmllistmodel::threading_data() void tst_qquickxmllistmodel::propertyChanges() { QQmlComponent component(&engine, testFileUrl("propertychanges.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel*>(component.create()); QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); + QTRY_COMPARE(model->rowCount(), 9); QObject *role = model->findChild<QObject*>("role"); QVERIFY(role); @@ -927,7 +943,7 @@ void tst_qquickxmllistmodel::propertyChanges() QCOMPARE(model->property("query").toString(), QString("/Pets")); QCOMPARE(model->property("namespaceDeclarations").toString(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";")); - QTRY_VERIFY(model->count() == 1); + QTRY_VERIFY(model->rowCount() == 1); QCOMPARE(sourceSpy.count(),1); QCOMPARE(xmlSpy.count(),1); @@ -944,7 +960,7 @@ void tst_qquickxmllistmodel::propertyChanges() QCOMPARE(modelQuerySpy.count(),1); QCOMPARE(namespaceDeclarationsSpy.count(),1); - QTRY_VERIFY(model->count() == 1); + QTRY_VERIFY(model->rowCount() == 1); delete model; } @@ -952,7 +968,7 @@ void tst_qquickxmllistmodel::roleCrash() { // don't crash QQmlComponent component(&engine, testFileUrl("roleCrash.qml")); - QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); QVERIFY(model != 0); delete model; } diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index f68ca1fd33..63da97b4f8 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -141,148 +141,6 @@ QList<int> QQuickViewTestUtil::adjustIndexesForRemoveDisplaced(const QList<int> return result; } - -QQuickViewTestUtil::QmlListModel::QmlListModel(QObject *parent) - : QListModelInterface(parent) -{ -} - -QQuickViewTestUtil::QmlListModel::~QmlListModel() -{ -} - -QString QQuickViewTestUtil::QmlListModel::name(int index) const -{ - return list.at(index).first; -} - -QString QQuickViewTestUtil::QmlListModel::number(int index) const -{ - return list.at(index).second; -} - -int QQuickViewTestUtil::QmlListModel::count() const -{ - return list.count(); -} - -QList<int> QQuickViewTestUtil::QmlListModel::roles() const -{ - return QList<int>() << Name << Number; -} - -QString QQuickViewTestUtil::QmlListModel::toString(int role) const -{ - switch (role) { - case Name: - return "name"; - case Number: - return "number"; - default: - return ""; - } -} - -QVariant QQuickViewTestUtil::QmlListModel::data(int index, int role) const -{ - if (role==0) - return list.at(index).first; - if (role==1) - return list.at(index).second; - return QVariant(); -} - -QHash<int, QVariant> QQuickViewTestUtil::QmlListModel::data(int index, const QList<int> &roles) const -{ - QHash<int,QVariant> returnHash; - - for (int i = 0; i < roles.size(); ++i) { - int role = roles.at(i); - QVariant info; - switch (role) { - case Name: - info = list.at(index).first; - break; - case Number: - info = list.at(index).second; - break; - default: - break; - } - returnHash.insert(role, info); - } - return returnHash; -} - -void QQuickViewTestUtil::QmlListModel::addItem(const QString &name, const QString &number) -{ - list.append(QPair<QString,QString>(name, number)); - emit itemsInserted(list.count()-1, 1); -} - -void QQuickViewTestUtil::QmlListModel::insertItem(int index, const QString &name, const QString &number) -{ - list.insert(index, QPair<QString,QString>(name, number)); - emit itemsInserted(index, 1); -} - -void QQuickViewTestUtil::QmlListModel::insertItems(int index, const QList<QPair<QString, QString> > &items) -{ - for (int i=0; i<items.count(); i++) - list.insert(index + i, QPair<QString,QString>(items[i].first, items[i].second)); - emit itemsInserted(index, items.count()); -} - -void QQuickViewTestUtil::QmlListModel::removeItem(int index) -{ - list.removeAt(index); - emit itemsRemoved(index, 1); -} - -void QQuickViewTestUtil::QmlListModel::removeItems(int index, int count) -{ - int c = count; - while (c--) - list.removeAt(index); - emit itemsRemoved(index, count); -} - -void QQuickViewTestUtil::QmlListModel::moveItem(int from, int to) -{ - list.move(from, to); - emit itemsMoved(from, to, 1); -} - -void QQuickViewTestUtil::QmlListModel::moveItems(int from, int to, int count) -{ - qquickmodelviewstestutil_move(from, to, count, &list); - emit itemsMoved(from, to, count); -} - -void QQuickViewTestUtil::QmlListModel::modifyItem(int index, const QString &name, const QString &number) -{ - list[index] = QPair<QString,QString>(name, number); - emit itemsChanged(index, 1, roles()); -} - -void QQuickViewTestUtil::QmlListModel::clear() { - int count = list.count(); - list.clear(); - emit itemsRemoved(0, count); -} - -void QQuickViewTestUtil::QmlListModel::matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2) { - for (int i=0; i<other.count(); i++) { - QVERIFY2(list.contains(other[i]), - QTest::toString(other[i].first + " " + other[i].second + " " + error1)); - } - for (int i=0; i<list.count(); i++) { - QVERIFY2(other.contains(list[i]), - QTest::toString(list[i].first + " " + list[i].second + " " + error2)); - } -} - - QQuickViewTestUtil::QaimModel::QaimModel(QObject *parent) : QAbstractListModel(parent) { @@ -392,9 +250,11 @@ void QQuickViewTestUtil::QaimModel::modifyItem(int idx, const QString &name, con void QQuickViewTestUtil::QaimModel::clear() { int count = list.count(); - emit beginRemoveRows(QModelIndex(), 0, count-1); - list.clear(); - emit endRemoveRows(); + if (count > 0) { + beginRemoveRows(QModelIndex(), 0, count-1); + list.clear(); + endRemoveRows(); + } } void QQuickViewTestUtil::QaimModel::reset() @@ -474,16 +334,6 @@ int QQuickViewTestUtil::ListRange::count() const return indexes.count(); } -QList<QPair<QString,QString> > QQuickViewTestUtil::ListRange::getModelDataValues(const QmlListModel &model) -{ - QList<QPair<QString,QString> > data; - if (!valid) - return data; - for (int i=0; i<indexes.count(); i++) - data.append(qMakePair(model.name(indexes[i]), model.number(indexes[i]))); - return data; -} - QList<QPair<QString,QString> > QQuickViewTestUtil::ListRange::getModelDataValues(const QaimModel &model) { QList<QPair<QString,QString> > data; diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h index 3108030406..771be0a890 100644 --- a/tests/auto/quick/shared/viewtestutil.h +++ b/tests/auto/quick/shared/viewtestutil.h @@ -44,7 +44,6 @@ #include <QtQuick/QQuickItem> #include <QtQml/QQmlExpression> -#include <QtQml/private/qlistmodelinterface_p.h> #include <QtCore/QAbstractListModel> QT_FORWARD_DECLARE_CLASS(QQuickView) @@ -74,46 +73,6 @@ namespace QQuickViewTestUtil static ListChange polish() { ListChange c = { Polish, -1, -1, -1, 0.0 }; return c; } }; - class QmlListModel : public QListModelInterface - { - Q_OBJECT - public: - QmlListModel(QObject *parent = 0); - ~QmlListModel(); - - enum Roles { Name, Number }; - - QString name(int index) const; - QString number(int index) const; - - int count() const; - - QList<int> roles() const; - QString toString(int role) const; - - QVariant data(int index, int role) const; - QHash<int, QVariant> data(int index, const QList<int> &roles) const; - - Q_INVOKABLE void addItem(const QString &name, const QString &number); - void insertItem(int index, const QString &name, const QString &number); - void insertItems(int index, const QList<QPair<QString, QString> > &items); - - Q_INVOKABLE void removeItem(int index); - Q_INVOKABLE void removeItems(int index, int count); - - void moveItem(int from, int to); - void moveItems(int from, int to, int count); - - void modifyItem(int index, const QString &name, const QString &number); - - void clear(); - - void matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2); - - private: - QList<QPair<QString,QString> > list; - }; - class QaimModel : public QAbstractListModel { Q_OBJECT @@ -134,7 +93,7 @@ namespace QQuickViewTestUtil void insertItem(int index, const QString &name, const QString &number); void insertItems(int index, const QList<QPair<QString, QString> > &items); - void removeItem(int index); + Q_INVOKABLE void removeItem(int index); void removeItems(int index, int count); void moveItem(int from, int to); @@ -168,7 +127,6 @@ namespace QQuickViewTestUtil bool isValid() const; int count() const; - QList<QPair<QString,QString> > getModelDataValues(const QmlListModel &model); QList<QPair<QString,QString> > getModelDataValues(const QaimModel &model); QList<int> indexes; |