From 71c0d0e34a08e812932bf6db2419d6aa307ba6b0 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 9 Jul 2020 14:44:47 +0200 Subject: Use QList instead of QVector Task-number: QTBUG-84469 Change-Id: I9109f92d059fd4152aee1f37597c5564d477fbf9 Reviewed-by: Mitch Curtis --- src/controls/Private/qquickcalendarmodel_p.h | 2 +- src/controls/Private/qquicktreemodeladaptor.cpp | 28 +++--- src/controls/Private/qquicktreemodeladaptor_p.h | 8 +- .../Styles/Android/qquickandroid9patch.cpp | 8 +- .../Styles/Android/qquickandroid9patch_p.h | 4 +- .../tst_qquicktreemodeladaptor.cpp | 112 ++++++++++----------- tests/auto/shared/testmodel.h | 10 +- 7 files changed, 86 insertions(+), 86 deletions(-) diff --git a/src/controls/Private/qquickcalendarmodel_p.h b/src/controls/Private/qquickcalendarmodel_p.h index 68fdea2e..8c637551 100644 --- a/src/controls/Private/qquickcalendarmodel_p.h +++ b/src/controls/Private/qquickcalendarmodel_p.h @@ -90,7 +90,7 @@ protected: QDate mVisibleDate; QDate mFirstVisibleDate; QDate mLastVisibleDate; - QVector mVisibleDates; + QList mVisibleDates; QLocale mLocale; }; diff --git a/src/controls/Private/qquicktreemodeladaptor.cpp b/src/controls/Private/qquicktreemodeladaptor.cpp index f1c8e413..cb16f559 100644 --- a/src/controls/Private/qquicktreemodeladaptor.cpp +++ b/src/controls/Private/qquicktreemodeladaptor.cpp @@ -73,8 +73,8 @@ void QQuickTreeModelAdaptor1::setModel(QAbstractItemModel *arg) SLOT(modelHasBeenDestroyed()) }, { SIGNAL(modelReset()), SLOT(modelHasBeenReset()) }, - { SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector&)), - SLOT(modelDataChanged(const QModelIndex&, const QModelIndex&, const QVector&)) }, + { SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QList&)), + SLOT(modelDataChanged(const QModelIndex&, const QModelIndex&, const QList&)) }, { SIGNAL(layoutAboutToBeChanged(const QList&, QAbstractItemModel::LayoutChangeHint)), SLOT(modelLayoutAboutToBeChanged(const QList&, QAbstractItemModel::LayoutChangeHint)) }, @@ -459,7 +459,7 @@ void QQuickTreeModelAdaptor1::expandRow(int n) return; item.expanded = true; m_expandedItems.insert(item.index); - QVector changedRole(1, ExpandedRole); + const QList changedRole = { ExpandedRole }; emit dataChanged(index(n), index(n), changedRole); m_itemsToExpand.append(&item); @@ -496,7 +496,7 @@ void QQuickTreeModelAdaptor1::collapseRow(int n) TreeItem &item = m_items[n]; item.expanded = false; m_expandedItems.remove(item.index); - QVector changedRole(1, ExpandedRole); + const QList changedRole = { ExpandedRole }; queueDataChanged(index(n), index(n), changedRole); int childrenCount = m_model->rowCount(item.index); if ((item.index.flags() & Qt::ItemNeverHasChildren) || !m_model->hasChildren(item.index) || childrenCount == 0) @@ -541,7 +541,7 @@ void QQuickTreeModelAdaptor1::removeVisibleRows(int startIndex, int endIndex, bo if (startIndex <= lastIndex) { const QModelIndex &topLeft = index(startIndex, 0, QModelIndex()); const QModelIndex &bottomRight = index(lastIndex, 0, QModelIndex()); - const QVector changedRole(1, ModelIndexRole); + const QList changedRole = { ModelIndexRole }; queueDataChanged(topLeft, bottomRight, changedRole); } } @@ -562,7 +562,7 @@ void QQuickTreeModelAdaptor1::modelHasBeenReset() ASSERT_CONSISTENCY(); } -void QQuickTreeModelAdaptor1::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRigth, const QVector &roles) +void QQuickTreeModelAdaptor1::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRigth, const QList &roles) { Q_ASSERT(topLeft.parent() == bottomRigth.parent()); const QModelIndex &parent = topLeft.parent(); @@ -648,7 +648,7 @@ void QQuickTreeModelAdaptor1::modelRowsInserted(const QModelIndex & parent, int int parentRow = itemIndex(parent); if (parentRow >= 0) { const QModelIndex& parentIndex = index(parentRow); - QVector changedRole(1, HasChildrenRole); + const QList changedRole = { HasChildrenRole }; queueDataChanged(parentIndex, parentIndex, changedRole); item = m_items.at(parentRow); if (!item.expanded) { @@ -700,7 +700,7 @@ void QQuickTreeModelAdaptor1::modelRowsRemoved(const QModelIndex & parent, int s int parentRow = itemIndex(parent); if (parentRow >= 0) { const QModelIndex& parentIndex = index(parentRow); - QVector changedRole(1, HasChildrenRole); + const QList changedRole = { HasChildrenRole }; queueDataChanged(parentIndex, parentIndex, changedRole); } disableSignalAggregation(); @@ -722,7 +722,7 @@ void QQuickTreeModelAdaptor1::modelRowsAboutToBeMoved(const QModelIndex & source if (isVisible(destinationParent) && m_model->rowCount(destinationParent) == 0) { const QModelIndex &topLeft = index(itemIndex(destinationParent), 0, QModelIndex()); const QModelIndex &bottomRight = topLeft; - const QVector changedRole(1, HasChildrenRole); + const QList changedRole = { HasChildrenRole }; queueDataChanged(topLeft, bottomRight, changedRole); } } else { @@ -806,13 +806,13 @@ void QQuickTreeModelAdaptor1::modelRowsAboutToBeMoved(const QModelIndex & source } const QModelIndex &topLeft = index(top, 0, QModelIndex()); const QModelIndex &bottomRight = index(bottom, 0, QModelIndex()); - const QVector changedRole(1, ModelIndexRole); + const QList changedRole = { ModelIndexRole }; queueDataChanged(topLeft, bottomRight, changedRole); if (depthDifference != 0) { const QModelIndex &topLeft = index(bufferCopyOffset, 0, QModelIndex()); const QModelIndex &bottomRight = index(bufferCopyOffset + totalMovedCount - 1, 0, QModelIndex()); - const QVector changedRole(1, DepthRole); + const QList changedRole = { DepthRole }; queueDataChanged(topLeft, bottomRight, changedRole); } } @@ -834,7 +834,7 @@ void QQuickTreeModelAdaptor1::modelRowsMoved(const QModelIndex & sourceParent, i collapseRow(parentRow); const QModelIndex &topLeft = index(parentRow, 0, QModelIndex()); const QModelIndex &bottomRight = topLeft; - const QVector changedRole { ExpandedRole, HasChildrenRole }; + const QList changedRole { ExpandedRole, HasChildrenRole }; queueDataChanged(topLeft, bottomRight, changedRole); } @@ -942,7 +942,7 @@ void QQuickTreeModelAdaptor1::disableSignalAggregation() { void QQuickTreeModelAdaptor1::queueDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, - const QVector &roles) + const QList &roles) { if (isAggregatingSignals()) { m_queuedDataChanged.append(DataChangedParams { topLeft, bottomRight, roles }); @@ -953,7 +953,7 @@ void QQuickTreeModelAdaptor1::queueDataChanged(const QModelIndex &topLeft, void QQuickTreeModelAdaptor1::emitQueuedSignals() { - QVector combinedUpdates; + QList combinedUpdates; /* First, iterate through the queued updates and merge the overlapping ones * to reduce the number of updates. * We don't merge adjacent updates, because they are typically filed with a diff --git a/src/controls/Private/qquicktreemodeladaptor_p.h b/src/controls/Private/qquicktreemodeladaptor_p.h index 9a272936..c078cc9f 100644 --- a/src/controls/Private/qquicktreemodeladaptor_p.h +++ b/src/controls/Private/qquicktreemodeladaptor_p.h @@ -131,7 +131,7 @@ public slots: private slots: void modelHasBeenDestroyed(); void modelHasBeenReset(); - void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRigth, const QVector &roles); + void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRigth, const QList &roles); void modelLayoutAboutToBeChanged(const QList &parents, QAbstractItemModel::LayoutChangeHint hint); void modelLayoutChanged(const QList &parents, QAbstractItemModel::LayoutChangeHint hint); void modelRowsAboutToBeInserted(const QModelIndex & parent, int start, int end); @@ -160,7 +160,7 @@ private: struct DataChangedParams { QModelIndex topLeft; QModelIndex bottomRight; - QVector roles; + QList roles; }; struct SignalFreezer { @@ -178,7 +178,7 @@ private: bool isAggregatingSignals() const { return m_signalAggregatorStack > 0; } void queueDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, - const QVector &roles); + const QList &roles); void emitQueuedSignals(); QPointer m_model; @@ -189,7 +189,7 @@ private: mutable int m_lastItemIndex; bool m_visibleRowsMoved; int m_signalAggregatorStack; - QVector m_queuedDataChanged; + QList m_queuedDataChanged; }; QT_END_NAMESPACE diff --git a/src/controls/Styles/Android/qquickandroid9patch.cpp b/src/controls/Styles/Android/qquickandroid9patch.cpp index 48e86baa..51c2a9d9 100644 --- a/src/controls/Styles/Android/qquickandroid9patch.cpp +++ b/src/controls/Styles/Android/qquickandroid9patch.cpp @@ -85,8 +85,8 @@ void QQuickAndroid9PatchNode1::initialize(QSGTexture *texture, const QRectF &bou m_geometry.allocate(xlen * ylen, verticesPerQuad * quads); QSGGeometry::TexturedPoint2D *vertices = m_geometry.vertexDataAsTexturedPoint2D(); - QVector xCoords = xDivs.coordsForSize(bounds.width()); - QVector yCoords = yDivs.coordsForSize(bounds.height()); + QList xCoords = xDivs.coordsForSize(bounds.width()); + QList yCoords = yDivs.coordsForSize(bounds.height()); for (int y = 0; y < ylen; ++y) { for (int x = 0; x < xlen; ++x, ++vertices) vertices->set(xCoords[x], yCoords[y], xDivs.data[x] / sourceSize.width(), @@ -115,7 +115,7 @@ void QQuickAndroid9PatchNode1::initialize(QSGTexture *texture, const QRectF &bou markDirty(QSGNode::DirtyGeometry | QSGNode::DirtyMaterial); } -QVector QQuickAndroid9PatchDivs1::coordsForSize(qreal size) const +QList QQuickAndroid9PatchDivs1::coordsForSize(qreal size) const { // n = number of stretchable sections // We have to compensate when adding 0 and/or @@ -124,7 +124,7 @@ QVector QQuickAndroid9PatchDivs1::coordsForSize(qreal size) const const int n = (inverted ? l - 1 : l) >> 1; const qreal stretchAmount = (size - data.last()) / n; - QVector coords; + QList coords; coords.reserve(l); coords.append(0); diff --git a/src/controls/Styles/Android/qquickandroid9patch_p.h b/src/controls/Styles/Android/qquickandroid9patch_p.h index 8d0c2a7b..a9f28606 100644 --- a/src/controls/Styles/Android/qquickandroid9patch_p.h +++ b/src/controls/Styles/Android/qquickandroid9patch_p.h @@ -48,13 +48,13 @@ QT_BEGIN_NAMESPACE struct QQuickAndroid9PatchDivs1 { - QVector coordsForSize(qreal size) const; + QList coordsForSize(qreal size) const; void fill(const QVariantList &divs, qreal size); void clear(); bool inverted; - QVector data; + QList data; }; class QQuickAndroid9Patch1 : public QQuickItem diff --git a/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp b/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp index c3e77cf9..7cc46fb8 100644 --- a/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp +++ b/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp @@ -108,7 +108,7 @@ void tst_QQuickTreeModelAdaptor::expandAndTest(const QModelIndex &idx, QQuickTre { QSignalSpy rowsAboutToBeInsertedSpy(&tma, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); QSignalSpy rowsInsertedSpy(&tma, SIGNAL(rowsInserted(QModelIndex,int,int))); - QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); int oldRowCount = tma.rowCount(); tma.expand(idx); @@ -137,7 +137,7 @@ void tst_QQuickTreeModelAdaptor::expandAndTest(const QModelIndex &idx, QQuickTre const QVariantList &dataChangedArgs = dataChangedSpy.first(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaIdx); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaIdx); - QCOMPARE(dataChangedArgs.at(2).value >(), QVector(1, QQuickTreeModelAdaptor1::ExpandedRole)); + QCOMPARE(dataChangedArgs.at(2).value>(), (QList { QQuickTreeModelAdaptor1::ExpandedRole })); } else { QCOMPARE(tma.rowCount(), oldRowCount); QCOMPARE(rowsAboutToBeInsertedSpy.count(), 0); @@ -150,7 +150,7 @@ void tst_QQuickTreeModelAdaptor::collapseAndTest(const QModelIndex &idx, QQuickT { QSignalSpy rowsAboutToBeRemovedSpy(&tma, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); QSignalSpy rowsRemovedSpy(&tma, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); int oldRowCount = tma.rowCount(); tma.collapse(idx); @@ -178,7 +178,7 @@ void tst_QQuickTreeModelAdaptor::collapseAndTest(const QModelIndex &idx, QQuickT const QVariantList &dataChangedArgs = dataChangedSpy.first(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaIdx); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaIdx); - QCOMPARE(dataChangedArgs.at(2).value >(), QVector(1, QQuickTreeModelAdaptor1::ExpandedRole)); + QCOMPARE(dataChangedArgs.at(2).value>(), (QList { QQuickTreeModelAdaptor1::ExpandedRole })); } else { QCOMPARE(tma.rowCount(), oldRowCount); QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0); @@ -192,7 +192,7 @@ bool tst_QQuickTreeModelAdaptor::rowRoleWasChanged(const QSignalSpy &captured, i const int startRow = args.at(0).toModelIndex().row(); const int endRow = args.at(1).toModelIndex().row(); if (row >= startRow && row <= endRow) { - const QVector roles = args.at(2).value>(); + const QList roles = args.at(2).value>(); if (roles.contains(role)) return true; } @@ -360,7 +360,7 @@ void tst_QQuickTreeModelAdaptor::dataChange() QQuickTreeModelAdaptor1 tma; tma.setModel(&model); - QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); const QModelIndex &idx = model.index(2, 0); model.setData(idx, QVariant(), Qt::DisplayRole); QCOMPARE(dataChangedSpy.count(), 1); @@ -368,7 +368,7 @@ void tst_QQuickTreeModelAdaptor::dataChange() const QModelIndex &tmaIdx = tma.index(tma.itemIndex(idx)); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaIdx); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaIdx); - QCOMPARE(dataChangedArgs.at(2).value >(), QVector(1, Qt::DisplayRole)); + QCOMPARE(dataChangedArgs.at(2).value>(), (QList { Qt::DisplayRole })); compareModels(tma, model); { @@ -389,7 +389,7 @@ void tst_QQuickTreeModelAdaptor::dataChange() const QModelIndex &tmaIdx = tma.index(tma.itemIndex(childIdx)); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaIdx); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaIdx); - QCOMPARE(dataChangedArgs.at(2).value >(), QVector(1, Qt::DisplayRole)); + QCOMPARE(dataChangedArgs.at(2).value>(), (QList { Qt::DisplayRole })); compareModels(tma, model); } } @@ -403,8 +403,8 @@ void tst_QQuickTreeModelAdaptor::groupedDataChange() QQuickTreeModelAdaptor1 tma; tma.setModel(&model); - QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); - const QVector roles(1, Qt::DisplayRole); + QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); + const QList roles = { Qt::DisplayRole }; { // No expanded items @@ -417,7 +417,7 @@ void tst_QQuickTreeModelAdaptor::groupedDataChange() const QVariantList &dataChangedArgs = dataChangedSpy.first(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaTLIdx); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaBRIdx); - QCOMPARE(dataChangedArgs.at(2).value >(), roles); + QCOMPARE(dataChangedArgs.at(2).value>(), roles); } // One item expanded in the group range @@ -439,12 +439,12 @@ void tst_QQuickTreeModelAdaptor::groupedDataChange() QVariantList dataChangedArgs = dataChangedSpy.takeFirst(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaTLIdx); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaExpandedIdx); - QCOMPARE(dataChangedArgs.at(2).value >(), roles); + QCOMPARE(dataChangedArgs.at(2).value>(), roles); dataChangedArgs = dataChangedSpy.takeFirst(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaExpandedSiblingIdx); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaBRIdx); - QCOMPARE(dataChangedArgs.at(2).value >(), roles); + QCOMPARE(dataChangedArgs.at(2).value>(), roles); // Further expanded descendants should not change grouping tma.expand(model.index(0, 0, expandedIdx)); @@ -473,17 +473,17 @@ void tst_QQuickTreeModelAdaptor::groupedDataChange() QVariantList dataChangedArgs = dataChangedSpy.takeFirst(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaTLIdx); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaExpandedIdx); - QCOMPARE(dataChangedArgs.at(2).value >(), roles); + QCOMPARE(dataChangedArgs.at(2).value>(), roles); dataChangedArgs = dataChangedSpy.takeFirst(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaExpandedSiblingIdx); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaOtherExpandedIdx); - QCOMPARE(dataChangedArgs.at(2).value >(), roles); + QCOMPARE(dataChangedArgs.at(2).value>(), roles); dataChangedArgs = dataChangedSpy.takeFirst(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaOtherExpandedSiblingIdx); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaBRIdx); - QCOMPARE(dataChangedArgs.at(2).value >(), roles); + QCOMPARE(dataChangedArgs.at(2).value>(), roles); // Further expanded descendants should not change grouping if (i == 0) { @@ -591,13 +591,13 @@ void tst_QQuickTreeModelAdaptor::layoutChange() tma.setModel(&model); // Nothing expanded - QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); model.changeLayout(); QCOMPARE(dataChangedSpy.count(), 1); QVariantList dataChangedArgs = dataChangedSpy.takeFirst(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tma.index(0)); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tma.index(tma.rowCount() - 1)); - QVERIFY(dataChangedArgs.at(2).value >().isEmpty()); + QVERIFY(dataChangedArgs.at(2).value>().isEmpty()); compareModels(tma, model); // One item expanded @@ -609,7 +609,7 @@ void tst_QQuickTreeModelAdaptor::layoutChange() dataChangedArgs = dataChangedSpy.takeFirst(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tma.index(0)); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tma.index(tma.rowCount() - 1)); - QVERIFY(dataChangedArgs.at(2).value >().isEmpty()); + QVERIFY(dataChangedArgs.at(2).value>().isEmpty()); compareModels(tma, model); // One parent layout change, expanded @@ -621,7 +621,7 @@ void tst_QQuickTreeModelAdaptor::layoutChange() dataChangedArgs = dataChangedSpy.takeFirst(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tma.index(tma.itemIndex(model.index(0, 0, idx)))); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tma.index(tma.itemIndex(model.index(model.rowCount(idx) - 1, 0, idx)))); - QVERIFY(dataChangedArgs.at(2).value >().isEmpty()); + QVERIFY(dataChangedArgs.at(2).value>().isEmpty()); compareModels(tma, model); // One parent layout change, collapsed @@ -647,7 +647,7 @@ void tst_QQuickTreeModelAdaptor::layoutChange() dataChangedArgs = dataChangedSpy.takeFirst(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tma.index(tma.itemIndex(model.index(0, 0, idx2)))); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tma.index(tma.itemIndex(model.index(model.rowCount(idx2) - 1, 0, idx2)))); - QVERIFY(dataChangedArgs.at(2).value >().isEmpty()); + QVERIFY(dataChangedArgs.at(2).value>().isEmpty()); compareModels(tma, model); // Two-parent layout change, both expanded @@ -659,11 +659,11 @@ void tst_QQuickTreeModelAdaptor::layoutChange() dataChangedArgs = dataChangedSpy.takeFirst(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tma.index(tma.itemIndex(model.index(0, 0, idx)))); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tma.index(tma.itemIndex(model.index(model.rowCount(idx) - 1, 0, idx)))); - QVERIFY(dataChangedArgs.at(2).value >().isEmpty()); + QVERIFY(dataChangedArgs.at(2).value>().isEmpty()); dataChangedArgs = dataChangedSpy.takeFirst(); QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tma.index(tma.itemIndex(model.index(0, 0, idx2)))); QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tma.index(tma.itemIndex(model.index(model.rowCount(idx2) - 1, 0, idx2)))); - QVERIFY(dataChangedArgs.at(2).value >().isEmpty()); + QVERIFY(dataChangedArgs.at(2).value>().isEmpty()); compareModels(tma, model); } @@ -856,7 +856,7 @@ void tst_QQuickTreeModelAdaptor::removeChildrenRelayoutParent() QCOMPARE(rowsAboutToBeRemovedArgs.at(2).toInt(), tmaItemIdx + expectedRemovedCount - 1); // Relayout the first node - QSignalSpy dataChanged(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy dataChanged(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); QList parents; parents << parent; model.changeLayout(parents); @@ -1174,35 +1174,35 @@ void tst_QQuickTreeModelAdaptor::moveRows() void tst_QQuickTreeModelAdaptor::moveRowsDataChanged_data() { /* This is the list of rows in the *list* model which are expanded. */ - QTest::addColumn>("expandedRows"); + QTest::addColumn>("expandedRows"); /* Here's the row to be moved (always just one) and the destination - * position. We use a QVector to identify a single row of the tree + * position. We use a QList to identify a single row of the tree * model: the array value at index n represents the row number at the depth * n. */ - QTest::addColumn>("sourcePath"); - QTest::addColumn>("destPath"); + QTest::addColumn>("sourcePath"); + QTest::addColumn>("destPath"); /* This is the list of expected changed rows in the *list* model. */ QTest::addColumn>("expectedRowChanges"); QTest::newRow("From and to top-level parent") - << QVector {} - << QVector { 4 } - << QVector { 3 } + << QList {} + << QList { 4 } + << QList { 3 } << QSet { 3, 4 }; QTest::newRow("From and to top-level parent, expanded") - << QVector { 3, 5 } - << QVector { 4 } - << QVector { 3 } + << QList { 3, 5 } + << QList { 4 } + << QList { 3 } << QSet { 3, 4, 5, 6, 7, 8, 9 }; QTest::newRow("From and to top-level parent, expanded, down") - << QVector { 3, 5 } - << QVector { 3 } - << QVector { 5 } + << QList { 3, 5 } + << QList { 3 } + << QList { 5 } << QSet { 3, 4, 5, 6, 7, 8, 9 }; /* Expected visible result: @@ -1217,23 +1217,23 @@ void tst_QQuickTreeModelAdaptor::moveRowsDataChanged_data() * M M */ QTest::newRow("Visible move, different parents") - << QVector { 3, 1 } - << QVector { 3, 0 } - << QVector { 1, 1 } + << QList { 3, 1 } + << QList { 3, 0 } + << QList { 1, 1 } << QSet { 3, 4, 5, 6, 7 }; QTest::newRow("Move to non expanded parent") - << QVector {} - << QVector { 3 } - << QVector { 1, 0 } + << QList {} + << QList { 3 } + << QList { 1, 0 } << QSet { 3 }; } void tst_QQuickTreeModelAdaptor::moveRowsDataChanged() { - QFETCH(QVector, expandedRows); - QFETCH(QVector, sourcePath); - QFETCH(QVector, destPath); + QFETCH(QList, expandedRows); + QFETCH(QList, sourcePath); + QFETCH(QList, destPath); QFETCH(QSet, expectedRowChanges); TestModel model(0, 1); @@ -1285,7 +1285,7 @@ void tst_QQuickTreeModelAdaptor::moveRowsDataChanged() destIndex = model.index(row, 0, destIndex); } - QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); QVERIFY(dataChangedSpy.isValid()); QVERIFY(model.moveRows(sourceIndex, sourceRow, 1, destIndex, destRow)); @@ -1293,7 +1293,7 @@ void tst_QQuickTreeModelAdaptor::moveRowsDataChanged() QSet emittedChanges; for (int i = 0; i < dataChangedSpy.count(); i++) { QVariantList args = dataChangedSpy.at(i); - QVector roles = args.at(2).value>(); + const QList roles = args.at(2).value>(); if (!roles.isEmpty() && !roles.contains(QQuickTreeModelAdaptor1::ModelIndexRole)) continue; @@ -1321,7 +1321,7 @@ void tst_QQuickTreeModelAdaptor::reparentOnSameRow() tma.expand(destParent); QVERIFY(tma.isExpanded(destParent)); - QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); QSignalSpy rowsMovedSpy(&tma, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); QVERIFY(rowsMovedSpy.isValid()); QVERIFY(dataChangedSpy.isValid()); @@ -1339,9 +1339,9 @@ void tst_QQuickTreeModelAdaptor::reparentOnSameRow() const QList > &changes = dataChangedSpy; for (const QList &change : changes) { if (change.at(0) == movedIndex) { - if (change.at(2).value >().contains(QQuickTreeModelAdaptor1::DepthRole)) + if (change.at(2).value>().contains(QQuickTreeModelAdaptor1::DepthRole)) depthChanged = true; - if (change.at(2).value >().contains(QQuickTreeModelAdaptor1::ModelIndexRole)) + if (change.at(2).value>().contains(QQuickTreeModelAdaptor1::ModelIndexRole)) modelIndexChanged = true; } } @@ -1381,7 +1381,7 @@ void tst_QQuickTreeModelAdaptor::moveAllChildren() tma.expandRow(1); - QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); QVERIFY(dataChangedSpy.isValid()); QVERIFY(model.moveRows(bIndex, 0, 1, aIndex, 0)); @@ -1594,7 +1594,7 @@ void tst_QQuickTreeModelAdaptor::hasChildrenEmit() { QVERIFY(!tma.isExpanded(root)); QVERIFY(!tma.isExpanded(child)); - QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); QCOMPARE(dataChangedSpy.count(), 0); QCOMPARE(model.rowCount(child), 1); model.insertRow(1, child); @@ -1605,7 +1605,7 @@ void tst_QQuickTreeModelAdaptor::hasChildrenEmit() // Root not expanded, insert in root, expect datachanged { QVERIFY(!tma.isExpanded(root)); - QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); QCOMPARE(dataChangedSpy.count(), 0); QCOMPARE(model.rowCount(root), 1); model.insertRow(1, root); @@ -1617,7 +1617,7 @@ void tst_QQuickTreeModelAdaptor::hasChildrenEmit() { QVERIFY(!tma.isExpanded(root)); QVERIFY(!tma.isExpanded(child)); - QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); QCOMPARE(dataChangedSpy.count(), 0); QCOMPARE(model.rowCount(child), 2); model.removeRow(1, child); @@ -1628,7 +1628,7 @@ void tst_QQuickTreeModelAdaptor::hasChildrenEmit() // Root not expanded, remove in root, expected datachanged on hasChildren { QVERIFY(!tma.isExpanded(root)); - QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector))); + QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList))); QCOMPARE(dataChangedSpy.count(), 0); QCOMPARE(model.rowCount(root), 2); model.removeRow(1, root); diff --git a/tests/auto/shared/testmodel.h b/tests/auto/shared/testmodel.h index b1d9308e..d0a7e6e4 100644 --- a/tests/auto/shared/testmodel.h +++ b/tests/auto/shared/testmodel.h @@ -175,12 +175,12 @@ public: bool setData(const QModelIndex &index, const QVariant &value, int role) { Q_UNUSED(value); - QVector changedRole(1, role); + QList changedRole(1, role); emit dataChanged(index, index, changedRole); return true; } - void groupedSetData(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) + void groupedSetData(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList &roles) { emit dataChanged(topLeft, bottomRight, roles); } @@ -243,12 +243,12 @@ public: Node *dest = (Node *)destinationParent.internalPointer(); if (!dest) dest = tree; - QVector buffer = src->children.mid(sourceRow, count); + QList buffer = src->children.mid(sourceRow, count); if (src != dest) { src->removeRows(sourceRow, count, true /* keep alive */); dest->addRows(destinationChild, count); } else { - QVector &c = dest->children; + QList &c = dest->children; if (sourceRow < destinationChild) { memmove(&c[sourceRow], &c[sourceRow + count], sizeof(Node *) * (destinationChild - sourceRow - count)); destinationChild -= count; @@ -280,7 +280,7 @@ public: struct Node { Node *parent; - QVector children; + QList children; Node(int rows, Node *p = 0) : parent(p) { -- cgit v1.2.1