summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-07-09 14:44:47 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2020-08-31 11:17:04 +0200
commit71c0d0e34a08e812932bf6db2419d6aa307ba6b0 (patch)
tree8f7ebe554b34abb9a47e98b901ad3c09861a27f4
parent7aeaa7aa1ef38ed337b41ea785852c72e48d6f22 (diff)
downloadqtquickcontrols-71c0d0e34a08e812932bf6db2419d6aa307ba6b0.tar.gz
Use QList instead of QVector
Task-number: QTBUG-84469 Change-Id: I9109f92d059fd4152aee1f37597c5564d477fbf9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/controls/Private/qquickcalendarmodel_p.h2
-rw-r--r--src/controls/Private/qquicktreemodeladaptor.cpp28
-rw-r--r--src/controls/Private/qquicktreemodeladaptor_p.h8
-rw-r--r--src/controls/Styles/Android/qquickandroid9patch.cpp8
-rw-r--r--src/controls/Styles/Android/qquickandroid9patch_p.h4
-rw-r--r--tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp112
-rw-r--r--tests/auto/shared/testmodel.h10
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<QDate> mVisibleDates;
+ QList<QDate> 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<int>&)),
- SLOT(modelDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)) },
+ { SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QList<int>&)),
+ SLOT(modelDataChanged(const QModelIndex&, const QModelIndex&, const QList<int>&)) },
{ SIGNAL(layoutAboutToBeChanged(const QList<QPersistentModelIndex>&, QAbstractItemModel::LayoutChangeHint)),
SLOT(modelLayoutAboutToBeChanged(const QList<QPersistentModelIndex>&, QAbstractItemModel::LayoutChangeHint)) },
@@ -459,7 +459,7 @@ void QQuickTreeModelAdaptor1::expandRow(int n)
return;
item.expanded = true;
m_expandedItems.insert(item.index);
- QVector<int> changedRole(1, ExpandedRole);
+ const QList<int> 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<int> changedRole(1, ExpandedRole);
+ const QList<int> 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<int> changedRole(1, ModelIndexRole);
+ const QList<int> 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<int> &roles)
+void QQuickTreeModelAdaptor1::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRigth, const QList<int> &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<int> changedRole(1, HasChildrenRole);
+ const QList<int> 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<int> changedRole(1, HasChildrenRole);
+ const QList<int> 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<int> changedRole(1, HasChildrenRole);
+ const QList<int> 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<int> changedRole(1, ModelIndexRole);
+ const QList<int> 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<int> changedRole(1, DepthRole);
+ const QList<int> 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<int> changedRole { ExpandedRole, HasChildrenRole };
+ const QList<int> 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<int> &roles)
+ const QList<int> &roles)
{
if (isAggregatingSignals()) {
m_queuedDataChanged.append(DataChangedParams { topLeft, bottomRight, roles });
@@ -953,7 +953,7 @@ void QQuickTreeModelAdaptor1::queueDataChanged(const QModelIndex &topLeft,
void QQuickTreeModelAdaptor1::emitQueuedSignals()
{
- QVector<DataChangedParams> combinedUpdates;
+ QList<DataChangedParams> 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<int> &roles);
+ void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRigth, const QList<int> &roles);
void modelLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint);
void modelLayoutChanged(const QList<QPersistentModelIndex> &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<int> roles;
+ QList<int> 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<int> &roles);
+ const QList<int> &roles);
void emitQueuedSignals();
QPointer<QAbstractItemModel> m_model;
@@ -189,7 +189,7 @@ private:
mutable int m_lastItemIndex;
bool m_visibleRowsMoved;
int m_signalAggregatorStack;
- QVector<DataChangedParams> m_queuedDataChanged;
+ QList<DataChangedParams> 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<qreal> xCoords = xDivs.coordsForSize(bounds.width());
- QVector<qreal> yCoords = yDivs.coordsForSize(bounds.height());
+ QList<qreal> xCoords = xDivs.coordsForSize(bounds.width());
+ QList<qreal> 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<qreal> QQuickAndroid9PatchDivs1::coordsForSize(qreal size) const
+QList<qreal> QQuickAndroid9PatchDivs1::coordsForSize(qreal size) const
{
// n = number of stretchable sections
// We have to compensate when adding 0 and/or
@@ -124,7 +124,7 @@ QVector<qreal> QQuickAndroid9PatchDivs1::coordsForSize(qreal size) const
const int n = (inverted ? l - 1 : l) >> 1;
const qreal stretchAmount = (size - data.last()) / n;
- QVector<qreal> coords;
+ QList<qreal> 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<qreal> coordsForSize(qreal size) const;
+ QList<qreal> coordsForSize(qreal size) const;
void fill(const QVariantList &divs, qreal size);
void clear();
bool inverted;
- QVector<qreal> data;
+ QList<qreal> 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<int>)));
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
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<int> >(), QVector<int>(1, QQuickTreeModelAdaptor1::ExpandedRole));
+ QCOMPARE(dataChangedArgs.at(2).value<QList<int>>(), (QList<int> { 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<int>)));
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
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<int> >(), QVector<int>(1, QQuickTreeModelAdaptor1::ExpandedRole));
+ QCOMPARE(dataChangedArgs.at(2).value<QList<int>>(), (QList<int> { 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<int> roles = args.at(2).value<QVector<int>>();
+ const QList<int> roles = args.at(2).value<QList<int>>();
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<int>)));
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
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<int> >(), QVector<int>(1, Qt::DisplayRole));
+ QCOMPARE(dataChangedArgs.at(2).value<QList<int>>(), (QList<int> { 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<int> >(), QVector<int>(1, Qt::DisplayRole));
+ QCOMPARE(dataChangedArgs.at(2).value<QList<int>>(), (QList<int> { 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<int>)));
- const QVector<int> roles(1, Qt::DisplayRole);
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
+ const QList<int> 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<QVector<int> >(), roles);
+ QCOMPARE(dataChangedArgs.at(2).value<QList<int>>(), 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<QVector<int> >(), roles);
+ QCOMPARE(dataChangedArgs.at(2).value<QList<int>>(), roles);
dataChangedArgs = dataChangedSpy.takeFirst();
QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaExpandedSiblingIdx);
QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaBRIdx);
- QCOMPARE(dataChangedArgs.at(2).value<QVector<int> >(), roles);
+ QCOMPARE(dataChangedArgs.at(2).value<QList<int>>(), 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<QVector<int> >(), roles);
+ QCOMPARE(dataChangedArgs.at(2).value<QList<int>>(), roles);
dataChangedArgs = dataChangedSpy.takeFirst();
QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaExpandedSiblingIdx);
QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaOtherExpandedIdx);
- QCOMPARE(dataChangedArgs.at(2).value<QVector<int> >(), roles);
+ QCOMPARE(dataChangedArgs.at(2).value<QList<int>>(), roles);
dataChangedArgs = dataChangedSpy.takeFirst();
QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaOtherExpandedSiblingIdx);
QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaBRIdx);
- QCOMPARE(dataChangedArgs.at(2).value<QVector<int> >(), roles);
+ QCOMPARE(dataChangedArgs.at(2).value<QList<int>>(), 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<int>)));
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
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<QVector<int> >().isEmpty());
+ QVERIFY(dataChangedArgs.at(2).value<QList<int>>().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<QVector<int> >().isEmpty());
+ QVERIFY(dataChangedArgs.at(2).value<QList<int>>().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<QVector<int> >().isEmpty());
+ QVERIFY(dataChangedArgs.at(2).value<QList<int>>().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<QVector<int> >().isEmpty());
+ QVERIFY(dataChangedArgs.at(2).value<QList<int>>().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<QVector<int> >().isEmpty());
+ QVERIFY(dataChangedArgs.at(2).value<QList<int>>().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<QVector<int> >().isEmpty());
+ QVERIFY(dataChangedArgs.at(2).value<QList<int>>().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<int>)));
+ QSignalSpy dataChanged(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
QList<QPersistentModelIndex> 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<QVector<int>>("expandedRows");
+ QTest::addColumn<QList<int>>("expandedRows");
/* Here's the row to be moved (always just one) and the destination
- * position. We use a QVector<int> to identify a single row of the tree
+ * position. We use a QList<int> 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<QVector<int>>("sourcePath");
- QTest::addColumn<QVector<int>>("destPath");
+ QTest::addColumn<QList<int>>("sourcePath");
+ QTest::addColumn<QList<int>>("destPath");
/* This is the list of expected changed rows in the *list* model. */
QTest::addColumn<QSet<int>>("expectedRowChanges");
QTest::newRow("From and to top-level parent")
- << QVector<int> {}
- << QVector<int> { 4 }
- << QVector<int> { 3 }
+ << QList<int> {}
+ << QList<int> { 4 }
+ << QList<int> { 3 }
<< QSet<int> { 3, 4 };
QTest::newRow("From and to top-level parent, expanded")
- << QVector<int> { 3, 5 }
- << QVector<int> { 4 }
- << QVector<int> { 3 }
+ << QList<int> { 3, 5 }
+ << QList<int> { 4 }
+ << QList<int> { 3 }
<< QSet<int> { 3, 4, 5, 6, 7, 8, 9 };
QTest::newRow("From and to top-level parent, expanded, down")
- << QVector<int> { 3, 5 }
- << QVector<int> { 3 }
- << QVector<int> { 5 }
+ << QList<int> { 3, 5 }
+ << QList<int> { 3 }
+ << QList<int> { 5 }
<< QSet<int> { 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<int> { 3, 1 }
- << QVector<int> { 3, 0 }
- << QVector<int> { 1, 1 }
+ << QList<int> { 3, 1 }
+ << QList<int> { 3, 0 }
+ << QList<int> { 1, 1 }
<< QSet<int> { 3, 4, 5, 6, 7 };
QTest::newRow("Move to non expanded parent")
- << QVector<int> {}
- << QVector<int> { 3 }
- << QVector<int> { 1, 0 }
+ << QList<int> {}
+ << QList<int> { 3 }
+ << QList<int> { 1, 0 }
<< QSet<int> { 3 };
}
void tst_QQuickTreeModelAdaptor::moveRowsDataChanged()
{
- QFETCH(QVector<int>, expandedRows);
- QFETCH(QVector<int>, sourcePath);
- QFETCH(QVector<int>, destPath);
+ QFETCH(QList<int>, expandedRows);
+ QFETCH(QList<int>, sourcePath);
+ QFETCH(QList<int>, destPath);
QFETCH(QSet<int>, 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<int>)));
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
QVERIFY(dataChangedSpy.isValid());
QVERIFY(model.moveRows(sourceIndex, sourceRow, 1, destIndex, destRow));
@@ -1293,7 +1293,7 @@ void tst_QQuickTreeModelAdaptor::moveRowsDataChanged()
QSet<int> emittedChanges;
for (int i = 0; i < dataChangedSpy.count(); i++) {
QVariantList args = dataChangedSpy.at(i);
- QVector<int> roles = args.at(2).value<QVector<int>>();
+ const QList<int> roles = args.at(2).value<QList<int>>();
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<int>)));
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
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<QList<QVariant> > &changes = dataChangedSpy;
for (const QList<QVariant> &change : changes) {
if (change.at(0) == movedIndex) {
- if (change.at(2).value<QVector<int> >().contains(QQuickTreeModelAdaptor1::DepthRole))
+ if (change.at(2).value<QList<int>>().contains(QQuickTreeModelAdaptor1::DepthRole))
depthChanged = true;
- if (change.at(2).value<QVector<int> >().contains(QQuickTreeModelAdaptor1::ModelIndexRole))
+ if (change.at(2).value<QList<int>>().contains(QQuickTreeModelAdaptor1::ModelIndexRole))
modelIndexChanged = true;
}
}
@@ -1381,7 +1381,7 @@ void tst_QQuickTreeModelAdaptor::moveAllChildren()
tma.expandRow(1);
- QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
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<int>)));
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
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<int>)));
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
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<int>)));
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
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<int>)));
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QList<int>)));
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<int> changedRole(1, role);
+ QList<int> changedRole(1, role);
emit dataChanged(index, index, changedRole);
return true;
}
- void groupedSetData(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
+ void groupedSetData(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList<int> &roles)
{
emit dataChanged(topLeft, bottomRight, roles);
}
@@ -243,12 +243,12 @@ public:
Node *dest = (Node *)destinationParent.internalPointer();
if (!dest)
dest = tree;
- QVector<Node *> buffer = src->children.mid(sourceRow, count);
+ QList<Node *> buffer = src->children.mid(sourceRow, count);
if (src != dest) {
src->removeRows(sourceRow, count, true /* keep alive */);
dest->addRows(destinationChild, count);
} else {
- QVector<Node *> &c = dest->children;
+ QList<Node *> &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<Node *> children;
+ QList<Node *> children;
Node(int rows, Node *p = 0) : parent(p)
{