Skip to content

Commit

Permalink
Daily Q_FOREACH removal
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent 8fcad6a commit 88c8c71
Show file tree
Hide file tree
Showing 19 changed files with 108 additions and 102 deletions.
3 changes: 2 additions & 1 deletion src/core/fieldformatter/qgslistfieldformatter.cpp
Expand Up @@ -35,7 +35,8 @@ QString QgsListFieldFormatter::representValue( QgsVectorLayer *layer, int fieldI
}

QString result;
Q_FOREACH ( const QVariant &val, value.toList() )
const QVariantList list = value.toList();
for ( const QVariant &val : list )
{
if ( !result.isEmpty() )
result.append( ", " );
Expand Down
4 changes: 2 additions & 2 deletions src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp
Expand Up @@ -57,7 +57,7 @@ QString QgsValueRelationFieldFormatter::representValue( QgsVectorLayer *layer, i
QStringList keyList = value.toString().remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( ',' );
QStringList valueList;

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

Q_FOREACH ( const QgsValueRelationFieldFormatter::ValueRelationItem &item, vrCache )
for ( const QgsValueRelationFieldFormatter::ValueRelationItem &item : qgsAsConst( vrCache ) )
{
if ( item.key == value )
{
Expand Down
5 changes: 3 additions & 2 deletions src/core/geometry/qgsabstractgeometry.cpp
Expand Up @@ -130,9 +130,10 @@ int QgsAbstractGeometry::nCoordinates() const
{
int nCoords = 0;

Q_FOREACH ( const QgsRingSequence &r, coordinateSequence() )
const QgsCoordinateSequence seq = coordinateSequence();
for ( const QgsRingSequence &r : seq )
{
Q_FOREACH ( const QgsPointSequence &p, r )
for ( const QgsPointSequence &p : r )
{
nCoords += p.size();
}
Expand Down
33 changes: 17 additions & 16 deletions src/core/geometry/qgscompoundcurve.cpp
Expand Up @@ -52,7 +52,7 @@ bool QgsCompoundCurve::operator!=( const QgsCurve &other ) const
QgsCompoundCurve::QgsCompoundCurve( const QgsCompoundCurve &curve ): QgsCurve( curve )
{
mWkbType = QgsWkbTypes::CompoundCurve;
Q_FOREACH ( const QgsCurve *c, curve.mCurves )
for ( const QgsCurve *c : curve.mCurves )
{
mCurves.append( static_cast<QgsCurve *>( c->clone() ) );
}
Expand All @@ -64,7 +64,7 @@ QgsCompoundCurve &QgsCompoundCurve::operator=( const QgsCompoundCurve &curve )
{
clearCache();
QgsCurve::operator=( curve );
Q_FOREACH ( const QgsCurve *c, curve.mCurves )
for ( const QgsCurve *c : curve.mCurves )
{
mCurves.append( static_cast<QgsCurve *>( c->clone() ) );
}
Expand Down Expand Up @@ -153,7 +153,8 @@ bool QgsCompoundCurve::fromWkt( const QString &wkt )

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

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

Expand All @@ -177,7 +178,7 @@ bool QgsCompoundCurve::fromWkt( const QString &wkt )
//if so, update the type dimensionality of the compound curve to match
bool hasZ = false;
bool hasM = false;
Q_FOREACH ( const QgsCurve *curve, mCurves )
for ( const QgsCurve *curve : qgsAsConst( mCurves ) )
{
hasZ = hasZ || curve->is3D();
hasM = hasM || curve->isMeasure();
Expand All @@ -196,7 +197,7 @@ QByteArray QgsCompoundCurve::asWkb() const
{
int binarySize = sizeof( char ) + sizeof( quint32 ) + sizeof( quint32 );
QList<QByteArray> wkbForCurves;
Q_FOREACH ( const QgsCurve *curve, mCurves )
for ( const QgsCurve *curve : mCurves )
{
QByteArray wkbForCurve = curve->asWkb();
binarySize += wkbForCurve.length();
Expand All @@ -209,7 +210,7 @@ QByteArray QgsCompoundCurve::asWkb() const
wkb << static_cast<char>( QgsApplication::endian() );
wkb << static_cast<quint32>( wkbType() );
wkb << static_cast<quint32>( mCurves.size() );
Q_FOREACH ( const QByteArray &wkbForCurve, wkbForCurves )
for ( const QByteArray &wkbForCurve : qgsAsConst( wkbForCurves ) )
{
wkb << wkbForCurve;
}
Expand All @@ -219,7 +220,7 @@ QByteArray QgsCompoundCurve::asWkb() const
QString QgsCompoundCurve::asWkt( int precision ) const
{
QString wkt = wktTypeStr() + " (";
Q_FOREACH ( const QgsCurve *curve, mCurves )
for ( const QgsCurve *curve : mCurves )
{
QString childWkt = curve->asWkt( precision );
if ( qgsgeometry_cast<const QgsLineString *>( curve ) )
Expand Down Expand Up @@ -249,7 +250,7 @@ QDomElement QgsCompoundCurve::asGML2( QDomDocument &doc, int precision, const QS
QDomElement QgsCompoundCurve::asGML3( QDomDocument &doc, int precision, const QString &ns ) const
{
QDomElement compoundCurveElem = doc.createElementNS( ns, QStringLiteral( "CompositeCurve" ) );
Q_FOREACH ( const QgsCurve *curve, mCurves )
for ( const QgsCurve *curve : mCurves )
{
QDomElement curveMemberElem = doc.createElementNS( ns, QStringLiteral( "curveMember" ) );
QDomElement curveElem = curve->asGML3( doc, precision, ns );
Expand Down Expand Up @@ -338,7 +339,7 @@ bool QgsCompoundCurve::isEmpty() const
if ( mCurves.isEmpty() )
return true;

Q_FOREACH ( QgsCurve *curve, mCurves )
for ( QgsCurve *curve : mCurves )
{
if ( !curve->isEmpty() )
return false;
Expand Down Expand Up @@ -448,7 +449,7 @@ void QgsCompoundCurve::draw( QPainter &p ) const

void QgsCompoundCurve::transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d, bool transformZ )
{
Q_FOREACH ( QgsCurve *curve, mCurves )
for ( QgsCurve *curve : qgsAsConst( mCurves ) )
{
curve->transform( ct, d, transformZ );
}
Expand All @@ -457,7 +458,7 @@ void QgsCompoundCurve::transform( const QgsCoordinateTransform &ct, QgsCoordinat

void QgsCompoundCurve::transform( const QTransform &t )
{
Q_FOREACH ( QgsCurve *curve, mCurves )
for ( QgsCurve *curve : qgsAsConst( mCurves ) )
{
curve->transform( t );
}
Expand Down Expand Up @@ -753,7 +754,7 @@ double QgsCompoundCurve::vertexAngle( QgsVertexId vertex ) const
QgsCompoundCurve *QgsCompoundCurve::reversed() const
{
QgsCompoundCurve *clone = new QgsCompoundCurve();
Q_FOREACH ( QgsCurve *curve, mCurves )
for ( QgsCurve *curve : mCurves )
{
QgsCurve *reversedCurve = curve->reversed();
clone->addCurve( reversedCurve );
Expand All @@ -768,7 +769,7 @@ bool QgsCompoundCurve::addZValue( double zValue )

mWkbType = QgsWkbTypes::addZ( mWkbType );

Q_FOREACH ( QgsCurve *curve, mCurves )
for ( QgsCurve *curve : qgsAsConst( mCurves ) )
{
curve->addZValue( zValue );
}
Expand All @@ -783,7 +784,7 @@ bool QgsCompoundCurve::addMValue( double mValue )

mWkbType = QgsWkbTypes::addM( mWkbType );

Q_FOREACH ( QgsCurve *curve, mCurves )
for ( QgsCurve *curve : qgsAsConst( mCurves ) )
{
curve->addMValue( mValue );
}
Expand All @@ -797,7 +798,7 @@ bool QgsCompoundCurve::dropZValue()
return false;

mWkbType = QgsWkbTypes::dropZ( mWkbType );
Q_FOREACH ( QgsCurve *curve, mCurves )
for ( QgsCurve *curve : qgsAsConst( mCurves ) )
{
curve->dropZValue();
}
Expand All @@ -811,7 +812,7 @@ bool QgsCompoundCurve::dropMValue()
return false;

mWkbType = QgsWkbTypes::dropM( mWkbType );
Q_FOREACH ( QgsCurve *curve, mCurves )
for ( QgsCurve *curve : qgsAsConst( mCurves ) )
{
curve->dropMValue();
}
Expand Down
31 changes: 16 additions & 15 deletions src/core/geometry/qgscurvepolygon.cpp
Expand Up @@ -47,7 +47,7 @@ QgsCurvePolygon::QgsCurvePolygon( const QgsCurvePolygon &p )
mExteriorRing = static_cast<QgsCurve *>( p.mExteriorRing->clone() );
}

Q_FOREACH ( const QgsCurve *ring, p.mInteriorRings )
for ( const QgsCurve *ring : p.mInteriorRings )
{
mInteriorRings.push_back( static_cast<QgsCurve *>( ring->clone() ) );
}
Expand All @@ -64,7 +64,7 @@ QgsCurvePolygon &QgsCurvePolygon::operator=( const QgsCurvePolygon &p )
mExteriorRing = static_cast<QgsCurve *>( p.mExteriorRing->clone() );
}

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

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

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

Expand Down Expand Up @@ -195,7 +196,7 @@ bool QgsCurvePolygon::fromWkt( const QString &wkt )
hasZ = hasZ || mExteriorRing->is3D();
hasM = hasM || mExteriorRing->isMeasure();
}
Q_FOREACH ( const QgsCurve *curve, mInteriorRings )
for ( const QgsCurve *curve : qgsAsConst( mInteriorRings ) )
{
hasZ = hasZ || curve->is3D();
hasM = hasM || curve->isMeasure();
Expand Down Expand Up @@ -229,7 +230,7 @@ QByteArray QgsCurvePolygon::asWkb() const
binarySize += wkb.length();
wkbForRings << wkb;
}
Q_FOREACH ( const QgsCurve *curve, mInteriorRings )
for ( const QgsCurve *curve : mInteriorRings )
{
QByteArray wkb( curve->asWkb() );
binarySize += wkb.length();
Expand All @@ -242,7 +243,7 @@ QByteArray QgsCurvePolygon::asWkb() const
wkbPtr << static_cast<char>( QgsApplication::endian() );
wkbPtr << static_cast<quint32>( wkbType() );
wkbPtr << static_cast<quint32>( wkbForRings.count() );
Q_FOREACH ( const QByteArray &wkb, wkbForRings )
for ( const QByteArray &wkb : qgsAsConst( wkbForRings ) )
{
wkbPtr << wkb;
}
Expand All @@ -262,7 +263,7 @@ QString QgsCurvePolygon::asWkt( int precision ) const
}
wkt += childWkt + ',';
}
Q_FOREACH ( const QgsCurve *curve, mInteriorRings )
for ( const QgsCurve *curve : mInteriorRings )
{
QString childWkt = curve->asWkt( precision );
if ( qgsgeometry_cast<const QgsLineString *>( curve ) )
Expand Down Expand Up @@ -494,7 +495,7 @@ void QgsCurvePolygon::setExteriorRing( QgsCurve *ring )
}

//match dimensionality for rings
Q_FOREACH ( QgsCurve *ring, mInteriorRings )
for ( QgsCurve *ring : qgsAsConst( mInteriorRings ) )
{
if ( is3D() )
ring->addZValue();
Expand All @@ -515,7 +516,7 @@ void QgsCurvePolygon::setInteriorRings( const QList<QgsCurve *> &rings )
mInteriorRings.clear();

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

Q_FOREACH ( QgsCurve *curve, mInteriorRings )
for ( QgsCurve *curve : qgsAsConst( mInteriorRings ) )
{
curve->transform( ct, d, transformZ );
}
Expand All @@ -615,7 +616,7 @@ void QgsCurvePolygon::transform( const QTransform &t )
mExteriorRing->transform( t );
}

Q_FOREACH ( QgsCurve *curve, mInteriorRings )
for ( QgsCurve *curve : qgsAsConst( mInteriorRings ) )
{
curve->transform( t );
}
Expand Down Expand Up @@ -868,7 +869,7 @@ bool QgsCurvePolygon::addZValue( double zValue )

if ( mExteriorRing )
mExteriorRing->addZValue( zValue );
Q_FOREACH ( QgsCurve *curve, mInteriorRings )
for ( QgsCurve *curve : qgsAsConst( mInteriorRings ) )
{
curve->addZValue( zValue );
}
Expand All @@ -885,7 +886,7 @@ bool QgsCurvePolygon::addMValue( double mValue )

if ( mExteriorRing )
mExteriorRing->addMValue( mValue );
Q_FOREACH ( QgsCurve *curve, mInteriorRings )
for ( QgsCurve *curve : qgsAsConst( mInteriorRings ) )
{
curve->addMValue( mValue );
}
Expand All @@ -901,7 +902,7 @@ bool QgsCurvePolygon::dropZValue()
mWkbType = QgsWkbTypes::dropZ( mWkbType );
if ( mExteriorRing )
mExteriorRing->dropZValue();
Q_FOREACH ( QgsCurve *curve, mInteriorRings )
for ( QgsCurve *curve : qgsAsConst( mInteriorRings ) )
{
curve->dropZValue();
}
Expand All @@ -917,7 +918,7 @@ bool QgsCurvePolygon::dropMValue()
mWkbType = QgsWkbTypes::dropM( mWkbType );
if ( mExteriorRing )
mExteriorRing->dropMValue();
Q_FOREACH ( QgsCurve *curve, mInteriorRings )
for ( QgsCurve *curve : qgsAsConst( mInteriorRings ) )
{
curve->dropMValue();
}
Expand Down

0 comments on commit 88c8c71

Please sign in to comment.