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 | |
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>
35 files changed, 116 insertions, 109 deletions
diff --git a/src/location/CMakeLists.txt b/src/location/CMakeLists.txt index 1410c193..f62fd315 100644 --- a/src/location/CMakeLists.txt +++ b/src/location/CMakeLists.txt @@ -191,6 +191,8 @@ qt_internal_add_module(Location Qt::PositioningQuickPrivate Qt::QmlPrivate Qt::QmlModelsPrivate + DEFINES + QT_NO_FOREACH GENERATE_CPP_EXPORTS GENERATE_PRIVATE_CPP_EXPORTS ) diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp index d239934b..ef537112 100644 --- a/src/location/declarativemaps/qdeclarativegeomap.cpp +++ b/src/location/declarativemaps/qdeclarativegeomap.cpp @@ -311,7 +311,7 @@ void QDeclarativeGeoMap::onSupportedMapTypesChanged() m_map->setActiveMapType(QGeoMapType()); // no supported map types: setting an invalid one } else { bool hasMapType = false; - foreach (QDeclarativeGeoMapType *declarativeType, m_supportedMapTypes) { + for (auto *declarativeType : m_supportedMapTypes) { if (declarativeType->mapType() == m_map->activeMapType()) hasMapType = true; } @@ -1972,7 +1972,7 @@ QList<QGeoMapObject *> QDeclarativeGeoMap::mapObjects() QList<QObject *> QDeclarativeGeoMap::mapItems() { QList<QObject *> ret; - foreach (const QPointer<QDeclarativeGeoMapItemBase> &ptr, m_mapItems) { + for (const auto &ptr : m_mapItems) { if (ptr) ret << ptr.data(); } diff --git a/src/location/declarativemaps/qdeclarativegeomapitembase.cpp b/src/location/declarativemaps/qdeclarativegeomapitembase.cpp index 8362940e..93e29242 100644 --- a/src/location/declarativemaps/qdeclarativegeomapitembase.cpp +++ b/src/location/declarativemaps/qdeclarativegeomapitembase.cpp @@ -102,10 +102,10 @@ QDeclarativeGeoMapItemBase::~QDeclarativeGeoMapItemBase() */ void QDeclarativeGeoMapItemBase::afterChildrenChanged() { - QList<QQuickItem *> kids = childItems(); + const QList<QQuickItem *> kids = childItems(); if (kids.size() > 0) { bool printedWarning = false; - foreach (QQuickItem *i, kids) { + for (auto *i : kids) { if (i->flags() & QQuickItem::ItemHasContents && !qobject_cast<QQuickMouseArea *>(i)) { if (!printedWarning) { diff --git a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp index 7dc934bf..6ef081f4 100644 --- a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp +++ b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp @@ -282,10 +282,10 @@ QQuickItem *QDeclarativeGeoMapQuickItem::sourceItem() */ void QDeclarativeGeoMapQuickItem::afterChildrenChanged() { - QList<QQuickItem *> kids = childItems(); + const QList<QQuickItem *> kids = childItems(); if (kids.size() > 0) { bool printedWarning = false; - foreach (QQuickItem *i, kids) { + for (auto *i : kids) { if (i->flags() & QQuickItem::ItemHasContents && !qobject_cast<QQuickMouseArea *>(i) && sourceItem_.data() != i diff --git a/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp b/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp index 239b0f50..ab4851c0 100644 --- a/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp +++ b/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp @@ -202,7 +202,7 @@ void QDeclarativeGeoServiceProvider::componentComplete() QStringList providers = QGeoServiceProvider::availableServiceProviders(); /* first check any preferred plugins */ - foreach (const QString &name, prefer_) { + for (const QString &name : prefer_) { if (providers.contains(name)) { // so we don't try it again later providers.removeAll(name); @@ -216,7 +216,7 @@ void QDeclarativeGeoServiceProvider::componentComplete() } /* then try the rest */ - foreach (const QString &name, providers) { + for (const QString &name : qAsConst(providers)) { QGeoServiceProvider sp(name, parameterMap(), experimental_); if (required_->matches(&sp)) { setName(name); diff --git a/src/location/declarativemaps/qgeomapitemgeometry.cpp b/src/location/declarativemaps/qgeomapitemgeometry.cpp index 9fe92287..ed96faa7 100644 --- a/src/location/declarativemaps/qgeomapitemgeometry.cpp +++ b/src/location/declarativemaps/qgeomapitemgeometry.cpp @@ -108,14 +108,14 @@ QRectF QGeoMapItemGeometry::translateToCommonOrigin(const QList<QGeoMapItemGeome // first get max offset QPointF maxOffset = geoms.at(0)->firstPointOffset(); - foreach (QGeoMapItemGeometry *g, geoms) { + for (const QGeoMapItemGeometry *g : geoms) { QPointF o = g->firstPointOffset(); maxOffset.setX(qMax(o.x(), maxOffset.x())); maxOffset.setY(qMax(o.y(), maxOffset.y())); } // then translate everything - foreach (QGeoMapItemGeometry *g, geoms) { + for (QGeoMapItemGeometry *g : geoms) { g->translate(maxOffset - g->firstPointOffset()); brects.addRect(g->sourceBoundingBox()); } diff --git a/src/location/declarativeplaces/qdeclarativeplace.cpp b/src/location/declarativeplaces/qdeclarativeplace.cpp index 75d23119..54473d13 100644 --- a/src/location/declarativeplaces/qdeclarativeplace.cpp +++ b/src/location/declarativeplaces/qdeclarativeplace.cpp @@ -400,7 +400,7 @@ QPlace QDeclarativePlace::place() // Categories QList<QPlaceCategory> categories; - foreach (QDeclarativeCategory *value, m_categories) + for (QDeclarativeCategory *value : qAsConst(m_categories)) categories.append(value->category()); result.setCategories(categories); @@ -419,11 +419,11 @@ QPlace QDeclarativePlace::place() //contact details QList<QPlaceContactDetail> cppDetails; - foreach (const QString &key, m_contactDetails->keys()) { + for (const QString &key : m_contactDetails->keys()) { cppDetails.clear(); if (m_contactDetails->value(key).typeId() == QMetaType::QVariantList) { - QVariantList detailsVarList = m_contactDetails->value(key).toList(); - foreach (const QVariant &detailVar, detailsVarList) { + const QVariantList detailsVarList = m_contactDetails->value(key).toList(); + for (const QVariant &detailVar : detailsVarList) { QDeclarativeContactDetail *detail = qobject_cast<QDeclarativeContactDetail *>(detailVar.value<QObject *>()); if (detail) cppDetails.append(detail->contactDetail()); @@ -724,7 +724,7 @@ void QDeclarativePlace::contactsModified(const QString &key, const QVariant &) */ void QDeclarativePlace::cleanupDeletedCategories() { - foreach (QDeclarativeCategory * category, m_categoriesToBeDeleted) { + for (QDeclarativeCategory * category : m_categoriesToBeDeleted) { if (category->parent() == this) delete category; } @@ -974,7 +974,7 @@ void QDeclarativePlace::synchronizeCategories() { qDeleteAll(m_categories); m_categories.clear(); - foreach (const QPlaceCategory &value, m_src.categories()) { + for (const QPlaceCategory &value : m_src.categories()) { QDeclarativeCategory *declarativeValue = new QDeclarativeCategory(value, m_plugin, this); m_categories.append(declarativeValue); } @@ -1081,12 +1081,12 @@ void QDeclarativePlace::initializeFavorite(QDeclarativeGeoServiceProvider *plugi */ void QDeclarativePlace::pullExtendedAttributes() { - QStringList keys = m_extendedAttributes->keys(); - foreach (const QString &key, keys) + const QStringList keys = m_extendedAttributes->keys(); + for (const QString &key : keys) m_extendedAttributes->clear(key); - QStringList attributeTypes = m_src.extendedAttributeTypes(); - foreach (const QString &attributeType, attributeTypes) { + const QStringList attributeTypes = m_src.extendedAttributeTypes(); + for (const QString &attributeType : attributeTypes) { m_extendedAttributes->insert(attributeType, QVariant::fromValue(new QDeclarativePlaceAttribute(m_src.extendedAttribute(attributeType)))); } @@ -1100,9 +1100,9 @@ void QDeclarativePlace::pullExtendedAttributes() void QDeclarativePlace::synchronizeContacts() { //clear out contact data - foreach (const QString &contactType, m_contactDetails->keys()) { - QList<QVariant> contacts = m_contactDetails->value(contactType).toList(); - foreach (const QVariant &var, contacts) { + for (const QString &contactType : m_contactDetails->keys()) { + const QList<QVariant> contacts = m_contactDetails->value(contactType).toList(); + for (const QVariant &var : contacts) { QObject *obj = var.value<QObject *>(); if (obj->parent() == this) delete obj; @@ -1111,10 +1111,10 @@ void QDeclarativePlace::synchronizeContacts() } //insert new contact data from source place - foreach (const QString &contactType, m_src.contactTypes()) { - QList<QPlaceContactDetail> sourceContacts = m_src.contactDetails(contactType); + for (const QString &contactType : m_src.contactTypes()) { + const QList<QPlaceContactDetail> sourceContacts = m_src.contactDetails(contactType); QVariantList declContacts; - foreach (const QPlaceContactDetail &sourceContact, sourceContacts) { + for (const QPlaceContactDetail &sourceContact : sourceContacts) { QDeclarativeContactDetail *declContact = new QDeclarativeContactDetail(this); declContact->setContactDetail(sourceContact); declContacts.append(QVariant::fromValue(qobject_cast<QObject *>(declContact))); diff --git a/src/location/declarativeplaces/qdeclarativeplaceicon.cpp b/src/location/declarativeplaces/qdeclarativeplaceicon.cpp index fa5b9df1..6df29671 100644 --- a/src/location/declarativeplaces/qdeclarativeplaceicon.cpp +++ b/src/location/declarativeplaces/qdeclarativeplaceicon.cpp @@ -118,7 +118,7 @@ QPlaceIcon QDeclarativePlaceIcon::icon() const result.setManager(0); QVariantMap params; - foreach (const QString &key, m_parameters->keys()) { + for (const QString &key : m_parameters->keys()) { const QVariant value = m_parameters->value(key); if (value.isValid()) { params.insert(key, value); @@ -241,10 +241,10 @@ QPlaceManager *QDeclarativePlaceIcon::manager() const void QDeclarativePlaceIcon::initParameters(const QVariantMap ¶meterMap) { //clear out old parameters - foreach (const QString &key, m_parameters->keys()) + for (const QString &key : m_parameters->keys()) m_parameters->clear(key); - foreach (const QString &key, parameterMap.keys()) { + for (const QString &key : parameterMap.keys()) { QVariant value = parameterMap.value(key); m_parameters->insert(key, value); } diff --git a/src/location/doc/snippets/places/requesthandler.h b/src/location/doc/snippets/places/requesthandler.h index 9aa5fe76..097a6a6d 100644 --- a/src/location/doc/snippets/places/requesthandler.h +++ b/src/location/doc/snippets/places/requesthandler.h @@ -314,7 +314,7 @@ public slots: //4) Have the slot appropriately process the results of the operation void processSearchReply() { if (searchReply->error() == QPlaceReply::NoError) { - foreach (const QPlaceSearchResult &result, searchReply->results()) { + for (const QPlaceSearchResult &result : searchReply->results()) { if (result.type() == QPlaceSearchResult::PlaceResult) qDebug() << "Title:" << result.title(); } @@ -329,7 +329,7 @@ public slots: //! [Search for places handler cpp] void handleSearchReply() { if (searchReply->error() == QPlaceReply::NoError) { - foreach (const QPlaceSearchResult &result, searchReply->results()) { + for (const QPlaceSearchResult &result : searchReply->results()) { if (result.type() == QPlaceSearchResult::PlaceResult) { QPlaceResult placeResult = result; qDebug() << "Name: " << placeResult.place().name(); @@ -367,7 +367,7 @@ public slots: } //alternatively if indexes are irrelevant - foreach (const QPlaceImage &image, contentReply->content()) { + for (const QPlaceImage &image : contentReply->content()) { qDebug() << image.url(); qDebug() << image.mimeType(); } @@ -387,7 +387,7 @@ public slots: //! [Suggestion handler] void handleSuggestionReply() { if (suggestionReply->error() == QPlaceReply::NoError) { - foreach (const QString &suggestion, suggestionReply->suggestions()) + for (const QString &suggestion : suggestionReply->suggestions()) qDebug() << suggestion; } @@ -433,8 +433,8 @@ public slots: void categories() { QPlaceCategory pizza; //! [Top level categories] - QList<QPlaceCategory> topLevelCategories = manager->childCategories(); - foreach (const QPlaceCategory &category, topLevelCategories) + const QList<QPlaceCategory> topLevelCategories = manager->childCategories(); + for (const QPlaceCategory &category : topLevelCategories) qDebug() << category.name(); //! [Top level categories] @@ -477,7 +477,7 @@ public slots: void phoneNumbers() { //! [Phone numbers] if (place.contactTypes().contains(QPlaceContactDetail::Phone)) { - foreach (const QPlaceContactDetail &number, place.contactDetails(QPlaceContactDetail::Phone)) + for (const QPlaceContactDetail &number : place.contactDetails(QPlaceContactDetail::Phone)) qDebug() << number.label() << ":" << number.value(); } //! [Phone numbers] @@ -494,7 +494,7 @@ public slots: //! [Match places handler] void matchHandler() { if (matchReply->error() == QPlaceReply::NoError) { - foreach (const QPlace place, matchReply->places()) { + for (const QPlace place : matchReply->places()) { if (place != QPlace()) qDebug() << "Place is a favorite with name" << place.name(); else diff --git a/src/location/maps/qgeofiletilecache.cpp b/src/location/maps/qgeofiletilecache.cpp index b4049897..251b3237 100644 --- a/src/location/maps/qgeofiletilecache.cpp +++ b/src/location/maps/qgeofiletilecache.cpp @@ -106,10 +106,10 @@ void QGeoFileTileCache::init() QDir baseDir(basePath); if (baseDir.exists()) { const QStringList oldCacheFiles = baseDir.entryList(QDir::Files); - foreach (const QString& file, oldCacheFiles) + for (const QString& file : oldCacheFiles) baseDir.remove(file); const QStringList oldCacheDirs = { QStringLiteral("osm"), QStringLiteral("mapbox"), QStringLiteral("here") }; - foreach (const QString& d, oldCacheDirs) { + for (const QString& d : oldCacheDirs) { QDir oldCacheDir(basePath + QLatin1Char('/') + d); if (oldCacheDir.exists()) oldCacheDir.removeRecursively(); @@ -222,7 +222,7 @@ QGeoFileTileCache::~QGeoFileTileCache() } QList<QSharedPointer<QGeoCachedTileDisk> > queue; diskCache_.serializeQueue(i, queue); - foreach (const QSharedPointer<QGeoCachedTileDisk> &tile, queue) { + for (const QSharedPointer<QGeoCachedTileDisk> &tile : queue) { if (tile.isNull()) continue; @@ -312,7 +312,7 @@ void QGeoFileTileCache::clearAll() QDir dir(directory_); dir.setNameFilters(QStringList() << QLatin1String("*-*-*-*.*")); dir.setFilter(QDir::Files); - foreach (QString dirFile, dir.entryList()) { + for (const QString &dirFile : dir.entryList()) { dir.remove(dirFile); } } diff --git a/src/location/maps/qgeorouteparserosrmv4.cpp b/src/location/maps/qgeorouteparserosrmv4.cpp index 35dda62b..a24ae2db 100644 --- a/src/location/maps/qgeorouteparserosrmv4.cpp +++ b/src/location/maps/qgeorouteparserosrmv4.cpp @@ -390,7 +390,7 @@ QUrl QGeoRouteParserOsrmV4Private::requestUrl(const QGeoRouteRequest &request, c query.addQueryItem(QStringLiteral("instructions"), QStringLiteral("true")); - foreach (const QGeoCoordinate &c, request.waypoints()) { + for (const QGeoCoordinate &c : request.waypoints()) { query.addQueryItem(QStringLiteral("loc"), QString::number(c.latitude()) + QLatin1Char(',') + QString::number(c.longitude())); } diff --git a/src/location/maps/qgeorouteparserosrmv5.cpp b/src/location/maps/qgeorouteparserosrmv5.cpp index 895b541d..151e065f 100644 --- a/src/location/maps/qgeorouteparserosrmv5.cpp +++ b/src/location/maps/qgeorouteparserosrmv5.cpp @@ -996,7 +996,7 @@ QGeoRouteReply::Error QGeoRouteParserOsrmV5Private::parseReply(QList<QGeoRoute> if (!error) { QList<QGeoCoordinate> path; - foreach (const QGeoRouteSegment &s, segments) + for (const QGeoRouteSegment &s : segments) path.append(s.path()); for (int i = segments.size() - 1; i > 0; --i) diff --git a/src/location/maps/qgeoserviceprovider.cpp b/src/location/maps/qgeoserviceprovider.cpp index b1582026..50d91230 100644 --- a/src/location/maps/qgeoserviceprovider.cpp +++ b/src/location/maps/qgeoserviceprovider.cpp @@ -286,8 +286,8 @@ Flags QGeoServiceProviderPrivate::features(const char *enumName) Flags ret = typename Flags::enum_type(0); if (this->metaData.contains(QStringLiteral("Features")) && this->metaData.value(QStringLiteral("Features")).isArray()) { - QCborArray features = this->metaData.value(QStringLiteral("Features")).toArray(); - for (const QCborValueRef v : features) { + const QCborArray features = this->metaData.value(QStringLiteral("Features")).toArray(); + for (const QCborValueConstRef v : features) { int val = en.keyToValue(v.toString().toLatin1().constData()); if (v.isString() && val != -1) { ret |= typename Flags::enum_type(val); diff --git a/src/location/places/qplacematchrequest.cpp b/src/location/places/qplacematchrequest.cpp index bd953f03..17b66e42 100644 --- a/src/location/places/qplacematchrequest.cpp +++ b/src/location/places/qplacematchrequest.cpp @@ -212,7 +212,7 @@ void QPlaceMatchRequest::setResults(const QList<QPlaceSearchResult> &results) { Q_D(QPlaceMatchRequest); QList<QPlace> places; - foreach (const QPlaceSearchResult &result, results) { + for (const QPlaceSearchResult &result : results) { if (result.type() == QPlaceSearchResult::PlaceResult) { QPlaceResult placeResult = result; places.append(placeResult.place()); 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)) { diff --git a/src/plugins/geoservices/itemsoverlay/CMakeLists.txt b/src/plugins/geoservices/itemsoverlay/CMakeLists.txt index 25ab9d8d..f06f3119 100644 --- a/src/plugins/geoservices/itemsoverlay/CMakeLists.txt +++ b/src/plugins/geoservices/itemsoverlay/CMakeLists.txt @@ -10,6 +10,8 @@ qt_internal_add_plugin(QGeoServiceProviderFactoryItemsOverlayPlugin Qt::Core Qt::LocationPrivate Qt::PositioningPrivate + DEFINES + QT_NO_FOREACH ) qt_internal_extend_target(QGeoServiceProviderFactoryItemsOverlayPlugin diff --git a/src/plugins/geoservices/mapbox/CMakeLists.txt b/src/plugins/geoservices/mapbox/CMakeLists.txt index 0080ee05..10b886bb 100644 --- a/src/plugins/geoservices/mapbox/CMakeLists.txt +++ b/src/plugins/geoservices/mapbox/CMakeLists.txt @@ -22,6 +22,8 @@ qt_internal_add_plugin(QGeoServiceProviderFactoryMapboxPlugin Qt::Network Qt::LocationPrivate Qt::PositioningPrivate + DEFINES + QT_NO_FOREACH ) qt_add_resources(plugin_resource_files mapbox.qrc) diff --git a/src/plugins/geoservices/nokia/CMakeLists.txt b/src/plugins/geoservices/nokia/CMakeLists.txt index 9eac5e6b..4edabfd6 100644 --- a/src/plugins/geoservices/nokia/CMakeLists.txt +++ b/src/plugins/geoservices/nokia/CMakeLists.txt @@ -36,6 +36,8 @@ qt_internal_add_plugin(QGeoServiceProviderFactoryNokiaPlugin Qt::Network Qt::LocationPrivate Qt::PositioningPrivate + DEFINES + QT_NO_FOREACH ) qt_add_resources(plugin_resource_files nokia.qrc) diff --git a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp index cdec141d..918e8147 100644 --- a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp @@ -57,7 +57,7 @@ QGeoRouteReplyNokia::QGeoRouteReplyNokia(const QGeoRouteRequest &request, qRegisterMetaType<QList<QGeoRoute> >(); bool failure = false; - foreach (QNetworkReply *reply, replies) { + for (QNetworkReply *reply : replies) { if (!reply) { failure = true; continue; diff --git a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp index 9e33fa85..72ef9d38 100644 --- a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp @@ -121,7 +121,7 @@ QGeoRouteReply *QGeoRoutingManagerEngineNokia::calculateRoute(const QGeoRouteReq } QList<QNetworkReply*> replies; - foreach (const QString &reqString, reqStrings) + for (const QString &reqString : reqStrings) replies.append(m_networkManager->get(QNetworkRequest(QUrl(reqString)))); QGeoRouteReplyNokia *reply = new QGeoRouteReplyNokia(request, replies, this); @@ -150,7 +150,7 @@ QGeoRouteReply *QGeoRoutingManagerEngineNokia::updateRoute(const QGeoRoute &rout } QList<QNetworkReply*> replies; - foreach (const QString &reqString, reqStrings) + for (const QString &reqString : reqStrings) replies.append(m_networkManager->get(QNetworkRequest(QUrl(reqString)))); QGeoRouteRequest updateRequest(route.request()); @@ -268,7 +268,7 @@ QStringList QGeoRoutingManagerEngineNokia::calculateRouteRequestString(const QGe if (optimization.testFlag(QGeoRouteRequest::FastestRoute)) types.append("fastest"); - foreach (const QString &optimization, types) { + for (const QString &optimization : types) { QString requestString = baseRequest; requestString += modesRequestString(request, request.travelModes(), optimization); requestString += routeRequestString(request); @@ -304,7 +304,7 @@ QStringList QGeoRoutingManagerEngineNokia::updateRouteRequestString(const QGeoRo if (optimization.testFlag(QGeoRouteRequest::FastestRoute)) types.append("fastest"); - foreach (const QString &optimization, types) { + for (const QString &optimization : types) { QString requestString = baseRequest; requestString += modesRequestString(route.request(), route.travelMode(), optimization); requestString += routeRequestString(route.request()); @@ -391,7 +391,7 @@ QString QGeoRoutingManagerEngineNokia::routeRequestString(const QGeoRouteRequest { QString requestString; - foreach (const QGeoRectangle &area, request.excludeAreas()) { + for (const QGeoRectangle &area : request.excludeAreas()) { requestString += QLatin1String("&avoidareas="); requestString += trimDouble(area.topLeft().latitude()); requestString += QLatin1String(","); diff --git a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp index 3b232630..9c433a30 100644 --- a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp @@ -62,7 +62,7 @@ namespace if (param.length() > 512) return false; - foreach (QChar c, param) { + for (const auto &c : param) { if (!c.isLetterOrNumber() && c.toLatin1() != '%' && c.toLatin1() != '-' && c.toLatin1() != '+' && c.toLatin1() != '_') { return false; diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp index cd3182d9..a7faf26d 100644 --- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp @@ -305,7 +305,7 @@ void QGeoTiledMappingManagerEngineNokia::parseNewVersionInfo(const QByteArray &v const QStringList versionLines = versionString.split(QLatin1Char('\n')); QJsonObject newVersionData; - foreach (const QString &line, versionLines) { + for (const QString &line : versionLines) { const QStringList versionInfo = line.split(':'); if (versionInfo.size() > 1) { const QString versionKey = versionInfo[0].trimmed(); @@ -436,7 +436,7 @@ QString QGeoTiledMappingManagerEngineNokia::evaluateCopyrightsText(const QGeoMap } } - foreach (const QString ©rightString, copyrightStrings) { + for (const QString ©rightString : copyrightStrings) { if (copyrightsText.length()) copyrightsText += QLatin1Char('\n'); copyrightsText += copyrightSymbol; diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp index 2c97a7b6..89766cfc 100644 --- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp +++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp @@ -400,9 +400,9 @@ QPlaceSearchReply *QPlaceManagerEngineNokiaV2::search(const QPlaceSearchRequest QUrl u = query.searchContext().value<QUrl>(); typedef QPair<QString, QString> QueryItem; - QList<QueryItem> queryItemList = queryItems.queryItems(QUrl::FullyEncoded); + const QList<QueryItem> queryItemList = queryItems.queryItems(QUrl::FullyEncoded); queryItems = QUrlQuery(u); - foreach (const QueryItem &item, queryItemList) + for (const QueryItem &item : queryItemList) queryItems.addQueryItem(item.first, item.second); if (query.limit() > 0) @@ -450,7 +450,7 @@ QPlaceSearchReply *QPlaceManagerEngineNokiaV2::search(const QPlaceSearchRequest QStringLiteral("/places/v1/discover/explore")); QStringList ids; - foreach (const QPlaceCategory &category, query.categories()) + for (const QPlaceCategory &category : query.categories()) ids.append(category.categoryId()); QUrlQuery queryItems; @@ -673,7 +673,7 @@ QPlaceCategory QPlaceManagerEngineNokiaV2::category(const QString &categoryId) c QList<QPlaceCategory> QPlaceManagerEngineNokiaV2::childCategories(const QString &parentId) const { QList<QPlaceCategory> results; - foreach (const QString &childId, m_categoryTree.value(parentId).childIds) + for (const QString &childId : m_categoryTree.value(parentId).childIds) results.append(m_categoryTree.value(childId).category); return results; } @@ -709,7 +709,7 @@ QPlaceIcon QPlaceManagerEngineNokiaV2::icon(const QString &remotePath, params.insert(NokiaIcon, nokiaIcon); params.insert(IconPrefix, iconPrefix); - foreach (const QPlaceCategory &category, categories) { + for (const QPlaceCategory &category : categories) { if (category.icon().parameters().value(NokiaIcon) == nokiaIcon) { params.insert(NokiaIconGenerated, true); break; @@ -857,7 +857,7 @@ QByteArray QPlaceManagerEngineNokiaV2::createLanguageString() const if (locales.isEmpty()) locales << QLocale(); - foreach (const QLocale &loc, locales) { + for (const QLocale &loc : qAsConst(locales)) { language.append(loc.name().replace(2, 1, QLatin1Char('-')).toLatin1()); language.append(", "); } diff --git a/src/plugins/geoservices/osm/CMakeLists.txt b/src/plugins/geoservices/osm/CMakeLists.txt index ad6811b5..4cc55042 100644 --- a/src/plugins/geoservices/osm/CMakeLists.txt +++ b/src/plugins/geoservices/osm/CMakeLists.txt @@ -22,6 +22,8 @@ qt_internal_add_plugin(QGeoServiceProviderFactoryOsmPlugin Qt::Network Qt::LocationPrivate Qt::PositioningPrivate + DEFINES + QT_NO_FOREACH ) qt_internal_extend_target(QGeoServiceProviderFactoryOsmPlugin diff --git a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp index b9b3f476..dd5d7092 100644 --- a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp +++ b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp @@ -376,7 +376,7 @@ void QGeoTiledMappingManagerEngineOsm::onProviderResolutionError(const QGeoTileP void QGeoTiledMappingManagerEngineOsm::updateMapTypes() { QList<QGeoMapType> mapTypes; - foreach (QGeoTileProviderOsm * provider, m_providers) { + for (QGeoTileProviderOsm * provider : m_providers) { // assume provider are ok until they have been resolved invalid if (!provider->isResolved() || provider->isValid()) mapTypes << provider->mapType(); diff --git a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp index 49c41bcb..b23b6ac5 100644 --- a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp +++ b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE static bool providersResolved(const QList<QGeoTileProviderOsm *> &providers) { - foreach (const QGeoTileProviderOsm *provider, providers) + for (const QGeoTileProviderOsm *provider : providers) if (!provider->isResolved()) return false; return true; @@ -84,7 +84,7 @@ QGeoTileFetcherOsm::QGeoTileFetcherOsm(const QList<QGeoTileProviderOsm *> &provi m_ready(true) { m_nm->setParent(this); - foreach (QGeoTileProviderOsm *provider, m_providers) { + for (QGeoTileProviderOsm *provider : m_providers) { if (!provider->isResolved()) { m_ready = false; connect(provider, &QGeoTileProviderOsm::resolutionFinished, @@ -108,7 +108,7 @@ void QGeoTileFetcherOsm::setUserAgent(const QByteArray &userAgent) bool QGeoTileFetcherOsm::initialized() const { if (!m_ready) { - foreach (QGeoTileProviderOsm *provider, m_providers) + for (QGeoTileProviderOsm *provider : m_providers) if (!provider->isResolved()) provider->resolveProvider(); } diff --git a/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp b/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp index c0d467f4..8c29652c 100644 --- a/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp +++ b/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp @@ -158,7 +158,7 @@ QPlaceSearchReply *QPlaceManagerEngineOsm::search(const QPlaceSearchRequest &req if (!request.searchTerm().isEmpty()) queryParts.append(request.searchTerm()); - foreach (const QPlaceCategory &category, request.categories()) { + for (const QPlaceCategory &category : request.categories()) { QString id = category.categoryId(); int index = id.indexOf(QLatin1Char('=')); if (index != -1) @@ -239,7 +239,7 @@ QPlaceCategory QPlaceManagerEngineOsm::category(const QString &categoryId) const QList<QPlaceCategory> QPlaceManagerEngineOsm::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; } @@ -315,14 +315,14 @@ void QPlaceManagerEngineOsm::categoryReplyFinished() m_categoryLocales.clear(); } - foreach (QPlaceCategoriesReplyOsm *reply, m_pendingCategoriesReply) + for (QPlaceCategoriesReplyOsm *reply : m_pendingCategoriesReply) reply->emitFinished(); m_pendingCategoriesReply.clear(); } void QPlaceManagerEngineOsm::categoryReplyError() { - foreach (QPlaceCategoriesReplyOsm *reply, m_pendingCategoriesReply) + for (QPlaceCategoriesReplyOsm *reply : m_pendingCategoriesReply) reply->setError(QPlaceReply::CommunicationError, tr("Network request error")); } diff --git a/tests/auto/geotestplugin/qplacemanagerengine_test.h b/tests/auto/geotestplugin/qplacemanagerengine_test.h index 45f52a2c..5f35fb37 100644 --- a/tests/auto/geotestplugin/qplacemanagerengine_test.h +++ b/tests/auto/geotestplugin/qplacemanagerengine_test.h @@ -463,7 +463,7 @@ public: QList<QPlaceSearchResult> results; if (!query.searchTerm().isEmpty()) { - foreach (const QPlace &place, m_places) { + for (const QPlace &place : m_places) { if (!place.name().contains(query.searchTerm(), Qt::CaseInsensitive)) continue; @@ -489,8 +489,8 @@ public: results.append(r); } } else if (!query.recommendationId().isEmpty()) { - QStringList recommendations = m_placeRecommendations.value(query.recommendationId()); - foreach (const QString &id, recommendations) { + const QStringList recommendations = m_placeRecommendations.value(query.recommendationId()); + for (const QString &id : recommendations) { QPlaceResult r; r.setPlace(m_places.value(id)); r.setTitle(r.place().name()); @@ -653,7 +653,7 @@ public: { QList<QPlaceCategory> categories; - foreach (const QString &id, m_childCategories.value(parentId)) + for (const QString &id : m_childCategories.value(parentId)) categories.append(m_categories.value(id)); return categories; @@ -678,11 +678,8 @@ public: sizeDictionary.insert(QStringLiteral("m"), 30); sizeDictionary.insert(QStringLiteral("l"), 50); - QStringList sizeKeys; - sizeKeys << QStringLiteral("s") << QStringLiteral("m") << QStringLiteral("l"); - - foreach (const QString &sizeKey, sizeKeys) - { + const QStringList sizeKeys = { QStringLiteral("s"), QStringLiteral("m"), QStringLiteral("l") }; + for (const QString &sizeKey : sizeKeys) { if (icon.parameters().contains(sizeKey)) candidates.append(QPair<int, QUrl>(sizeDictionary.value(sizeKey), icon.parameters().value(sizeKey).toUrl())); diff --git a/tests/auto/nokia_services/places_semiauto/tst_places.cpp b/tests/auto/nokia_services/places_semiauto/tst_places.cpp index c198c616..072d4bf4 100644 --- a/tests/auto/nokia_services/places_semiauto/tst_places.cpp +++ b/tests/auto/nokia_services/places_semiauto/tst_places.cpp @@ -380,12 +380,12 @@ void tst_QPlaceManagerNokia::details() QVERIFY(doFetchDetails(ValidKnownPlaceId, &place)); QVERIFY(!place.name().isEmpty()); QVERIFY(!place.icon().url().isEmpty()); - QStringList contactTypes = place.contactTypes(); + const QStringList contactTypes = place.contactTypes(); QVERIFY(!contactTypes.isEmpty()); - foreach (const QString &contactType, contactTypes) { - QList<QPlaceContactDetail> details = place.contactDetails(contactType); + for (const QString &contactType : contactTypes) { + const QList<QPlaceContactDetail> details = place.contactDetails(contactType); QVERIFY(details.count() > 0); - foreach (const QPlaceContactDetail &detail, details) { + for (const QPlaceContactDetail &detail : details) { QVERIFY(!detail.label().isEmpty()); QVERIFY(!detail.value().isEmpty()); } @@ -401,7 +401,7 @@ void tst_QPlaceManagerNokia::details() QVERIFY(place.ratings().count() > 0); QVERIFY(place.categories().count() > 0); - foreach (const QPlaceCategory &category, place.categories()) { + for (const QPlaceCategory &category : place.categories()) { QVERIFY(!category.name().isEmpty()); QVERIFY(!category.categoryId().isEmpty()); QVERIFY(!category.icon().url().isEmpty()); @@ -424,7 +424,7 @@ void tst_QPlaceManagerNokia::categories() QList<QPlaceCategory> categories = placeManager->childCategories(); QVERIFY(categories.count() > 0); - foreach (const QPlaceCategory &category, categories) { + for (const QPlaceCategory &category : categories) { //check that we have valid fields QVERIFY(!category.categoryId().isEmpty()); QVERIFY(!category.name().isEmpty()); @@ -438,7 +438,7 @@ void tst_QPlaceManagerNokia::categories() const QList<QPlaceCategory> childCats = placeManager->childCategories(category.categoryId()); if (!childCats.isEmpty()) { - foreach (const QPlaceCategory &child, childCats) { + for (const QPlaceCategory &child : childCats) { // only two levels of categories hence 2.nd level has no further children QVERIFY(placeManager->childCategories(child.categoryId()).isEmpty()); QVERIFY(placeManager->parentCategoryId(child.categoryId()) == category.categoryId()); @@ -562,15 +562,15 @@ void tst_QPlaceManagerNokia::locale() //check that we can set different locales for the categories placeManager->setLocale(QLocale("en")); QVERIFY(doInitializeCategories()); - QList<QPlaceCategory> enCategories = placeManager->childCategories(); + const QList<QPlaceCategory> enCategories = placeManager->childCategories(); QVERIFY(enCategories.count() > 0); placeManager->setLocale(QLocale("fi")); QVERIFY(doInitializeCategories()); - QList<QPlaceCategory> fiCategories = placeManager->childCategories(); + const QList<QPlaceCategory> fiCategories = placeManager->childCategories(); - foreach (const QPlaceCategory enCat, enCategories) { - foreach (const QPlaceCategory fiCat, fiCategories) { + for (const QPlaceCategory &enCat : enCategories) { + for (const QPlaceCategory &fiCat : fiCategories) { if (enCat.categoryId() == fiCat.categoryId()) { QVERIFY(fiCat.name() != enCat.name()); QVERIFY(fiCat == placeManager->category(fiCat.categoryId())); diff --git a/tests/auto/nokia_services/routing/tst_routing.cpp b/tests/auto/nokia_services/routing/tst_routing.cpp index f2279f26..626eaaf2 100644 --- a/tests/auto/nokia_services/routing/tst_routing.cpp +++ b/tests/auto/nokia_services/routing/tst_routing.cpp @@ -261,7 +261,7 @@ void tst_nokia_routing::verifySaneRoute(const QGeoRoute& route) const QList<QGeoCoordinate> path = route.path(); QVERIFY(path.size() >= 2); - foreach (const QGeoCoordinate& coord, path) { + for (const QGeoCoordinate& coord : path) { QVERIFY(coord.isValid()); QVERIFY(bounds.contains(coord)); } @@ -278,7 +278,7 @@ void tst_nokia_routing::verifySaneRoute(const QGeoRoute& route) QVERIFY(segment.travelTime() >= 0); // times are rounded and thus may end up being zero const QList<QGeoCoordinate> path = segment.path(); - foreach (const QGeoCoordinate& coord, path) { + for (const QGeoCoordinate& coord : path) { QVERIFY(coord.isValid()); if (!first && !last) { QVERIFY(bounds.contains(coord)); // on pt and pedestrian diff --git a/tests/auto/placemanager_utils/placemanager_utils.cpp b/tests/auto/placemanager_utils/placemanager_utils.cpp index d5ba61f1..33cbab9e 100644 --- a/tests/auto/placemanager_utils/placemanager_utils.cpp +++ b/tests/auto/placemanager_utils/placemanager_utils.cpp @@ -72,7 +72,7 @@ void PlaceManagerUtils::doSavePlaces(QPlaceManager *manager, QList<QPlace> &plac { QPlaceIdReply *saveReply; - foreach (QPlace place, places) { + for (const auto &place : places) { saveReply = manager->savePlace(place); QSignalSpy saveSpy(saveReply, SIGNAL(finished())); QTRY_VERIFY_WITH_TIMEOUT(saveSpy.count() == 1, Timeout); @@ -86,7 +86,7 @@ void PlaceManagerUtils::doSavePlaces(QPlaceManager *manager, const QList<QPlace QPlaceIdReply *saveReply; static int count= 0; - foreach (QPlace *place, places) { + for (QPlace *place : places) { count++; saveReply = manager->savePlace(*place); QSignalSpy saveSpy(saveReply, SIGNAL(finished())); @@ -116,7 +116,7 @@ bool PlaceManagerUtils::doSearch(QPlaceManager *manager, results->clear(); QList<QPlaceSearchResult> searchResults; success = doSearch(manager, request, &searchResults, expectedError); - foreach (const QPlaceSearchResult &searchResult, searchResults) { + for (const QPlaceSearchResult &searchResult : searchResults) { if (searchResult.type() == QPlaceSearchResult::PlaceResult) { QPlaceResult placeResult = searchResult; results->append(placeResult.place()); @@ -351,11 +351,11 @@ bool PlaceManagerUtils::compare(const QList<QPlace> &actualResults, const QList<QPlace> &expectedResults) { QSet<QString> actualIds; - foreach (const QPlace &place, actualResults) + for (const QPlace &place : actualResults) actualIds.insert(place.placeId()); QSet<QString> expectedIds; - foreach (const QPlace &place, expectedResults) + for (const QPlace &place : expectedResults) expectedIds.insert(place.placeId()); bool isMatch = (actualIds == expectedIds); @@ -371,6 +371,6 @@ bool PlaceManagerUtils::compare(const QList<QPlace> &actualResults, void PlaceManagerUtils::setVisibility(QList<QPlace *> places, QLocation::Visibility visibility) { - foreach (QPlace *place, places) + for (QPlace *place : places) place->setVisibility(visibility); } diff --git a/tests/auto/qplace/tst_qplace.cpp b/tests/auto/qplace/tst_qplace.cpp index bc865994..419328a1 100644 --- a/tests/auto/qplace/tst_qplace.cpp +++ b/tests/auto/qplace/tst_qplace.cpp @@ -541,7 +541,7 @@ void tst_Place::extendedAttributeTest() QCOMPARE(place.extendedAttribute(QStringLiteral("shelter")).text(), QStringLiteral("No")); //test clearing of attributes by setting them to the default attribute - foreach (const QString &attributeType, place.extendedAttributeTypes()) + for (const QString &attributeType : place.extendedAttributeTypes()) place.setExtendedAttribute(attributeType, QPlaceAttribute()); QCOMPARE(place.extendedAttributeTypes().count(), 0); |