diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-07-10 21:21:17 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-07-15 14:21:25 +0200 |
commit | 874f8ef3b9fb9d80a2b05c264ca48464e31257e2 (patch) | |
tree | 2a1213104b290a196e71f57e928befc38a20c992 /tests | |
parent | 0a8d24180e11a093656a8efe31370a591115a96f (diff) |
Eradicate Java-style iterators and Q_FOREACH and mark the module free of them
... and QLinkedList.
Java-style iterators are scheduled to be deprecated, or at the very
least banned from use in Qt's own implementation. Ditto Q_FOREACH.
Ditto QLinkedList.
Change-Id: I92eb5c22762b63cba45f8eaf717c1b7d458fcda4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp | 16 | ||||
-rw-r--r-- | tests/auto/shared/testmodel.h | 3 | ||||
-rw-r--r-- | tests/benchmarks/objectcount/tst_objectcount.cpp | 4 |
3 files changed, 11 insertions, 12 deletions
diff --git a/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp b/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp index 0fec548d8..c035c6760 100644 --- a/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp +++ b/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp @@ -1181,8 +1181,8 @@ void tst_QQuickTreeModelAdaptor::reparentOnSameRow() // at least DepthRole and ModeIndexRole changes should have happened for the affected row bool depthChanged = false; bool modelIndexChanged = false; - QList<QList<QVariant> > &changes = dataChangedSpy; - foreach (QList<QVariant> change, changes) { + 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)) depthChanged = true; @@ -1258,7 +1258,7 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange() QCOMPARE(sel.count(), 2); // We don't know in which order the selection ranges are // being added, so we iterate and try to find what we expect. - foreach (const QItemSelectionRange &range, sel) { + for (const QItemSelectionRange &range : sel) { if (range.topLeft() == model.index(0, 0)) QCOMPARE(QModelIndex(range.bottomRight()), model.index(0, 0)); else if (range.topLeft() == model.index(0, 0, parent)) @@ -1275,7 +1275,7 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange() QCOMPARE(sel.count(), 2); // We don't know in which order the selection ranges are // being added, so we iterate and try to find what we expect. - foreach (const QItemSelectionRange &range, sel) { + for (const QItemSelectionRange &range : sel) { if (range.topLeft() == model.index(0, 0)) QCOMPARE(QModelIndex(range.bottomRight()), model.index(4, 0)); else if (range.topLeft() == model.index(0, 0, parent)) @@ -1296,7 +1296,7 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange() QCOMPARE(sel.count(), 3); // We don't know in which order the selection ranges are // being added, so we iterate and try to find what we expect. - foreach (const QItemSelectionRange &range, sel) { + for (const QItemSelectionRange &range : sel) { if (range.topLeft() == model.index(0, 0)) QCOMPARE(QModelIndex(range.bottomRight()), model.index(4, 0)); else if (range.topLeft() == model.index(0, 0, parent)) @@ -1319,7 +1319,7 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange() QCOMPARE(sel.count(), 3); // We don't know in which order the selection ranges are // being added, so we iterate and try to find what we expect. - foreach (const QItemSelectionRange &range, sel) { + for (const QItemSelectionRange &range : sel) { if (range.topLeft() == model.index(0, 0)) QCOMPARE(QModelIndex(range.bottomRight()), model.index(0, 0)); else if (range.topLeft() == model.index(0, 0, parent)) @@ -1338,7 +1338,7 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange() QCOMPARE(sel.count(), 4); // We don't know in which order the selection ranges are // being added, so we iterate and try to find what we expect. - foreach (const QItemSelectionRange &range, sel) { + for (const QItemSelectionRange &range : sel) { if (range.topLeft() == model.index(0, 0)) QCOMPARE(QModelIndex(range.bottomRight()), model.index(ModelRowCount - 1, 0)); else if (range.topLeft() == model.index(0, 0, parent)) @@ -1359,7 +1359,7 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange() QCOMPARE(sel.count(), 4); // We don't know in which order the selection ranges are // being added, so we iterate and try to find what we expect. - foreach (const QItemSelectionRange &range, sel) { + for (const QItemSelectionRange &range : sel) { if (range.topLeft() == model.index(1, 0)) QCOMPARE(QModelIndex(range.bottomRight()), model.index(1, 0)); else if (range.topLeft() == model.index(1, 0, parent)) diff --git a/tests/auto/shared/testmodel.h b/tests/auto/shared/testmodel.h index 6eaab74aa..b1d9308e4 100644 --- a/tests/auto/shared/testmodel.h +++ b/tests/auto/shared/testmodel.h @@ -289,8 +289,7 @@ public: ~Node() { - foreach (Node *n, children) - delete n; + qDeleteAll(children); } void addRows(int row, int count) diff --git a/tests/benchmarks/objectcount/tst_objectcount.cpp b/tests/benchmarks/objectcount/tst_objectcount.cpp index c57971603..996b4b66c 100644 --- a/tests/benchmarks/objectcount/tst_objectcount.cpp +++ b/tests/benchmarks/objectcount/tst_objectcount.cpp @@ -83,7 +83,7 @@ static void printItems(const QList<QQuickItem *> &items) std::cout << " QQuickItems: " << items.count() << " (total of QObjects: " << qt_qobjects->count() << ")" << std::endl; if (qt_verbose) { - foreach (QObject *object, *qt_qobjects) + for (QObject *object : qAsConst(*qt_qobjects)) qInfo() << "\t" << object; } } @@ -101,7 +101,7 @@ void tst_ObjectCount::controls() QVERIFY2(object.data(), qPrintable(component.errorString())); QList<QQuickItem *> items; - foreach (QObject *object, *qt_qobjects()) { + for (QObject *object : qAsConst(*qt_qobjects)) { QQuickItem *item = qobject_cast<QQuickItem *>(object); if (item) items += item; |