Skip to content
Permalink
Browse files

Fix clazy detaching range based for warnings

  • Loading branch information
nyalldawson committed Sep 25, 2017
1 parent e8b90c3 commit 1a32f0883c05c70392f54a571533d192176d69ff
@@ -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 )
{
@@ -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() &&
@@ -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() )
{
@@ -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 ) )
@@ -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 );
}
@@ -1586,7 +1589,7 @@ void QgsNodeTool::deleteVertex()
}
}
// now delete the duplicities
for ( int duplicateVertexIndex : duplicateVertexIndices )
for ( int duplicateVertexIndex : qgsAsConst( duplicateVertexIndices ) )
vertexIds.removeOne( duplicateVertexIndex );
}
}
@@ -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 );
}

@@ -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 );
@@ -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 += ')';
@@ -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 )
{
@@ -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 )
{

0 comments on commit 1a32f08

Please sign in to comment.
You can’t perform that action at this time.