Skip to content

Commit

Permalink
Use range-based for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 20, 2018
1 parent eb7f755 commit a75fa25
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/gui/qgsmaptoolidentify.cpp
Expand Up @@ -244,8 +244,6 @@ bool QgsMapToolIdentify::identifyVectorLayer( QList<IdentifyResult> *results, Qg
QgsDebugMsg( QString( "Caught CRS exception %1" ).arg( cse.what() ) ); QgsDebugMsg( QString( "Caught CRS exception %1" ).arg( cse.what() ) );
} }


QgsFeatureList::iterator f_it = featureList.begin();

bool filter = false; bool filter = false;


QgsRenderContext context( QgsRenderContext::fromMapSettings( mCanvas->mapSettings() ) ); QgsRenderContext context( QgsRenderContext::fromMapSettings( mCanvas->mapSettings() ) );
Expand All @@ -258,23 +256,23 @@ bool QgsMapToolIdentify::identifyVectorLayer( QList<IdentifyResult> *results, Qg
filter = renderer->capabilities() & QgsFeatureRenderer::Filter; filter = renderer->capabilities() & QgsFeatureRenderer::Filter;
} }


for ( ; f_it != featureList.end(); ++f_it ) for ( const QgsFeature &feature : qgis::as_const( featureList ) )
{ {
QMap< QString, QString > derivedAttributes = commonDerivedAttributes; QMap< QString, QString > derivedAttributes = commonDerivedAttributes;


QgsFeatureId fid = f_it->id(); QgsFeatureId fid = feature.id();
context.expressionContext().setFeature( *f_it ); context.expressionContext().setFeature( feature );


if ( filter && !renderer->willRenderFeature( *f_it, context ) ) if ( filter && !renderer->willRenderFeature( const_cast<QgsFeature &>( feature ), context ) )
continue; continue;


featureCount++; featureCount++;


derivedAttributes.unite( featureDerivedAttributes( &( *f_it ), layer, toLayerCoordinates( layer, point ) ) ); derivedAttributes.unite( featureDerivedAttributes( const_cast<QgsFeature *>( &feature ), layer, toLayerCoordinates( layer, point ) ) );


derivedAttributes.insert( tr( "feature id" ), fid < 0 ? tr( "new feature" ) : FID_TO_STRING( fid ) ); derivedAttributes.insert( tr( "feature id" ), fid < 0 ? tr( "new feature" ) : FID_TO_STRING( fid ) );


results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), *f_it, derivedAttributes ) ); results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), feature, derivedAttributes ) );
} }


if ( renderer ) if ( renderer )
Expand Down

0 comments on commit a75fa25

Please sign in to comment.