Skip to content

Commit 1a32f08

Browse files
committed
Fix clazy detaching range based for warnings
1 parent e8b90c3 commit 1a32f08

6 files changed

+20
-14
lines changed

src/app/locator/qgsinbuiltlocatorfilters.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c
191191

192192
// build up request expression
193193
QStringList expressionParts;
194-
Q_FOREACH ( const QgsField &field, layer->fields() )
194+
const QgsFields fields = layer->fields();
195+
for ( const QgsField &field : fields )
195196
{
196197
if ( field.type() == QVariant::String )
197198
{

src/app/nodetool/qgsnodetool.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,8 @@ void QgsNodeTool::startDraggingMoveVertex( const QgsPointLocator::Match &m )
10791079
if ( !vlayer || !vlayer->isEditable() )
10801080
continue;
10811081

1082-
for ( const QgsPointLocator::Match &otherMatch : layerVerticesSnappedToPoint( vlayer, m.point() ) )
1082+
const auto snappedVertices = layerVerticesSnappedToPoint( vlayer, m.point() );
1083+
for ( const QgsPointLocator::Match &otherMatch : snappedVertices )
10831084
{
10841085
if ( otherMatch.layer() == m.layer() &&
10851086
otherMatch.featureId() == m.featureId() &&
@@ -1436,7 +1437,8 @@ void QgsNodeTool::moveVertex( const QgsPointXY &mapPoint, const QgsPointLocator:
14361437
// topo editing: add vertex to existing segments when moving/adding a vertex to such segment.
14371438
// this requires that the snapping match is to a segment and the segment layer's CRS
14381439
// is the same (otherwise we would need to reproject the point and it will not be coincident)
1439-
for ( QgsVectorLayer *layer : edits.keys() )
1440+
const auto editKeys = edits.keys();
1441+
for ( QgsVectorLayer *layer : editKeys )
14401442
{
14411443
if ( layer->crs() == mapPointMatch->layer()->crs() )
14421444
{
@@ -1531,11 +1533,12 @@ void QgsNodeTool::deleteVertex()
15311533
{
15321534
// if topo editing is enabled, delete all the vertices that are on the same location
15331535
QSet<Vertex> topoVerticesToDelete;
1534-
for ( const Vertex &vertexToDelete : toDelete )
1536+
for ( const Vertex &vertexToDelete : qgsAsConst( toDelete ) )
15351537
{
15361538
QgsPointXY layerPt = cachedGeometryForVertex( vertexToDelete ).vertexAt( vertexToDelete.vertexId );
15371539
QgsPointXY mapPt = toMapCoordinates( vertexToDelete.layer, layerPt );
1538-
for ( const QgsPointLocator::Match &otherMatch : layerVerticesSnappedToPoint( vertexToDelete.layer, mapPt ) )
1540+
const auto snappedVertices = layerVerticesSnappedToPoint( vertexToDelete.layer, mapPt );
1541+
for ( const QgsPointLocator::Match &otherMatch : snappedVertices )
15391542
{
15401543
Vertex otherVertex( otherMatch.layer(), otherMatch.featureId(), otherMatch.vertexIndex() );
15411544
if ( toDelete.contains( otherVertex ) || topoVerticesToDelete.contains( otherVertex ) )
@@ -1550,7 +1553,7 @@ void QgsNodeTool::deleteVertex()
15501553

15511554
// switch from a plain list to dictionary { layer: { fid: [vertexNr1, vertexNr2, ...] } }
15521555
QHash<QgsVectorLayer *, QHash<QgsFeatureId, QList<int> > > toDeleteGrouped;
1553-
for ( const Vertex &vertex : toDelete )
1556+
for ( const Vertex &vertex : qgsAsConst( toDelete ) )
15541557
{
15551558
toDeleteGrouped[vertex.layer][vertex.fid].append( vertex.vertexId );
15561559
}
@@ -1586,7 +1589,7 @@ void QgsNodeTool::deleteVertex()
15861589
}
15871590
}
15881591
// now delete the duplicities
1589-
for ( int duplicateVertexIndex : duplicateVertexIndices )
1592+
for ( int duplicateVertexIndex : qgsAsConst( duplicateVertexIndices ) )
15901593
vertexIds.removeOne( duplicateVertexIndex );
15911594
}
15921595
}
@@ -1779,7 +1782,7 @@ void QgsNodeTool::CircularBand::updateRubberBand( const QgsPointXY &mapPoint )
17791782
QgsGeometryUtils::segmentizeArc( QgsPoint( v0 ), QgsPoint( v1 ), QgsPoint( v2 ), points );
17801783
// it would be useful to have QgsRubberBand::setPoints() call
17811784
band->reset();
1782-
for ( const QgsPoint &p : points )
1785+
for ( const QgsPoint &p : qgsAsConst( points ) )
17831786
band->addPoint( p );
17841787
}
17851788

src/core/processing/qgsnativealgorithms.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ QVariantMap QgsLineIntersectionAlgorithm::processAlgorithm( const QVariantMap &p
21652165
points.append( intersectGeom.asPoint() );
21662166
}
21672167

2168-
for ( QgsPointXY j : qgsAsConst( points ) )
2168+
for ( const QgsPointXY &j : qgsAsConst( points ) )
21692169
{
21702170
outFeature.setGeometry( QgsGeometry::fromPoint( j ) );
21712171
outFeature.setAttributes( outAttributes );

src/gui/qgsprojectionselectiontreewidget.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@ QString QgsProjectionSelectionTreeWidget::ogcWmsCrsFilterAsSqlExpression( QSet<Q
188188
if ( !authParts.isEmpty() )
189189
{
190190
QString prefix = QStringLiteral( " AND (" );
191-
Q_FOREACH ( const QString &auth_name, authParts.keys() )
191+
for ( auto it = authParts.constBegin(); it != authParts.constEnd(); ++it )
192192
{
193193
sqlExpression += QStringLiteral( "%1(upper(auth_name)='%2' AND upper(auth_id) IN ('%3'))" )
194194
.arg( prefix,
195-
auth_name,
196-
authParts[auth_name].join( QStringLiteral( "','" ) ) );
195+
it.key(),
196+
it.value().join( QStringLiteral( "','" ) ) );
197197
prefix = QStringLiteral( " OR " );
198198
}
199199
sqlExpression += ')';

src/providers/ogr/qgsogrdataitems.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ QList<QgsOgrDbLayerInfo *> QgsOgrLayerItem::subLayers( const QString &path, cons
163163
subLayersMap.insert( pieces[0].toInt(), pieces );
164164
}
165165
int prevIdx = -1;
166-
for ( const int &idx : subLayersMap.keys( ) )
166+
const auto subLayerKeys = subLayersMap.keys( );
167+
for ( const int &idx : subLayerKeys )
167168
{
168169
if ( idx == prevIdx )
169170
{

src/providers/virtual/qgsvirtuallayersourceselect.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ QgsVirtualLayerSourceSelect::QgsVirtualLayerSourceSelect( QWidget *parent, Qt::W
6565
}
6666
// It needs to find the layertree view without relying on the parent
6767
// being the main window
68-
for ( const QWidget *widget : qApp->allWidgets() )
68+
const QList< QWidget * > widgets = qApp->allWidgets();
69+
for ( const QWidget *widget : widgets )
6970
{
7071
if ( ! mTreeView )
7172
{

0 commit comments

Comments
 (0)