diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-07-24 12:39:01 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-07-26 08:34:51 +0000 |
commit | da870b829cc860ca394af836733dbcc002016061 (patch) | |
tree | f9e1dc0774f43b2f621eac7654ec139ab00ba285 /src/plugins/geoservices/esri | |
parent | 7c00aa7aa1476fc45adc5abf54185545ecc4c14e (diff) | |
download | qtlocation-da870b829cc860ca394af836733dbcc002016061.tar.gz |
Replace foreach with ranged for and set QT_NO_FOREACH
Make containers const where they obviously should be, iterate over
references where it's clearly possible.
Cherry-pick of 2c8c5dca44aba5612cc67b04dd3c7e5fc4919b19.
Change-Id: Ie55a58873b48bbb60ac49790db612f85777e6ceb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins/geoservices/esri')
4 files changed, 11 insertions, 11 deletions
diff --git a/src/plugins/geoservices/esri/CMakeLists.txt b/src/plugins/geoservices/esri/CMakeLists.txt index 73eb89e0..97e8574a 100644 --- a/src/plugins/geoservices/esri/CMakeLists.txt +++ b/src/plugins/geoservices/esri/CMakeLists.txt @@ -22,6 +22,8 @@ qt_internal_add_plugin(GeoServiceProviderFactoryEsriPlugin Qt::Network Qt::LocationPrivate Qt::PositioningPrivate + DEFINES + QT_NO_FOREACH ) qt_add_resources(plugin_resource_files esri.qrc) diff --git a/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp index ed613f4b..52d92ac4 100644 --- a/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp +++ b/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp @@ -83,8 +83,7 @@ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteReque QUrlQuery query; QString stops; - foreach (const QGeoCoordinate &coordinate, request.waypoints()) - { + for (const QGeoCoordinate &coordinate : request.waypoints()) { if (!stops.isEmpty()) stops += "; "; diff --git a/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp index c5845848..f085726f 100644 --- a/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp +++ b/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp @@ -106,7 +106,7 @@ GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(const QVarian QList<QGeoMapType> mapTypes; - foreach (GeoMapSource *mapSource, m_mapSources) { + for (GeoMapSource *mapSource : m_mapSources) { mapTypes << QGeoMapType( mapSource->style(), mapSource->name(), @@ -267,7 +267,7 @@ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider: QVariantList mapSources = maps["mapSources"].toList(); - foreach (QVariant mapSourceElement, mapSources) { + for (const QVariant &mapSourceElement : mapSources) { QVariantMap mapSource = mapSourceElement.toMap(); int mapId = m_mapSources.count() + 1; @@ -290,7 +290,7 @@ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider: GeoMapSource *GeoTiledMappingManagerEngineEsri::mapSource(int mapId) const { - foreach (GeoMapSource *mapSource, mapSources()) { + for (GeoMapSource *mapSource : mapSources()) { if (mapSource->mapId() == mapId) return mapSource; } diff --git a/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/src/plugins/geoservices/esri/placemanagerengine_esri.cpp index 8f1e7dbc..b367a428 100644 --- a/src/plugins/geoservices/esri/placemanagerengine_esri.cpp +++ b/src/plugins/geoservices/esri/placemanagerengine_esri.cpp @@ -132,7 +132,7 @@ QPlaceSearchReply *PlaceManagerEngineEsri::search(const QPlaceSearchRequest &req QStringList categories; if (!request.categories().isEmpty()) { - foreach (const QPlaceCategory &placeCategory, request.categories()) + for (const QPlaceCategory &placeCategory : request.categories()) categories.append(placeCategory.categoryId()); queryItems.addQueryItem("category", categories.join(",")); } @@ -236,21 +236,21 @@ QPlaceCategory PlaceManagerEngineEsri::category(const QString &categoryId) const QList<QPlaceCategory> PlaceManagerEngineEsri::childCategories(const QString &parentId) const { QList<QPlaceCategory> categories; - foreach (const QString &id, m_subcategories.value(parentId)) + for (const QString &id : m_subcategories.value(parentId)) categories.append(m_categories.value(id)); return categories; } void PlaceManagerEngineEsri::finishCategories() { - foreach (PlaceCategoriesReplyEsri *reply, m_pendingCategoriesReply) + for (PlaceCategoriesReplyEsri *reply : m_pendingCategoriesReply) reply->emitFinished(); m_pendingCategoriesReply.clear(); } void PlaceManagerEngineEsri::errorCaterogies(const QString &error) { - foreach (PlaceCategoriesReplyEsri *reply, m_pendingCategoriesReply) + for (PlaceCategoriesReplyEsri *reply : m_pendingCategoriesReply) reply->setError(QPlaceReply::CommunicationError, error); } @@ -271,8 +271,7 @@ QString PlaceManagerEngineEsri::localizedName(const QJsonObject &jsonObject) { const QJsonObject localizedNames = jsonObject.value(kLocalizedNamesKey).toObject(); - foreach (const QLocale &locale, m_locales) - { + for (const QLocale &locale : qAsConst(m_locales)) { const QString localeStr = locale.name(); if (localizedNames.contains(localeStr)) { |