Skip to content

Commit 8f38e86

Browse files
committedMar 15, 2019
Make offline editing a Q_FOREACH free zone
1 parent 525f0f0 commit 8f38e86

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed
 

‎src/core/qgsofflineediting.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString &offlineDataPath,
105105
QMap<QString, QgsVectorJoinList > joinInfoBuffer;
106106
QMap<QString, QgsVectorLayer *> layerIdMapping;
107107

108-
Q_FOREACH ( const QString &layerId, layerIds )
108+
for ( const QString &layerId : layerIds )
109109
{
110110
QgsMapLayer *layer = QgsProject::instance()->mapLayer( layerId );
111111
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
@@ -161,7 +161,8 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString &offlineDataPath,
161161

162162
if ( newLayer )
163163
{
164-
Q_FOREACH ( QgsVectorLayerJoinInfo join, it.value() )
164+
const QList<QgsVectorLayerJoinInfo> joins = it.value();
165+
for ( QgsVectorLayerJoinInfo join : joins )
165166
{
166167
QgsVectorLayer *newJoinedLayer = layerIdMapping.value( join.joinLayerId() );
167168
if ( newJoinedLayer )
@@ -910,9 +911,9 @@ void QgsOfflineEditing::applyAttributesAdded( QgsVectorLayer *remoteLayer, sqlit
910911
void QgsOfflineEditing::applyFeaturesAdded( QgsVectorLayer *offlineLayer, QgsVectorLayer *remoteLayer, sqlite3 *db, int layerId )
911912
{
912913
QString sql = QStringLiteral( "SELECT \"fid\" FROM 'log_added_features' WHERE \"layer_id\" = %1" ).arg( layerId );
913-
QList<int> featureIdInts = sqlQueryInts( db, sql );
914+
const QList<int> featureIdInts = sqlQueryInts( db, sql );
914915
QgsFeatureIds newFeatureIds;
915-
Q_FOREACH ( int id, featureIdInts )
916+
for ( int id : featureIdInts )
916917
{
917918
newFeatureIds << id;
918919
}
@@ -1073,19 +1074,18 @@ void QgsOfflineEditing::copySymbology( QgsVectorLayer *sourceLayer, QgsVectorLay
10731074
void QgsOfflineEditing::updateRelations( QgsVectorLayer *sourceLayer, QgsVectorLayer *targetLayer )
10741075
{
10751076
QgsRelationManager *relationManager = QgsProject::instance()->relationManager();
1076-
QList<QgsRelation> relations;
1077-
relations = relationManager->referencedRelations( sourceLayer );
1077+
const QList<QgsRelation> referencedRelations = relationManager->referencedRelations( sourceLayer );
10781078

1079-
Q_FOREACH ( QgsRelation relation, relations )
1079+
for ( QgsRelation relation : referencedRelations )
10801080
{
10811081
relationManager->removeRelation( relation );
10821082
relation.setReferencedLayer( targetLayer->id() );
10831083
relationManager->addRelation( relation );
10841084
}
10851085

1086-
relations = relationManager->referencingRelations( sourceLayer );
1086+
const QList<QgsRelation> referencingRelations = relationManager->referencingRelations( sourceLayer );
10871087

1088-
Q_FOREACH ( QgsRelation relation, relations )
1088+
for ( QgsRelation relation : referencingRelations )
10891089
{
10901090
relationManager->removeRelation( relation );
10911091
relation.setReferencingLayer( targetLayer->id() );
@@ -1096,13 +1096,15 @@ void QgsOfflineEditing::updateRelations( QgsVectorLayer *sourceLayer, QgsVectorL
10961096
void QgsOfflineEditing::updateMapThemes( QgsVectorLayer *sourceLayer, QgsVectorLayer *targetLayer )
10971097
{
10981098
QgsMapThemeCollection *mapThemeCollection = QgsProject::instance()->mapThemeCollection();
1099-
QStringList mapThemeNames = mapThemeCollection->mapThemes();
1099+
const QStringList mapThemeNames = mapThemeCollection->mapThemes();
11001100

1101-
Q_FOREACH ( const QString &mapThemeName, mapThemeNames )
1101+
for ( const QString &mapThemeName : mapThemeNames )
11021102
{
11031103
QgsMapThemeCollection::MapThemeRecord record = mapThemeCollection->mapThemeState( mapThemeName );
11041104

1105-
Q_FOREACH ( QgsMapThemeCollection::MapThemeLayerRecord layerRecord, record.layerRecords() )
1105+
const auto layerRecords = record.layerRecords();
1106+
1107+
for ( QgsMapThemeCollection::MapThemeLayerRecord layerRecord : layerRecords )
11061108
{
11071109
if ( layerRecord.layer() == sourceLayer )
11081110
{

0 commit comments

Comments
 (0)
Please sign in to comment.