Skip to content

Commit

Permalink
Modernize iterators in offline editing
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 13, 2020
1 parent 7441141 commit a76c2dd
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -1453,9 +1453,8 @@ void QgsOfflineEditing::committedAttributesAdded( const QString &qgisLayerId, co
int layerId = getOrCreateLayerId( database.get(), qgisLayerId );
int commitNo = getCommitNo( database.get() );

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

for ( QgsFeatureIds::const_iterator it = deletedFeatureIds.begin(); it != deletedFeatureIds.end(); ++it )
for ( QgsFeatureId id : deletedFeatureIds )
{
if ( isAddedFeature( database.get(), layerId, *it ) )
if ( isAddedFeature( database.get(), layerId, id ) )
{
// remove from added features log
QString sql = QStringLiteral( "DELETE FROM 'log_added_features' WHERE \"layer_id\" = %1 AND \"fid\" = %2" ).arg( layerId ).arg( *it );
QString sql = QStringLiteral( "DELETE FROM 'log_added_features' WHERE \"layer_id\" = %1 AND \"fid\" = %2" ).arg( layerId ).arg( id );
sqlExec( database.get(), sql );
}
else
{
QString sql = QStringLiteral( "INSERT INTO 'log_removed_features' VALUES ( %1, %2)" )
.arg( layerId )
.arg( *it );
.arg( id );
sqlExec( database.get(), sql );
}
}
Expand Down

0 comments on commit a76c2dd

Please sign in to comment.