Skip to content
Permalink
Browse files

Daily Q_FOREACH removal

  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent 8fcad6a commit 88c8c71422bebbac7d0bb57662eb6394b17a4b44
@@ -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( ", " );
@@ -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() ) )
{
@@ -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 )
{
@@ -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();
}
@@ -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() ) );
}
@@ -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() ) );
}
@@ -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 );

@@ -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();
@@ -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();
@@ -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;
}
@@ -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 ) )
@@ -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 );
@@ -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;
@@ -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 );
}
@@ -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 );
}
@@ -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 );
@@ -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 );
}
@@ -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 );
}
@@ -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();
}
@@ -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();
}
@@ -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() ) );
}
@@ -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() ) );
}
@@ -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 );

@@ -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();
@@ -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();
@@ -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;
}
@@ -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 ) )
@@ -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();
@@ -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 );
}
@@ -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 );
}
@@ -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 );
}
@@ -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 );
}
@@ -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 );
}
@@ -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();
}
@@ -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();
}

0 comments on commit 88c8c71

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