diff options
author | Keith Gardner <kreios4004@gmail.com> | 2014-04-22 21:31:47 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-08 04:22:54 +0200 |
commit | 43f52f93b558cb1c095d445c41c8be3e84ca81c3 (patch) | |
tree | 174459d806369e4bd7854e62b50a750233d318de /tests/auto/corelib/itemmodels | |
parent | fe70367fe06984d1ac84cc276ca3fd3edc4193c7 (diff) |
Updated corelib's unit tests to use QSignalSpy's functor constructor
The intent is to provide compile time validation of signals and to help
detect signal overloading in the future.
Change-Id: I9d5d46ed4b70c5d0cd407deb5928b1e76d37e007
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'tests/auto/corelib/itemmodels')
5 files changed, 130 insertions, 126 deletions
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index 2d2ae14fb8..0503371714 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -158,6 +158,8 @@ public: QVector<QVector<QString> > table; }; +Q_DECLARE_METATYPE(QAbstractItemModel::LayoutChangeHint); + QtTestModel::QtTestModel(int rows, int columns, QObject *parent) : QAbstractItemModel(parent), cCount(columns), rCount(rows), wrongIndex(false) { @@ -353,6 +355,8 @@ void tst_QAbstractItemModel::init() insertCommand->setStartRow(0); insertCommand->setEndRow(9); insertCommand->doCommand(); + + qRegisterMetaType<QAbstractItemModel::LayoutChangeHint>(); } void tst_QAbstractItemModel::cleanup() @@ -807,8 +811,8 @@ void tst_QAbstractItemModel::removeRows() { QtTestModel model(10, 10); - QSignalSpy rowsAboutToBeRemovedSpy(&model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy rowsRemovedSpy(&model, SIGNAL(rowsRemoved(QModelIndex,int,int))); + QSignalSpy rowsAboutToBeRemovedSpy(&model, &QtTestModel::rowsAboutToBeRemoved); + QSignalSpy rowsRemovedSpy(&model, &QtTestModel::rowsRemoved); QVERIFY(rowsAboutToBeRemovedSpy.isValid()); QVERIFY(rowsRemovedSpy.isValid()); @@ -822,8 +826,8 @@ void tst_QAbstractItemModel::removeColumns() { QtTestModel model(10, 10); - QSignalSpy columnsAboutToBeRemovedSpy(&model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy columnsRemovedSpy(&model, SIGNAL(columnsRemoved(QModelIndex,int,int))); + QSignalSpy columnsAboutToBeRemovedSpy(&model, &QtTestModel::columnsAboutToBeRemoved); + QSignalSpy columnsRemovedSpy(&model, &QtTestModel::columnsRemoved); QVERIFY(columnsAboutToBeRemovedSpy.isValid()); QVERIFY(columnsRemovedSpy.isValid()); @@ -837,8 +841,8 @@ void tst_QAbstractItemModel::insertRows() { QtTestModel model(10, 10); - QSignalSpy rowsAboutToBeInsertedSpy(&model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy rowsInsertedSpy(&model, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy rowsAboutToBeInsertedSpy(&model, &QtTestModel::rowsAboutToBeInserted); + QSignalSpy rowsInsertedSpy(&model, &QtTestModel::rowsInserted); QVERIFY(rowsAboutToBeInsertedSpy.isValid()); QVERIFY(rowsInsertedSpy.isValid()); @@ -852,8 +856,8 @@ void tst_QAbstractItemModel::insertColumns() { QtTestModel model(10, 10); - QSignalSpy columnsAboutToBeInsertedSpy(&model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy columnsInsertedSpy(&model, SIGNAL(columnsInserted(QModelIndex,int,int))); + QSignalSpy columnsAboutToBeInsertedSpy(&model, &QtTestModel::columnsAboutToBeInserted); + QSignalSpy columnsInsertedSpy(&model, &QtTestModel::columnsInserted); QVERIFY(columnsAboutToBeInsertedSpy.isValid()); QVERIFY(columnsInsertedSpy.isValid()); @@ -867,8 +871,8 @@ void tst_QAbstractItemModel::moveRows() { QtTestModel model(10, 10); - QSignalSpy rowsAboutToBeMovedSpy(&model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy rowsMovedSpy(&model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy rowsAboutToBeMovedSpy(&model, &QtTestModel::rowsAboutToBeMoved); + QSignalSpy rowsMovedSpy(&model, &QtTestModel::rowsMoved); QVERIFY(rowsAboutToBeMovedSpy.isValid()); QVERIFY(rowsMovedSpy.isValid()); @@ -882,8 +886,8 @@ void tst_QAbstractItemModel::moveColumns() { QtTestModel model(10, 10); - QSignalSpy columnsAboutToBeMovedSpy(&model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy columnsMovedSpy(&model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy columnsAboutToBeMovedSpy(&model, &QtTestModel::columnsAboutToBeMoved); + QSignalSpy columnsMovedSpy(&model, &QtTestModel::columnsMoved); QVERIFY(columnsAboutToBeMovedSpy.isValid()); QVERIFY(columnsMovedSpy.isValid()); @@ -901,7 +905,7 @@ void tst_QAbstractItemModel::reset() { QtTestModel model(10, 10); - QSignalSpy resetSpy(&model, SIGNAL(modelReset())); + QSignalSpy resetSpy(&model, &QtTestModel::modelReset); QVERIFY(resetSpy.isValid()); model.reset(); QCOMPARE(resetSpy.count(), 1); @@ -1023,8 +1027,8 @@ void tst_QAbstractItemModel::testMoveSameParentDown() } } - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1138,8 +1142,8 @@ void tst_QAbstractItemModel::testMoveSameParentUp() } } - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1287,8 +1291,8 @@ void tst_QAbstractItemModel::testMoveToGrandParent() } } - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1427,8 +1431,8 @@ void tst_QAbstractItemModel::testMoveToSibling() persistentList << QPersistentModelIndex(idx); } - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1577,8 +1581,8 @@ void tst_QAbstractItemModel::testMoveToUncle() persistentList << QPersistentModelIndex(idx); } - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1684,8 +1688,8 @@ void tst_QAbstractItemModel::testMoveToDescendants() persistentList << QPersistentModelIndex(idx); } - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1748,8 +1752,8 @@ void tst_QAbstractItemModel::testMoveWithinOwnRange() QFETCH(int, endRow); QFETCH(int, destRow); - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1841,8 +1845,8 @@ void ListenerObject::slotReset() void tst_QAbstractItemModel::testReset() { - QSignalSpy beforeResetSpy(m_model, SIGNAL(modelAboutToBeReset())); - QSignalSpy afterResetSpy(m_model, SIGNAL(modelReset())); + QSignalSpy beforeResetSpy(m_model, &DynamicTreeModel::modelAboutToBeReset); + QSignalSpy afterResetSpy(m_model, &DynamicTreeModel::modelReset); QVERIFY(beforeResetSpy.isValid()); QVERIFY(afterResetSpy.isValid()); @@ -1874,8 +1878,8 @@ void tst_QAbstractItemModel::testReset() // Delete it because its slots test things which are not true after this point. delete listener; - QSignalSpy proxyBeforeResetSpy(nullProxy, SIGNAL(modelAboutToBeReset())); - QSignalSpy proxyAfterResetSpy(nullProxy, SIGNAL(modelReset())); + QSignalSpy proxyBeforeResetSpy(nullProxy, &QSortFilterProxyModel::modelAboutToBeReset); + QSignalSpy proxyAfterResetSpy(nullProxy, &QSortFilterProxyModel::modelReset); // Before setting it, it does not have custom roles. QCOMPARE(nullProxy->roleNames().value(Qt::UserRole + 1), QByteArray()); @@ -1925,8 +1929,8 @@ void tst_QAbstractItemModel::testDataChanged() { CustomRoleModel model; - QSignalSpy withRoles(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); - QSignalSpy withoutRoles(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + QSignalSpy withRoles(&model, &CustomRoleModel::dataChanged); + QSignalSpy withoutRoles(&model, &CustomRoleModel::dataChanged); QVERIFY(withRoles.isValid()); QVERIFY(withoutRoles.isValid()); @@ -2027,8 +2031,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged() QCOMPARE(model.rowCount(p1), 10); QCOMPARE(model.rowCount(p2), 10); - QSignalSpy beforeSpy(&model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy afterSpy(&model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy beforeSpy(&model, &DynamicTreeModel::layoutAboutToBeChanged); + QSignalSpy afterSpy(&model, &DynamicTreeModel::layoutChanged); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -2043,8 +2047,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged() const QVariantList beforeSignal = beforeSpy.first(); const QVariantList afterSignal = afterSpy.first(); - QCOMPARE(beforeSignal.size(), 1); - QCOMPARE(afterSignal.size(), 1); + QCOMPARE(beforeSignal.size(), 2); + QCOMPARE(afterSignal.size(), 2); const QList<QPersistentModelIndex> beforeParents = beforeSignal.first().value<QList<QPersistentModelIndex> >(); QCOMPARE(beforeParents.size(), 2); @@ -2093,8 +2097,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged() const QPersistentModelIndex p2FirstPersistent = model.index(0, 0, p2); const QPersistentModelIndex p2LastPersistent = model.index(9, 0, p2); - QSignalSpy beforeSpy(&model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy afterSpy(&model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy beforeSpy(&model, &DynamicTreeModel::layoutAboutToBeChanged); + QSignalSpy afterSpy(&model, &DynamicTreeModel::layoutChanged); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -2116,8 +2120,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged() const QVariantList beforeSignal = beforeSpy.first(); const QVariantList afterSignal = afterSpy.first(); - QCOMPARE(beforeSignal.size(), 1); - QCOMPARE(afterSignal.size(), 1); + QCOMPARE(beforeSignal.size(), 2); + QCOMPARE(afterSignal.size(), 2); QVERIFY(p1FirstPersistent.row() == 1); QVERIFY(p1LastPersistent.row() == 0); diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index ea0a14c18c..5d21509c86 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -163,10 +163,10 @@ void tst_QIdentityProxyModel::insertRows() verifyIdentity(m_model); - QSignalSpy modelBeforeSpy(m_model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy modelAfterSpy(m_model, SIGNAL(rowsInserted(QModelIndex,int,int))); - QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy modelBeforeSpy(m_model, &QStandardItemModel::rowsAboutToBeInserted); + QSignalSpy modelAfterSpy(m_model, &QStandardItemModel::rowsInserted); + QSignalSpy proxyBeforeSpy(m_proxy, &QStandardItemModel::rowsAboutToBeInserted); + QSignalSpy proxyAfterSpy(m_proxy, &QStandardItemModel::rowsInserted); QVERIFY(modelBeforeSpy.isValid()); QVERIFY(modelAfterSpy.isValid()); @@ -203,10 +203,10 @@ void tst_QIdentityProxyModel::removeRows() verifyIdentity(m_model); - QSignalSpy modelBeforeSpy(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy modelAfterSpy(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsRemoved(QModelIndex,int,int))); + QSignalSpy modelBeforeSpy(m_model, &QStandardItemModel::rowsAboutToBeRemoved); + QSignalSpy modelAfterSpy(m_model, &QStandardItemModel::rowsRemoved); + QSignalSpy proxyBeforeSpy(m_proxy, &QStandardItemModel::rowsAboutToBeRemoved); + QSignalSpy proxyAfterSpy(m_proxy, &QStandardItemModel::rowsRemoved); QVERIFY(modelBeforeSpy.isValid()); QVERIFY(modelAfterSpy.isValid()); @@ -257,10 +257,10 @@ void tst_QIdentityProxyModel::moveRows() verifyIdentity(&model); - QSignalSpy modelBeforeSpy(&model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy modelAfterSpy(&model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy modelBeforeSpy(&model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy modelAfterSpy(&model, &DynamicTreeModel::rowsMoved); + QSignalSpy proxyBeforeSpy(m_proxy, &QIdentityProxyModel::rowsAboutToBeMoved); + QSignalSpy proxyAfterSpy(m_proxy, &QIdentityProxyModel::rowsMoved); QVERIFY(modelBeforeSpy.isValid()); QVERIFY(modelAfterSpy.isValid()); @@ -318,10 +318,10 @@ void tst_QIdentityProxyModel::reset() verifyIdentity(&model); - QSignalSpy modelBeforeSpy(&model, SIGNAL(modelAboutToBeReset())); - QSignalSpy modelAfterSpy(&model, SIGNAL(modelReset())); - QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(modelAboutToBeReset())); - QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(modelReset())); + QSignalSpy modelBeforeSpy(&model, &DynamicTreeModel::modelAboutToBeReset); + QSignalSpy modelAfterSpy(&model, &DynamicTreeModel::modelReset); + QSignalSpy proxyBeforeSpy(m_proxy, &QIdentityProxyModel::modelAboutToBeReset); + QSignalSpy proxyAfterSpy(m_proxy, &QIdentityProxyModel::modelReset); QVERIFY(modelBeforeSpy.isValid()); QVERIFY(modelAfterSpy.isValid()); @@ -351,8 +351,8 @@ void tst_QIdentityProxyModel::dataChanged() verifyIdentity(&model); - QSignalSpy modelSpy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); - QSignalSpy proxySpy(m_proxy, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); + QSignalSpy modelSpy(&model, &DataChangedModel::dataChanged); + QSignalSpy proxySpy(m_proxy, &QIdentityProxyModel::dataChanged); QVERIFY(modelSpy.isValid()); QVERIFY(proxySpy.isValid()); diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp index 30434bfd56..df4d8d0916 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp @@ -608,7 +608,7 @@ void tst_QItemModel::setData() QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); QVERIFY(currentModel); - QSignalSpy spy(currentModel, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + QSignalSpy spy(currentModel, &QAbstractItemModel::dataChanged); QVERIFY(spy.isValid()); QCOMPARE(currentModel->setData(QModelIndex(), QVariant()), false); QCOMPARE(spy.count(), 0); @@ -670,7 +670,7 @@ void tst_QItemModel::setHeaderData() QVERIFY(index.isValid()); qRegisterMetaType<Qt::Orientation>("Qt::Orientation"); - QSignalSpy spy(currentModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int))); + QSignalSpy spy(currentModel, &QAbstractItemModel::headerDataChanged); QVERIFY(spy.isValid()); QString text = "Index private pointers should always be the same"; @@ -711,7 +711,7 @@ void tst_QItemModel::sort() QVERIFY(currentModel->hasChildren(topIndex)); QModelIndex index = currentModel->index(0, 0, topIndex); QVERIFY(index.isValid()); - QSignalSpy spy(currentModel, SIGNAL(layoutChanged())); + QSignalSpy spy(currentModel, &QAbstractItemModel::layoutChanged); QVERIFY(spy.isValid()); for (int i=-1; i < 10; ++i){ currentModel->sort(i); @@ -849,12 +849,12 @@ void tst_QItemModel::remove() // When a row or column is removed there should be two signals. // Watch to make sure they are emitted and get the row/column count when they do get emitted by connecting them to a slot - QSignalSpy columnsAboutToBeRemovedSpy(currentModel, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy rowsAboutToBeRemovedSpy(currentModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy columnsRemovedSpy(currentModel, SIGNAL(columnsRemoved(QModelIndex,int,int))); - QSignalSpy rowsRemovedSpy(currentModel, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy modelResetSpy(currentModel, SIGNAL(modelReset())); - QSignalSpy modelLayoutChangedSpy(currentModel, SIGNAL(layoutChanged())); + QSignalSpy columnsAboutToBeRemovedSpy(currentModel, &QAbstractItemModel::columnsAboutToBeRemoved); + QSignalSpy rowsAboutToBeRemovedSpy(currentModel, &QAbstractItemModel::rowsAboutToBeRemoved); + QSignalSpy columnsRemovedSpy(currentModel, &QAbstractItemModel::columnsRemoved); + QSignalSpy rowsRemovedSpy(currentModel, &QAbstractItemModel::rowsRemoved); + QSignalSpy modelResetSpy(currentModel, &QAbstractItemModel::modelReset); + QSignalSpy modelLayoutChangedSpy(currentModel, &QAbstractItemModel::layoutChanged); QVERIFY(columnsAboutToBeRemovedSpy.isValid()); QVERIFY(rowsAboutToBeRemovedSpy.isValid()); @@ -1191,12 +1191,12 @@ void tst_QItemModel::insert() // When a row or column is inserted there should be two signals. // Watch to make sure they are emitted and get the row/column count when they do get emitted by connecting them to a slot - QSignalSpy columnsAboutToBeInsertedSpy(currentModel, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy rowsAboutToBeInsertedSpy(currentModel, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy columnsInsertedSpy(currentModel, SIGNAL(columnsInserted(QModelIndex,int,int))); - QSignalSpy rowsInsertedSpy(currentModel, SIGNAL(rowsInserted(QModelIndex,int,int))); - QSignalSpy modelResetSpy(currentModel, SIGNAL(modelReset())); - QSignalSpy modelLayoutChangedSpy(currentModel, SIGNAL(layoutChanged())); + QSignalSpy columnsAboutToBeInsertedSpy(currentModel, &QAbstractItemModel::columnsAboutToBeInserted); + QSignalSpy rowsAboutToBeInsertedSpy(currentModel, &QAbstractItemModel::rowsAboutToBeInserted); + QSignalSpy columnsInsertedSpy(currentModel, &QAbstractItemModel::columnsInserted); + QSignalSpy rowsInsertedSpy(currentModel, &QAbstractItemModel::rowsInserted); + QSignalSpy modelResetSpy(currentModel, &QAbstractItemModel::modelReset); + QSignalSpy modelLayoutChangedSpy(currentModel, &QAbstractItemModel::layoutChanged); QVERIFY(columnsAboutToBeInsertedSpy.isValid()); QVERIFY(rowsAboutToBeInsertedSpy.isValid()); diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index 9e3457a25a..a4e219a040 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -1529,7 +1529,7 @@ void tst_QItemSelectionModel::resetModel() MyStandardItemModel model(20, 20); QItemSelectionModel *selectionModel = new QItemSelectionModel(&model); - QSignalSpy spy(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection))); + QSignalSpy spy(selectionModel, &QItemSelectionModel::selectionChanged); QVERIFY(spy.isValid()); selectionModel->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select); @@ -1592,7 +1592,7 @@ void tst_QItemSelectionModel::removeRows() MyStandardItemModel model(rowCount, columnCount); QItemSelectionModel selections(&model); - QSignalSpy spy(&selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection))); + QSignalSpy spy(&selections, &QItemSelectionModel::selectionChanged); QVERIFY(spy.isValid()); QModelIndex tl = model.index(selectTop, selectLeft); @@ -1655,7 +1655,7 @@ void tst_QItemSelectionModel::removeColumns() MyStandardItemModel model(rowCount, columnCount); QItemSelectionModel selections(&model); - QSignalSpy spy(&selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection))); + QSignalSpy spy(&selections, &QItemSelectionModel::selectionChanged); QVERIFY(spy.isValid()); QModelIndex tl = model.index(selectTop, selectLeft); @@ -1914,12 +1914,9 @@ void tst_QItemSelectionModel::setCurrentIndex() treemodel->index(0, 0, treemodel->index(0, 0)), QItemSelectionModel::SelectCurrent); - QSignalSpy currentSpy(&selectionModel, - SIGNAL(currentChanged(QModelIndex,QModelIndex))); - QSignalSpy rowSpy(&selectionModel, - SIGNAL(currentRowChanged(QModelIndex,QModelIndex))); - QSignalSpy columnSpy(&selectionModel, - SIGNAL(currentColumnChanged(QModelIndex,QModelIndex))); + QSignalSpy currentSpy(&selectionModel, &QItemSelectionModel::currentChanged); + QSignalSpy rowSpy(&selectionModel, &QItemSelectionModel::currentRowChanged); + QSignalSpy columnSpy(&selectionModel, &QItemSelectionModel::currentColumnChanged); QVERIFY(currentSpy.isValid()); QVERIFY(rowSpy.isValid()); @@ -2223,7 +2220,7 @@ void tst_QItemSelectionModel::childrenDeselectionSignal() QItemSelectionModel selectionModel(&model); selectionModel.select(sel, QItemSelectionModel::SelectCurrent); - QSignalSpy deselectSpy(&selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection))); + QSignalSpy deselectSpy(&selectionModel, &QItemSelectionModel::selectionChanged); QVERIFY(deselectSpy.isValid()); model.removeRows(0, 1, root); QVERIFY(deselectSpy.count() == 1); @@ -2406,7 +2403,7 @@ void tst_QItemSelectionModel::deselectRemovedMiddleRange() RemovalObserver ro(&selModel); - QSignalSpy spy(&selModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection))); + QSignalSpy spy(&selModel, &QItemSelectionModel::selectionChanged); QVERIFY(spy.isValid()); bool ok = model.removeRows(4, 2); @@ -2738,7 +2735,7 @@ void tst_QItemSelectionModel::testClearCurrentIndex() QItemSelectionModel selectionModel(&model, 0); - QSignalSpy currentIndexSpy(&selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex))); + QSignalSpy currentIndexSpy(&selectionModel, &QItemSelectionModel::currentChanged); QVERIFY(currentIndexSpy.isValid()); QModelIndex firstIndex = model.index(0, 0); diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 0f72b419a0..72c7246ca9 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -159,6 +159,8 @@ private: QSortFilterProxyModel *m_proxy; }; +Q_DECLARE_METATYPE(QAbstractItemModel::LayoutChangeHint) + // Testing get/set functions void tst_QSortFilterProxyModel::getSetCheck() { @@ -177,6 +179,7 @@ void tst_QSortFilterProxyModel::getSetCheck() tst_QSortFilterProxyModel::tst_QSortFilterProxyModel() : m_model(0), m_proxy(0) { + qRegisterMetaType<QAbstractItemModel::LayoutChangeHint>(); } void tst_QSortFilterProxyModel::initTestCase() @@ -1472,7 +1475,7 @@ void tst_QSortFilterProxyModel::filterCurrent() view.show(); view.setModel(&proxy); - QSignalSpy spy(view.selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex))); + QSignalSpy spy(view.selectionModel(), &QItemSelectionModel::currentChanged); QVERIFY(spy.isValid()); view.setCurrentIndex(proxy.index(0, 0)); @@ -1620,10 +1623,10 @@ void tst_QSortFilterProxyModel::removeSourceRows() proxy.sort(0, static_cast<Qt::SortOrder>(sortOrder)); (void)proxy.rowCount(QModelIndex()); // force mapping - QSignalSpy removeSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy insertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); - QSignalSpy aboutToRemoveSpy(&proxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy aboutToInsertSpy(&proxy, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); + QSignalSpy removeSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); + QSignalSpy insertSpy(&proxy, &QSortFilterProxyModel::rowsInserted); + QSignalSpy aboutToRemoveSpy(&proxy, &QSortFilterProxyModel::rowsAboutToBeRemoved); + QSignalSpy aboutToInsertSpy(&proxy, &QSortFilterProxyModel::rowsAboutToBeInserted); QVERIFY(removeSpy.isValid()); QVERIFY(insertSpy.isValid()); @@ -1801,8 +1804,8 @@ void tst_QSortFilterProxyModel::changeFilter() proxy.sort(0, static_cast<Qt::SortOrder>(sortOrder)); (void)proxy.rowCount(QModelIndex()); // force mapping - QSignalSpy initialRemoveSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy initialInsertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy initialRemoveSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); + QSignalSpy initialInsertSpy(&proxy, &QSortFilterProxyModel::rowsInserted); QVERIFY(initialRemoveSpy.isValid()); QVERIFY(initialInsertSpy.isValid()); @@ -1825,8 +1828,8 @@ void tst_QSortFilterProxyModel::changeFilter() QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), initialProxyItems.at(i)); } - QSignalSpy finalRemoveSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy finalInsertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy finalRemoveSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); + QSignalSpy finalInsertSpy(&proxy, &QSortFilterProxyModel::rowsInserted); QVERIFY(finalRemoveSpy.isValid()); QVERIFY(finalInsertSpy.isValid()); @@ -1976,8 +1979,8 @@ void tst_QSortFilterProxyModel::changeSourceData() proxy.setFilterRegExp(filter); - QSignalSpy removeSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy insertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy removeSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); + QSignalSpy insertSpy(&proxy, &QSortFilterProxyModel::rowsInserted); QVERIFY(removeSpy.isValid()); QVERIFY(insertSpy.isValid()); @@ -2075,7 +2078,7 @@ void tst_QSortFilterProxyModel::selectionFilteredOut() view.show(); view.setModel(&proxy); - QSignalSpy spy(view.selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex))); + QSignalSpy spy(view.selectionModel(), &QItemSelectionModel::currentChanged); QVERIFY(spy.isValid()); view.setCurrentIndex(proxy.index(0, 0)); @@ -2190,8 +2193,8 @@ void tst_QSortFilterProxyModel::insertIntoChildrenlessItem() QSortFilterProxyModel proxy; proxy.setSourceModel(&model); - QSignalSpy colsInsertedSpy(&proxy, SIGNAL(columnsInserted(QModelIndex,int,int))); - QSignalSpy rowsInsertedSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy colsInsertedSpy(&proxy, &QSortFilterProxyModel::columnsInserted); + QSignalSpy rowsInsertedSpy(&proxy, &QSortFilterProxyModel::rowsInserted); QVERIFY(colsInsertedSpy.isValid()); QVERIFY(rowsInsertedSpy.isValid()); @@ -2270,7 +2273,7 @@ void tst_QSortFilterProxyModel::insertRowIntoFilteredParent() EvenOddFilterModel proxy; proxy.setSourceModel(&model); - QSignalSpy spy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy spy(&proxy, &EvenOddFilterModel::rowsInserted); QVERIFY(spy.isValid()); QStandardItem *itemA = new QStandardItem(); @@ -2299,8 +2302,8 @@ void tst_QSortFilterProxyModel::filterOutParentAndFilterInChild() QStandardItem *itemC = new QStandardItem("C"); itemA->appendRow(itemC); // filtered - QSignalSpy removedSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy insertedSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy removedSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); + QSignalSpy insertedSpy(&proxy, &QSortFilterProxyModel::rowsInserted); QVERIFY(removedSpy.isValid()); QVERIFY(insertedSpy.isValid()); @@ -2903,8 +2906,8 @@ void tst_QSortFilterProxyModel::appearsAndSort() QCOMPARE(sourceModel.rowCount(), 3); QCOMPARE(proxyModel.rowCount(), 0); //all rows are hidden at first; - QSignalSpy spyAbout1(&proxyModel, SIGNAL(layoutAboutToBeChanged())); - QSignalSpy spyChanged1(&proxyModel, SIGNAL(layoutChanged())); + QSignalSpy spyAbout1(&proxyModel, &PModel::layoutAboutToBeChanged); + QSignalSpy spyChanged1(&proxyModel, &PModel::layoutChanged); QVERIFY(spyAbout1.isValid()); QVERIFY(spyChanged1.isValid()); @@ -2915,8 +2918,8 @@ void tst_QSortFilterProxyModel::appearsAndSort() secondProxyModel.setDynamicSortFilter(true); secondProxyModel.sort(0, Qt::DescendingOrder); QCOMPARE(secondProxyModel.rowCount(), 0); //all rows are hidden at first; - QSignalSpy spyAbout2(&secondProxyModel, SIGNAL(layoutAboutToBeChanged())); - QSignalSpy spyChanged2(&secondProxyModel, SIGNAL(layoutChanged())); + QSignalSpy spyAbout2(&secondProxyModel, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy spyChanged2(&secondProxyModel, &QSortFilterProxyModel::layoutChanged); QVERIFY(spyAbout2.isValid()); QVERIFY(spyChanged2.isValid()); @@ -3443,25 +3446,25 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged() proxy2.setSourceModel(&proxy); proxy2.setObjectName("proxy2"); - QSignalSpy dataChangedSpy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + QSignalSpy dataChangedSpy(&model, &QSortFilterProxyModel::dataChanged); QVERIFY(dataChangedSpy.isValid()); // Verify that the no-arg signal is still emitted. - QSignalSpy layoutAboutToBeChangedSpy(&proxy, SIGNAL(layoutAboutToBeChanged())); - QSignalSpy layoutChangedSpy(&proxy, SIGNAL(layoutChanged())); + QSignalSpy layoutAboutToBeChangedSpy(&proxy, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy layoutChangedSpy(&proxy, &QSortFilterProxyModel::layoutChanged); QVERIFY(layoutAboutToBeChangedSpy.isValid()); QVERIFY(layoutChangedSpy.isValid()); - QSignalSpy parentsAboutToBeChangedSpy(&proxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy parentsChangedSpy(&proxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy parentsAboutToBeChangedSpy(&proxy, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy parentsChangedSpy(&proxy, &QSortFilterProxyModel::layoutChanged); QVERIFY(parentsAboutToBeChangedSpy.isValid()); QVERIFY(parentsChangedSpy.isValid()); - QSignalSpy proxy2ParentsAboutToBeChangedSpy(&proxy2, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy proxy2ParentsChangedSpy(&proxy2, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy proxy2ParentsAboutToBeChangedSpy(&proxy2, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy proxy2ParentsChangedSpy(&proxy2, &QSortFilterProxyModel::layoutChanged); QVERIFY(proxy2ParentsAboutToBeChangedSpy.isValid()); QVERIFY(proxy2ParentsChangedSpy.isValid()); @@ -3484,8 +3487,8 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged() QVariantList beforeSignal = parentsAboutToBeChangedSpy.first(); QVariantList afterSignal = parentsChangedSpy.first(); - QCOMPARE(beforeSignal.size(), 1); - QCOMPARE(afterSignal.size(), 1); + QCOMPARE(beforeSignal.size(), 2); + QCOMPARE(afterSignal.size(), 2); QList<QPersistentModelIndex> beforeParents = beforeSignal.first().value<QList<QPersistentModelIndex> >(); QList<QPersistentModelIndex> afterParents = afterSignal.first().value<QList<QPersistentModelIndex> >(); @@ -3620,16 +3623,16 @@ void tst_QSortFilterProxyModel::moveSourceRows() filterBothProxy.setSourceModel(&proxy); filterBothProxy.setFilterRegExp("5"); // The parents are 6 and 3. This filters both out. - QSignalSpy modelBeforeSpy(&model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy modelAfterSpy(&model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy proxyBeforeMoveSpy(m_proxy, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy proxyAfterMoveSpy(m_proxy, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy proxyBeforeParentLayoutSpy(&proxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy proxyAfterParentLayoutSpy(&proxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); - QSignalSpy filterBeforeParentLayoutSpy(&filterProxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy filterAfterParentLayoutSpy(&filterProxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); - QSignalSpy filterBothBeforeParentLayoutSpy(&filterBothProxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy filterBothAfterParentLayoutSpy(&filterBothProxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy modelBeforeSpy(&model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy modelAfterSpy(&model, &DynamicTreeModel::rowsMoved); + QSignalSpy proxyBeforeMoveSpy(m_proxy, &QSortFilterProxyModel::rowsAboutToBeMoved); + QSignalSpy proxyAfterMoveSpy(m_proxy, &QSortFilterProxyModel::rowsMoved); + QSignalSpy proxyBeforeParentLayoutSpy(&proxy, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy proxyAfterParentLayoutSpy(&proxy, &QSortFilterProxyModel::layoutChanged); + QSignalSpy filterBeforeParentLayoutSpy(&filterProxy, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy filterAfterParentLayoutSpy(&filterProxy, &QSortFilterProxyModel::layoutChanged); + QSignalSpy filterBothBeforeParentLayoutSpy(&filterBothProxy, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy filterBothAfterParentLayoutSpy(&filterBothProxy, &QSortFilterProxyModel::layoutChanged); QVERIFY(modelBeforeSpy.isValid()); QVERIFY(modelAfterSpy.isValid()); |