Skip to content

Commit a76c2dd

Browse files
committedMar 13, 2020
Modernize iterators in offline editing
1 parent 7441141 commit a76c2dd

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed
 

‎src/core/qgsofflineediting.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,9 +1453,8 @@ void QgsOfflineEditing::committedAttributesAdded( const QString &qgisLayerId, co
14531453
int layerId = getOrCreateLayerId( database.get(), qgisLayerId );
14541454
int commitNo = getCommitNo( database.get() );
14551455

1456-
for ( QList<QgsField>::const_iterator it = addedAttributes.begin(); it != addedAttributes.end(); ++it )
1456+
for ( const QgsField &field : addedAttributes )
14571457
{
1458-
QgsField field = *it;
14591458
QString sql = QStringLiteral( "INSERT INTO 'log_added_attrs' VALUES ( %1, %2, '%3', %4, %5, %6, '%7' )" )
14601459
.arg( layerId )
14611460
.arg( commitNo )
@@ -1516,19 +1515,19 @@ void QgsOfflineEditing::committedFeaturesRemoved( const QString &qgisLayerId, co
15161515
// insert log
15171516
int layerId = getOrCreateLayerId( database.get(), qgisLayerId );
15181517

1519-
for ( QgsFeatureIds::const_iterator it = deletedFeatureIds.begin(); it != deletedFeatureIds.end(); ++it )
1518+
for ( QgsFeatureId id : deletedFeatureIds )
15201519
{
1521-
if ( isAddedFeature( database.get(), layerId, *it ) )
1520+
if ( isAddedFeature( database.get(), layerId, id ) )
15221521
{
15231522
// remove from added features log
1524-
QString sql = QStringLiteral( "DELETE FROM 'log_added_features' WHERE \"layer_id\" = %1 AND \"fid\" = %2" ).arg( layerId ).arg( *it );
1523+
QString sql = QStringLiteral( "DELETE FROM 'log_added_features' WHERE \"layer_id\" = %1 AND \"fid\" = %2" ).arg( layerId ).arg( id );
15251524
sqlExec( database.get(), sql );
15261525
}
15271526
else
15281527
{
15291528
QString sql = QStringLiteral( "INSERT INTO 'log_removed_features' VALUES ( %1, %2)" )
15301529
.arg( layerId )
1531-
.arg( *it );
1530+
.arg( id );
15321531
sqlExec( database.get(), sql );
15331532
}
15341533
}

0 commit comments

Comments
 (0)
Please sign in to comment.