Skip to content
Permalink
Browse files

Daily Q_FOREACH -> for conversion

  • Loading branch information
nyalldawson committed Sep 3, 2017
1 parent e30f704 commit 85e6a633288cffff09830c6dfb5bb432f19158e4
@@ -69,7 +69,7 @@ void QgsAtlasComposition::removeLayers( const QStringList &layers )
return;
}

Q_FOREACH ( const QString &layerId, layers )
for ( const QString &layerId : layers )
{
if ( layerId == mCoverageLayer.layerId )
{
@@ -399,7 +399,8 @@ bool QgsComposerAttributeTableColumnModelV2::moveColumnInSortRank( QgsComposerTa

//find column before this one in sort order
QList<QgsComposerTableColumn *> sortedColumns;
Q_FOREACH ( QgsComposerTableColumn *currentColumn, *mComposerTable->columns() )
const QgsComposerTableColumns columns = *mComposerTable->columns();
for ( QgsComposerTableColumn *currentColumn : columns )
{
if ( currentColumn->sortByRank() > 0 )
{
@@ -49,7 +49,7 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsFeature &feature, const QgsRen
if ( !feature.fields().isEmpty() )
expressionContext.setFields( feature.fields() );

Q_FOREACH ( const QString &cat, s.categoryAttributes )
for ( const QString &cat : qgsAsConst( s.categoryAttributes ) )
{
QgsExpression *expression = getExpression( cat, expressionContext );
maxValue = std::max( expression->evaluate( &expressionContext ).toDouble(), maxValue );
@@ -146,7 +146,7 @@ void QgsHistogramDiagram::renderDiagram( const QgsFeature &feature, QgsRenderCon
if ( !feature.fields().isEmpty() )
expressionContext.setFields( feature.fields() );

Q_FOREACH ( const QString &cat, s.categoryAttributes )
for ( const QString &cat : qgsAsConst( s.categoryAttributes ) )
{
QgsExpression *expression = getExpression( cat, expressionContext );
double currentVal = expression->evaluate( &expressionContext ).toDouble();
@@ -516,7 +516,8 @@ int QgsDxfExport::writeToFile( QIODevice *d, const QString &encoding )

if ( mExtent.isEmpty() )
{
Q_FOREACH ( QgsMapLayer *ml, mMapSettings.layers() )
const QList< QgsMapLayer * > layers = mMapSettings.layers();
for ( QgsMapLayer *ml : layers )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
if ( !vl )
@@ -655,7 +656,8 @@ void QgsDxfExport::writeTables()
writeGroup( 100, QStringLiteral( "AcDbSymbolTable" ) );
writeGroup( 70, 0 );

Q_FOREACH ( const QString &block, QStringList() << "*Model_Space" << "*Paper_Space" << "*Paper_Space0" )
const QStringList blockStrings = QStringList() << "*Model_Space" << "*Paper_Space" << "*Paper_Space0";
for ( const QString &block : blockStrings )
{
writeGroup( 0, QStringLiteral( "BLOCK_RECORD" ) );
mBlockHandles.insert( block, writeHandle() );
@@ -771,7 +773,8 @@ void QgsDxfExport::writeTables()
writeGroup( 0, QStringLiteral( "ENDTAB" ) );

QSet<QString> layerNames;
Q_FOREACH ( QgsMapLayer *ml, mMapSettings.layers() )
const QList< QgsMapLayer * > layers = mMapSettings.layers();
for ( QgsMapLayer *ml : layers )
{
if ( !layerIsScaleBasedVisible( ml ) )
continue;
@@ -787,8 +790,8 @@ void QgsDxfExport::writeTables()
}
else
{
QSet<QVariant> values = vl->uniqueValues( attrIdx );
Q_FOREACH ( const QVariant &v, values )
const QSet<QVariant> values = vl->uniqueValues( attrIdx );
for ( const QVariant &v : values )
{
layerNames << dxfLayerName( v.toString() );
}
@@ -813,7 +816,7 @@ void QgsDxfExport::writeTables()
writeGroup( 6, QStringLiteral( "CONTINUOUS" ) );
writeHandle( 390, DXF_HANDPLOTSTYLE );

Q_FOREACH ( const QString &layerName, layerNames )
for ( const QString &layerName : qgsAsConst( layerNames ) )
{
writeGroup( 0, QStringLiteral( "LAYER" ) );
writeHandle();
@@ -859,7 +862,8 @@ void QgsDxfExport::writeBlocks()
startSection();
writeGroup( 2, QStringLiteral( "BLOCKS" ) );

Q_FOREACH ( const QString &block, QStringList() << "*Model_Space" << "*Paper_Space" << "*Paper_Space0" )
const QStringList blockStrings = QStringList() << "*Model_Space" << "*Paper_Space" << "*Paper_Space0";
for ( const QString &block : blockStrings )
{
writeGroup( 0, QStringLiteral( "BLOCK" ) );
writeHandle();
@@ -968,7 +972,8 @@ void QgsDxfExport::writeEntities()
engine.setMapSettings( mMapSettings );

// iterate through the maplayers
Q_FOREACH ( QgsMapLayer *ml, mMapSettings.layers() )
const QList< QgsMapLayer *> layers = mMapSettings.layers();
for ( QgsMapLayer *ml : layers )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
if ( !vl || !layerIsScaleBasedVisible( vl ) )
@@ -3978,7 +3983,8 @@ QList< QPair< QgsSymbolLayer *, QgsSymbol * > > QgsDxfExport::symbolLayers( QgsR
{
QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers;

Q_FOREACH ( QgsMapLayer *ml, mMapSettings.layers() )
const QList< QgsMapLayer * > layers = mMapSettings.layers();
for ( QgsMapLayer *ml : layers )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
if ( !vl )
@@ -4016,7 +4022,8 @@ QList< QPair< QgsSymbolLayer *, QgsSymbol * > > QgsDxfExport::symbolLayers( QgsR
void QgsDxfExport::writeDefaultLinetypes()
{
// continuous (Qt solid line)
Q_FOREACH ( const QString &ltype, QStringList() << "ByLayer" << "ByBlock" << "CONTINUOUS" )
const QStringList blockStrings = QStringList() << "ByLayer" << "ByBlock" << "CONTINUOUS";
for ( const QString &ltype : blockStrings )
{
writeGroup( 0, QStringLiteral( "LTYPE" ) );
writeHandle();
@@ -4232,7 +4239,8 @@ bool QgsDxfExport::layerIsScaleBasedVisible( const QgsMapLayer *layer ) const

QString QgsDxfExport::layerName( const QString &id, const QgsFeature &f ) const
{
Q_FOREACH ( QgsMapLayer *ml, mMapSettings.layers() )
const QList< QgsMapLayer * > layers = mMapSettings.layers();
for ( QgsMapLayer *ml : layers )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
if ( vl && vl->id() == id )
@@ -4247,7 +4255,8 @@ QString QgsDxfExport::layerName( const QString &id, const QgsFeature &f ) const

QString QgsDxfExport::dxfEncoding( const QString &name )
{
Q_FOREACH ( const QByteArray &codec, QTextCodec::availableCodecs() )
const QList< QByteArray > codecs = QTextCodec::availableCodecs();
for ( const QByteArray &codec : codecs )
{
if ( name != codec )
continue;
@@ -4268,7 +4277,8 @@ QString QgsDxfExport::dxfEncoding( const QString &name )
QStringList QgsDxfExport::encodings()
{
QStringList encodings;
Q_FOREACH ( QByteArray codec, QTextCodec::availableCodecs() )
const QList< QByteArray > codecs = QTextCodec::availableCodecs();
for ( const QByteArray &codec : codecs )
{
int i;
for ( i = 0; i < static_cast< int >( sizeof( DXF_ENCODINGS ) / sizeof( *DXF_ENCODINGS ) ) && strcmp( codec.data(), DXF_ENCODINGS[i][1] ) != 0; ++i )
@@ -157,7 +157,7 @@ bool QgsEffectStack::saveProperties( QDomDocument &doc, QDomElement &element ) c
effectElement.setAttribute( QStringLiteral( "enabled" ), mEnabled );

bool ok = true;
Q_FOREACH ( QgsPaintEffect *effect, mEffectList )
for ( QgsPaintEffect *effect : mEffectList )
{
if ( effect )
ok = ok && effect->saveProperties( doc, effectElement );
@@ -149,7 +149,8 @@ QString QgsExpression::quotedValue( const QVariant &value, QVariant::Type type )
case QVariant::List:
{
QStringList quotedValues;
Q_FOREACH ( const QVariant &v, value.toList() )
const QVariantList values = value.toList();
for ( const QVariant &v : values )
{
quotedValues += quotedValue( v );
}
@@ -175,7 +176,8 @@ int QgsExpression::functionIndex( const QString &name )
{
if ( QString::compare( name, QgsExpression::Functions()[i]->name(), Qt::CaseInsensitive ) == 0 )
return i;
Q_FOREACH ( const QString &alias, QgsExpression::Functions()[i]->aliases() )
const QStringList aliases = QgsExpression::Functions()[i]->aliases();
for ( const QString &alias : aliases )
{
if ( QString::compare( name, alias, Qt::CaseInsensitive ) == 0 )
return i;
@@ -506,7 +508,7 @@ QString QgsExpression::helpText( QString name )
.arg( tr( "%1 %2" ).arg( f.mType, name ),
f.mDescription ) );

Q_FOREACH ( const HelpVariant &v, f.mVariants )
for ( const HelpVariant &v : qgsAsConst( f.mVariants ) )
{
if ( f.mVariants.size() > 1 )
{
@@ -538,7 +540,7 @@ QString QgsExpression::helpText( QString name )
helpContents += '(';

QString delim;
Q_FOREACH ( const HelpArg &a, v.mArguments )
for ( const HelpArg &a : qgsAsConst( v.mArguments ) )
{
helpContents += delim;
delim = QStringLiteral( ", " );
@@ -564,7 +566,7 @@ QString QgsExpression::helpText( QString name )
{
helpContents += QStringLiteral( "<h4>%1</h4>\n<div class=\"arguments\">\n<table>" ).arg( tr( "Arguments" ) );

Q_FOREACH ( const HelpArg &a, v.mArguments )
for ( const HelpArg &a : qgsAsConst( v.mArguments ) )
{
if ( a.mSyntaxOnly )
continue;
@@ -579,7 +581,7 @@ QString QgsExpression::helpText( QString name )
{
helpContents += QStringLiteral( "<h4>%1</h4>\n<div class=\"examples\">\n<ul>\n" ).arg( tr( "Examples" ) );

Q_FOREACH ( const HelpExample &e, v.mExamples )
for ( const HelpExample &e : qgsAsConst( v.mExamples ) )
{
helpContents += "<li><code>" + e.mExpression + "</code> &rarr; <code>" + e.mReturns + "</code>";

@@ -179,7 +179,7 @@ class CORE_EXPORT QgsExpressionFunction
return mParams;

int min = 0;
Q_FOREACH ( const Parameter &param, mParameterList )
for ( const Parameter &param : mParameterList )
{
if ( !param.optional() )
min++;

0 comments on commit 85e6a63

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