Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix clazy detaching range based for warnings
  • Loading branch information
nyalldawson committed Sep 25, 2017
1 parent e8b90c3 commit 1a32f08
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/app/locator/qgsinbuiltlocatorfilters.cpp
Expand Up @@ -191,7 +191,8 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c

// build up request expression
QStringList expressionParts;
Q_FOREACH ( const QgsField &field, layer->fields() )
const QgsFields fields = layer->fields();
for ( const QgsField &field : fields )
{
if ( field.type() == QVariant::String )
{
Expand Down
17 changes: 10 additions & 7 deletions src/app/nodetool/qgsnodetool.cpp
Expand Up @@ -1079,7 +1079,8 @@ void QgsNodeTool::startDraggingMoveVertex( const QgsPointLocator::Match &m )
if ( !vlayer || !vlayer->isEditable() )
continue;

for ( const QgsPointLocator::Match &otherMatch : layerVerticesSnappedToPoint( vlayer, m.point() ) )
const auto snappedVertices = layerVerticesSnappedToPoint( vlayer, m.point() );
for ( const QgsPointLocator::Match &otherMatch : snappedVertices )
{
if ( otherMatch.layer() == m.layer() &&
otherMatch.featureId() == m.featureId() &&
Expand Down Expand Up @@ -1436,7 +1437,8 @@ void QgsNodeTool::moveVertex( const QgsPointXY &mapPoint, const QgsPointLocator:
// topo editing: add vertex to existing segments when moving/adding a vertex to such segment.
// this requires that the snapping match is to a segment and the segment layer's CRS
// is the same (otherwise we would need to reproject the point and it will not be coincident)
for ( QgsVectorLayer *layer : edits.keys() )
const auto editKeys = edits.keys();
for ( QgsVectorLayer *layer : editKeys )
{
if ( layer->crs() == mapPointMatch->layer()->crs() )
{
Expand Down Expand Up @@ -1531,11 +1533,12 @@ void QgsNodeTool::deleteVertex()
{
// if topo editing is enabled, delete all the vertices that are on the same location
QSet<Vertex> topoVerticesToDelete;
for ( const Vertex &vertexToDelete : toDelete )
for ( const Vertex &vertexToDelete : qgsAsConst( toDelete ) )
{
QgsPointXY layerPt = cachedGeometryForVertex( vertexToDelete ).vertexAt( vertexToDelete.vertexId );
QgsPointXY mapPt = toMapCoordinates( vertexToDelete.layer, layerPt );
for ( const QgsPointLocator::Match &otherMatch : layerVerticesSnappedToPoint( vertexToDelete.layer, mapPt ) )
const auto snappedVertices = layerVerticesSnappedToPoint( vertexToDelete.layer, mapPt );
for ( const QgsPointLocator::Match &otherMatch : snappedVertices )
{
Vertex otherVertex( otherMatch.layer(), otherMatch.featureId(), otherMatch.vertexIndex() );
if ( toDelete.contains( otherVertex ) || topoVerticesToDelete.contains( otherVertex ) )
Expand All @@ -1550,7 +1553,7 @@ void QgsNodeTool::deleteVertex()

// switch from a plain list to dictionary { layer: { fid: [vertexNr1, vertexNr2, ...] } }
QHash<QgsVectorLayer *, QHash<QgsFeatureId, QList<int> > > toDeleteGrouped;
for ( const Vertex &vertex : toDelete )
for ( const Vertex &vertex : qgsAsConst( toDelete ) )
{
toDeleteGrouped[vertex.layer][vertex.fid].append( vertex.vertexId );
}
Expand Down Expand Up @@ -1586,7 +1589,7 @@ void QgsNodeTool::deleteVertex()
}
}
// now delete the duplicities
for ( int duplicateVertexIndex : duplicateVertexIndices )
for ( int duplicateVertexIndex : qgsAsConst( duplicateVertexIndices ) )
vertexIds.removeOne( duplicateVertexIndex );
}
}
Expand Down Expand Up @@ -1779,7 +1782,7 @@ void QgsNodeTool::CircularBand::updateRubberBand( const QgsPointXY &mapPoint )
QgsGeometryUtils::segmentizeArc( QgsPoint( v0 ), QgsPoint( v1 ), QgsPoint( v2 ), points );
// it would be useful to have QgsRubberBand::setPoints() call
band->reset();
for ( const QgsPoint &p : points )
for ( const QgsPoint &p : qgsAsConst( points ) )
band->addPoint( p );
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/processing/qgsnativealgorithms.cpp
Expand Up @@ -2165,7 +2165,7 @@ QVariantMap QgsLineIntersectionAlgorithm::processAlgorithm( const QVariantMap &p
points.append( intersectGeom.asPoint() );
}

for ( QgsPointXY j : qgsAsConst( points ) )
for ( const QgsPointXY &j : qgsAsConst( points ) )
{
outFeature.setGeometry( QgsGeometry::fromPoint( j ) );
outFeature.setAttributes( outAttributes );
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsprojectionselectiontreewidget.cpp
Expand Up @@ -188,12 +188,12 @@ QString QgsProjectionSelectionTreeWidget::ogcWmsCrsFilterAsSqlExpression( QSet<Q
if ( !authParts.isEmpty() )
{
QString prefix = QStringLiteral( " AND (" );
Q_FOREACH ( const QString &auth_name, authParts.keys() )
for ( auto it = authParts.constBegin(); it != authParts.constEnd(); ++it )
{
sqlExpression += QStringLiteral( "%1(upper(auth_name)='%2' AND upper(auth_id) IN ('%3'))" )
.arg( prefix,
auth_name,
authParts[auth_name].join( QStringLiteral( "','" ) ) );
it.key(),
it.value().join( QStringLiteral( "','" ) ) );
prefix = QStringLiteral( " OR " );
}
sqlExpression += ')';
Expand Down
3 changes: 2 additions & 1 deletion src/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -163,7 +163,8 @@ QList<QgsOgrDbLayerInfo *> QgsOgrLayerItem::subLayers( const QString &path, cons
subLayersMap.insert( pieces[0].toInt(), pieces );
}
int prevIdx = -1;
for ( const int &idx : subLayersMap.keys( ) )
const auto subLayerKeys = subLayersMap.keys( );
for ( const int &idx : subLayerKeys )
{
if ( idx == prevIdx )
{
Expand Down
3 changes: 2 additions & 1 deletion src/providers/virtual/qgsvirtuallayersourceselect.cpp
Expand Up @@ -65,7 +65,8 @@ QgsVirtualLayerSourceSelect::QgsVirtualLayerSourceSelect( QWidget *parent, Qt::W
}
// It needs to find the layertree view without relying on the parent
// being the main window
for ( const QWidget *widget : qApp->allWidgets() )
const QList< QWidget * > widgets = qApp->allWidgets();
for ( const QWidget *widget : widgets )
{
if ( ! mTreeView )
{
Expand Down

0 comments on commit 1a32f08

Please sign in to comment.