Skip to content

Commit 88c8c71

Browse files
committed
Daily Q_FOREACH removal
1 parent 8fcad6a commit 88c8c71

19 files changed

+108
-102
lines changed

src/core/fieldformatter/qgslistfieldformatter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ QString QgsListFieldFormatter::representValue( QgsVectorLayer *layer, int fieldI
3535
}
3636

3737
QString result;
38-
Q_FOREACH ( const QVariant &val, value.toList() )
38+
const QVariantList list = value.toList();
39+
for ( const QVariant &val : list )
3940
{
4041
if ( !result.isEmpty() )
4142
result.append( ", " );

src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ QString QgsValueRelationFieldFormatter::representValue( QgsVectorLayer *layer, i
5757
QStringList keyList = value.toString().remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( ',' );
5858
QStringList valueList;
5959

60-
Q_FOREACH ( const QgsValueRelationFieldFormatter::ValueRelationItem &item, vrCache )
60+
for ( const QgsValueRelationFieldFormatter::ValueRelationItem &item : qgsAsConst( vrCache ) )
6161
{
6262
if ( keyList.contains( item.key.toString() ) )
6363
{
@@ -74,7 +74,7 @@ QString QgsValueRelationFieldFormatter::representValue( QgsVectorLayer *layer, i
7474
return QgsApplication::nullRepresentation();
7575
}
7676

77-
Q_FOREACH ( const QgsValueRelationFieldFormatter::ValueRelationItem &item, vrCache )
77+
for ( const QgsValueRelationFieldFormatter::ValueRelationItem &item : qgsAsConst( vrCache ) )
7878
{
7979
if ( item.key == value )
8080
{

src/core/geometry/qgsabstractgeometry.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ int QgsAbstractGeometry::nCoordinates() const
130130
{
131131
int nCoords = 0;
132132

133-
Q_FOREACH ( const QgsRingSequence &r, coordinateSequence() )
133+
const QgsCoordinateSequence seq = coordinateSequence();
134+
for ( const QgsRingSequence &r : seq )
134135
{
135-
Q_FOREACH ( const QgsPointSequence &p, r )
136+
for ( const QgsPointSequence &p : r )
136137
{
137138
nCoords += p.size();
138139
}

src/core/geometry/qgscompoundcurve.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bool QgsCompoundCurve::operator!=( const QgsCurve &other ) const
5252
QgsCompoundCurve::QgsCompoundCurve( const QgsCompoundCurve &curve ): QgsCurve( curve )
5353
{
5454
mWkbType = QgsWkbTypes::CompoundCurve;
55-
Q_FOREACH ( const QgsCurve *c, curve.mCurves )
55+
for ( const QgsCurve *c : curve.mCurves )
5656
{
5757
mCurves.append( static_cast<QgsCurve *>( c->clone() ) );
5858
}
@@ -64,7 +64,7 @@ QgsCompoundCurve &QgsCompoundCurve::operator=( const QgsCompoundCurve &curve )
6464
{
6565
clearCache();
6666
QgsCurve::operator=( curve );
67-
Q_FOREACH ( const QgsCurve *c, curve.mCurves )
67+
for ( const QgsCurve *c : curve.mCurves )
6868
{
6969
mCurves.append( static_cast<QgsCurve *>( c->clone() ) );
7070
}
@@ -153,7 +153,8 @@ bool QgsCompoundCurve::fromWkt( const QString &wkt )
153153

154154
QString defaultChildWkbType = QStringLiteral( "LineString%1%2" ).arg( is3D() ? "Z" : QString(), isMeasure() ? "M" : QString() );
155155

156-
Q_FOREACH ( const QString &childWkt, QgsGeometryUtils::wktGetChildBlocks( parts.second, defaultChildWkbType ) )
156+
const QStringList blocks = QgsGeometryUtils::wktGetChildBlocks( parts.second, defaultChildWkbType );
157+
for ( const QString &childWkt : blocks )
157158
{
158159
QPair<QgsWkbTypes::Type, QString> childParts = QgsGeometryUtils::wktReadBlock( childWkt );
159160

@@ -177,7 +178,7 @@ bool QgsCompoundCurve::fromWkt( const QString &wkt )
177178
//if so, update the type dimensionality of the compound curve to match
178179
bool hasZ = false;
179180
bool hasM = false;
180-
Q_FOREACH ( const QgsCurve *curve, mCurves )
181+
for ( const QgsCurve *curve : qgsAsConst( mCurves ) )
181182
{
182183
hasZ = hasZ || curve->is3D();
183184
hasM = hasM || curve->isMeasure();
@@ -196,7 +197,7 @@ QByteArray QgsCompoundCurve::asWkb() const
196197
{
197198
int binarySize = sizeof( char ) + sizeof( quint32 ) + sizeof( quint32 );
198199
QList<QByteArray> wkbForCurves;
199-
Q_FOREACH ( const QgsCurve *curve, mCurves )
200+
for ( const QgsCurve *curve : mCurves )
200201
{
201202
QByteArray wkbForCurve = curve->asWkb();
202203
binarySize += wkbForCurve.length();
@@ -209,7 +210,7 @@ QByteArray QgsCompoundCurve::asWkb() const
209210
wkb << static_cast<char>( QgsApplication::endian() );
210211
wkb << static_cast<quint32>( wkbType() );
211212
wkb << static_cast<quint32>( mCurves.size() );
212-
Q_FOREACH ( const QByteArray &wkbForCurve, wkbForCurves )
213+
for ( const QByteArray &wkbForCurve : qgsAsConst( wkbForCurves ) )
213214
{
214215
wkb << wkbForCurve;
215216
}
@@ -219,7 +220,7 @@ QByteArray QgsCompoundCurve::asWkb() const
219220
QString QgsCompoundCurve::asWkt( int precision ) const
220221
{
221222
QString wkt = wktTypeStr() + " (";
222-
Q_FOREACH ( const QgsCurve *curve, mCurves )
223+
for ( const QgsCurve *curve : mCurves )
223224
{
224225
QString childWkt = curve->asWkt( precision );
225226
if ( qgsgeometry_cast<const QgsLineString *>( curve ) )
@@ -249,7 +250,7 @@ QDomElement QgsCompoundCurve::asGML2( QDomDocument &doc, int precision, const QS
249250
QDomElement QgsCompoundCurve::asGML3( QDomDocument &doc, int precision, const QString &ns ) const
250251
{
251252
QDomElement compoundCurveElem = doc.createElementNS( ns, QStringLiteral( "CompositeCurve" ) );
252-
Q_FOREACH ( const QgsCurve *curve, mCurves )
253+
for ( const QgsCurve *curve : mCurves )
253254
{
254255
QDomElement curveMemberElem = doc.createElementNS( ns, QStringLiteral( "curveMember" ) );
255256
QDomElement curveElem = curve->asGML3( doc, precision, ns );
@@ -338,7 +339,7 @@ bool QgsCompoundCurve::isEmpty() const
338339
if ( mCurves.isEmpty() )
339340
return true;
340341

341-
Q_FOREACH ( QgsCurve *curve, mCurves )
342+
for ( QgsCurve *curve : mCurves )
342343
{
343344
if ( !curve->isEmpty() )
344345
return false;
@@ -448,7 +449,7 @@ void QgsCompoundCurve::draw( QPainter &p ) const
448449

449450
void QgsCompoundCurve::transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d, bool transformZ )
450451
{
451-
Q_FOREACH ( QgsCurve *curve, mCurves )
452+
for ( QgsCurve *curve : qgsAsConst( mCurves ) )
452453
{
453454
curve->transform( ct, d, transformZ );
454455
}
@@ -457,7 +458,7 @@ void QgsCompoundCurve::transform( const QgsCoordinateTransform &ct, QgsCoordinat
457458

458459
void QgsCompoundCurve::transform( const QTransform &t )
459460
{
460-
Q_FOREACH ( QgsCurve *curve, mCurves )
461+
for ( QgsCurve *curve : qgsAsConst( mCurves ) )
461462
{
462463
curve->transform( t );
463464
}
@@ -753,7 +754,7 @@ double QgsCompoundCurve::vertexAngle( QgsVertexId vertex ) const
753754
QgsCompoundCurve *QgsCompoundCurve::reversed() const
754755
{
755756
QgsCompoundCurve *clone = new QgsCompoundCurve();
756-
Q_FOREACH ( QgsCurve *curve, mCurves )
757+
for ( QgsCurve *curve : mCurves )
757758
{
758759
QgsCurve *reversedCurve = curve->reversed();
759760
clone->addCurve( reversedCurve );
@@ -768,7 +769,7 @@ bool QgsCompoundCurve::addZValue( double zValue )
768769

769770
mWkbType = QgsWkbTypes::addZ( mWkbType );
770771

771-
Q_FOREACH ( QgsCurve *curve, mCurves )
772+
for ( QgsCurve *curve : qgsAsConst( mCurves ) )
772773
{
773774
curve->addZValue( zValue );
774775
}
@@ -783,7 +784,7 @@ bool QgsCompoundCurve::addMValue( double mValue )
783784

784785
mWkbType = QgsWkbTypes::addM( mWkbType );
785786

786-
Q_FOREACH ( QgsCurve *curve, mCurves )
787+
for ( QgsCurve *curve : qgsAsConst( mCurves ) )
787788
{
788789
curve->addMValue( mValue );
789790
}
@@ -797,7 +798,7 @@ bool QgsCompoundCurve::dropZValue()
797798
return false;
798799

799800
mWkbType = QgsWkbTypes::dropZ( mWkbType );
800-
Q_FOREACH ( QgsCurve *curve, mCurves )
801+
for ( QgsCurve *curve : qgsAsConst( mCurves ) )
801802
{
802803
curve->dropZValue();
803804
}
@@ -811,7 +812,7 @@ bool QgsCompoundCurve::dropMValue()
811812
return false;
812813

813814
mWkbType = QgsWkbTypes::dropM( mWkbType );
814-
Q_FOREACH ( QgsCurve *curve, mCurves )
815+
for ( QgsCurve *curve : qgsAsConst( mCurves ) )
815816
{
816817
curve->dropMValue();
817818
}

src/core/geometry/qgscurvepolygon.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ QgsCurvePolygon::QgsCurvePolygon( const QgsCurvePolygon &p )
4747
mExteriorRing = static_cast<QgsCurve *>( p.mExteriorRing->clone() );
4848
}
4949

50-
Q_FOREACH ( const QgsCurve *ring, p.mInteriorRings )
50+
for ( const QgsCurve *ring : p.mInteriorRings )
5151
{
5252
mInteriorRings.push_back( static_cast<QgsCurve *>( ring->clone() ) );
5353
}
@@ -64,7 +64,7 @@ QgsCurvePolygon &QgsCurvePolygon::operator=( const QgsCurvePolygon &p )
6464
mExteriorRing = static_cast<QgsCurve *>( p.mExteriorRing->clone() );
6565
}
6666

67-
Q_FOREACH ( const QgsCurve *ring, p.mInteriorRings )
67+
for ( const QgsCurve *ring : p.mInteriorRings )
6868
{
6969
mInteriorRings.push_back( static_cast<QgsCurve *>( ring->clone() ) );
7070
}
@@ -154,7 +154,8 @@ bool QgsCurvePolygon::fromWkt( const QString &wkt )
154154

155155
QString defaultChildWkbType = QStringLiteral( "LineString%1%2" ).arg( is3D() ? "Z" : QString(), isMeasure() ? "M" : QString() );
156156

157-
Q_FOREACH ( const QString &childWkt, QgsGeometryUtils::wktGetChildBlocks( parts.second, defaultChildWkbType ) )
157+
const QStringList blocks = QgsGeometryUtils::wktGetChildBlocks( parts.second, defaultChildWkbType );
158+
for ( const QString &childWkt : blocks )
158159
{
159160
QPair<QgsWkbTypes::Type, QString> childParts = QgsGeometryUtils::wktReadBlock( childWkt );
160161

@@ -195,7 +196,7 @@ bool QgsCurvePolygon::fromWkt( const QString &wkt )
195196
hasZ = hasZ || mExteriorRing->is3D();
196197
hasM = hasM || mExteriorRing->isMeasure();
197198
}
198-
Q_FOREACH ( const QgsCurve *curve, mInteriorRings )
199+
for ( const QgsCurve *curve : qgsAsConst( mInteriorRings ) )
199200
{
200201
hasZ = hasZ || curve->is3D();
201202
hasM = hasM || curve->isMeasure();
@@ -229,7 +230,7 @@ QByteArray QgsCurvePolygon::asWkb() const
229230
binarySize += wkb.length();
230231
wkbForRings << wkb;
231232
}
232-
Q_FOREACH ( const QgsCurve *curve, mInteriorRings )
233+
for ( const QgsCurve *curve : mInteriorRings )
233234
{
234235
QByteArray wkb( curve->asWkb() );
235236
binarySize += wkb.length();
@@ -242,7 +243,7 @@ QByteArray QgsCurvePolygon::asWkb() const
242243
wkbPtr << static_cast<char>( QgsApplication::endian() );
243244
wkbPtr << static_cast<quint32>( wkbType() );
244245
wkbPtr << static_cast<quint32>( wkbForRings.count() );
245-
Q_FOREACH ( const QByteArray &wkb, wkbForRings )
246+
for ( const QByteArray &wkb : qgsAsConst( wkbForRings ) )
246247
{
247248
wkbPtr << wkb;
248249
}
@@ -262,7 +263,7 @@ QString QgsCurvePolygon::asWkt( int precision ) const
262263
}
263264
wkt += childWkt + ',';
264265
}
265-
Q_FOREACH ( const QgsCurve *curve, mInteriorRings )
266+
for ( const QgsCurve *curve : mInteriorRings )
266267
{
267268
QString childWkt = curve->asWkt( precision );
268269
if ( qgsgeometry_cast<const QgsLineString *>( curve ) )
@@ -494,7 +495,7 @@ void QgsCurvePolygon::setExteriorRing( QgsCurve *ring )
494495
}
495496

496497
//match dimensionality for rings
497-
Q_FOREACH ( QgsCurve *ring, mInteriorRings )
498+
for ( QgsCurve *ring : qgsAsConst( mInteriorRings ) )
498499
{
499500
if ( is3D() )
500501
ring->addZValue();
@@ -515,7 +516,7 @@ void QgsCurvePolygon::setInteriorRings( const QList<QgsCurve *> &rings )
515516
mInteriorRings.clear();
516517

517518
//add rings one-by-one, so that they can each be converted to the correct type for the CurvePolygon
518-
Q_FOREACH ( QgsCurve *ring, rings )
519+
for ( QgsCurve *ring : rings )
519520
{
520521
addInteriorRing( ring );
521522
}
@@ -601,7 +602,7 @@ void QgsCurvePolygon::transform( const QgsCoordinateTransform &ct, QgsCoordinate
601602
mExteriorRing->transform( ct, d, transformZ );
602603
}
603604

604-
Q_FOREACH ( QgsCurve *curve, mInteriorRings )
605+
for ( QgsCurve *curve : qgsAsConst( mInteriorRings ) )
605606
{
606607
curve->transform( ct, d, transformZ );
607608
}
@@ -615,7 +616,7 @@ void QgsCurvePolygon::transform( const QTransform &t )
615616
mExteriorRing->transform( t );
616617
}
617618

618-
Q_FOREACH ( QgsCurve *curve, mInteriorRings )
619+
for ( QgsCurve *curve : qgsAsConst( mInteriorRings ) )
619620
{
620621
curve->transform( t );
621622
}
@@ -868,7 +869,7 @@ bool QgsCurvePolygon::addZValue( double zValue )
868869

869870
if ( mExteriorRing )
870871
mExteriorRing->addZValue( zValue );
871-
Q_FOREACH ( QgsCurve *curve, mInteriorRings )
872+
for ( QgsCurve *curve : qgsAsConst( mInteriorRings ) )
872873
{
873874
curve->addZValue( zValue );
874875
}
@@ -885,7 +886,7 @@ bool QgsCurvePolygon::addMValue( double mValue )
885886

886887
if ( mExteriorRing )
887888
mExteriorRing->addMValue( mValue );
888-
Q_FOREACH ( QgsCurve *curve, mInteriorRings )
889+
for ( QgsCurve *curve : qgsAsConst( mInteriorRings ) )
889890
{
890891
curve->addMValue( mValue );
891892
}
@@ -901,7 +902,7 @@ bool QgsCurvePolygon::dropZValue()
901902
mWkbType = QgsWkbTypes::dropZ( mWkbType );
902903
if ( mExteriorRing )
903904
mExteriorRing->dropZValue();
904-
Q_FOREACH ( QgsCurve *curve, mInteriorRings )
905+
for ( QgsCurve *curve : qgsAsConst( mInteriorRings ) )
905906
{
906907
curve->dropZValue();
907908
}
@@ -917,7 +918,7 @@ bool QgsCurvePolygon::dropMValue()
917918
mWkbType = QgsWkbTypes::dropM( mWkbType );
918919
if ( mExteriorRing )
919920
mExteriorRing->dropMValue();
920-
Q_FOREACH ( QgsCurve *curve, mInteriorRings )
921+
for ( QgsCurve *curve : qgsAsConst( mInteriorRings ) )
921922
{
922923
curve->dropMValue();
923924
}

0 commit comments

Comments
 (0)