diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-07-10 15:45:10 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-08-03 21:05:14 +0300 |
commit | 44757c534b950e2fca2d56d0ab4228b4123cf080 (patch) | |
tree | 6d51e0f3e9877e177a528fb06ae5e755a1d61f4c /tests | |
parent | 266e6a3269ab16846de3d6cbce39aa226d45934c (diff) | |
download | qtlocation-44757c534b950e2fca2d56d0ab4228b4123cf080.tar.gz |
Eradicate Java-style iterators and mark the module free of them
... and of QLinkedList
Java-style iterators are going to be deprecated, or at the very least
banned from use in Qt code. Ditto QLinkedList.
Unfortunately, the module contains more than 120 uses of Q_FOREACH,
even though, according to my sources, its use was banned in Qt
implementation from the get-go. So QT_NO_FOREACH is currently not an
option.
Change-Id: I0f05e9c78dda259b0eac1bcdfc7dddfcddc4b908
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/geotestplugin/qplacemanagerengine_test.h | 18 | ||||
-rw-r--r-- | tests/auto/nokia_services/places_semiauto/tst_places.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp | 7 |
3 files changed, 9 insertions, 20 deletions
diff --git a/tests/auto/geotestplugin/qplacemanagerengine_test.h b/tests/auto/geotestplugin/qplacemanagerengine_test.h index f015afe7..0c707b65 100644 --- a/tests/auto/geotestplugin/qplacemanagerengine_test.h +++ b/tests/auto/geotestplugin/qplacemanagerengine_test.h @@ -574,11 +574,8 @@ public: m_categories.insert(category.categoryId(), category); QStringList children = m_childCategories.value(parentId); - QMutableHashIterator<QString, QStringList> i(m_childCategories); - while (i.hasNext()) { - i.next(); - i.value().removeAll(category.categoryId()); - } + for (QStringList &c : m_childCategories) + c.removeAll(category.categoryId()); if (!children.contains(category.categoryId())) { children.append(category.categoryId()); @@ -614,11 +611,8 @@ public: } else { m_categories.remove(categoryId); - QMutableHashIterator<QString, QStringList> i(m_childCategories); - while (i.hasNext()) { - i.next(); - i.value().removeAll(categoryId); - } + for (auto &c : m_childCategories) + c.removeAll(categoryId); } QMetaObject::invokeMethod(reply, "emitFinished", Qt::QueuedConnection); @@ -637,9 +631,7 @@ public: QString parentCategoryId(const QString &categoryId) const override { - QHashIterator<QString, QStringList> i(m_childCategories); - while (i.hasNext()) { - i.next(); + for (auto i = m_childCategories.cbegin(), end = m_childCategories.cend(); i != end; ++i) { if (i.value().contains(categoryId)) return i.key(); } diff --git a/tests/auto/nokia_services/places_semiauto/tst_places.cpp b/tests/auto/nokia_services/places_semiauto/tst_places.cpp index 2f68ab44..c198c616 100644 --- a/tests/auto/nokia_services/places_semiauto/tst_places.cpp +++ b/tests/auto/nokia_services/places_semiauto/tst_places.cpp @@ -610,9 +610,7 @@ void tst_QPlaceManagerNokia::content() QVERIFY(results.count() > 0); - QMapIterator<int, QPlaceContent> iter(results); - while (iter.hasNext()) { - iter.next(); + for (auto iter = results.cbegin(), end = results.cend(); iter != end; ++iter) { switch (type) { case (QPlaceContent::ImageType): { QPlaceImage image = iter.value(); diff --git a/tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp b/tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp index 5da6b4d4..c7189278 100644 --- a/tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp +++ b/tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp @@ -145,7 +145,7 @@ void tst_QGeoTiledMap::fetchTiles() m_tilesCounter->m_tiles.clear(); m_map->setCameraData(camera); waitForFetch(visibleCount); - QSet<QGeoTileSpec> visible = m_tilesCounter->m_tiles; + const QSet<QGeoTileSpec> visible = m_tilesCounter->m_tiles; m_map->clearData(); m_tilesCounter->m_tiles.clear(); m_map->prefetchData(); @@ -164,9 +164,8 @@ void tst_QGeoTiledMap::fetchTiles() QVERIFY2(visibleCount == visible.size(), "visible count incorrect"); QVERIFY2(prefetchCount == prefetched.size(), "prefetch count incorrect"); - QSetIterator<QGeoTileSpec> i(visible); - while (i.hasNext()) - QVERIFY2(prefetched.contains(i.next()),"visible tile missing from prefetched tiles"); + for (const QGeoTileSpec &tile : visible) + QVERIFY2(prefetched.contains(tile),"visible tile missing from prefetched tiles"); //for zoomLevels wihtout fractions more tiles are fetched for current zoomlevel due to ViewExpansion if (qCeil(zoomLevel) != zoomLevel && style == QGeoTiledMap::PrefetchNeighbourLayer && nearestNeighbourLayer < zoomLevel) |