Navigation Menu

Skip to content

Commit

Permalink
Daily Q_FOREACH -> for conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 3, 2017
1 parent e30f704 commit 85e6a63
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/core/composer/qgsatlascomposition.cpp
Expand Up @@ -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 )
{
Expand Down
3 changes: 2 additions & 1 deletion src/core/composer/qgscomposerattributetablemodelv2.cpp
Expand Up @@ -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 )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/diagram/qgshistogramdiagram.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
Expand Down
36 changes: 23 additions & 13 deletions src/core/dxf/qgsdxfexport.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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;
Expand All @@ -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() );
}
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 ) )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 )
Expand All @@ -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;
Expand All @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion src/core/effects/qgseffectstack.cpp
Expand Up @@ -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 );
Expand Down
14 changes: 8 additions & 6 deletions src/core/expression/qgsexpression.cpp
Expand Up @@ -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 );
}
Expand All @@ -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;
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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( ", " );
Expand All @@ -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;
Expand All @@ -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>";

Expand Down
2 changes: 1 addition & 1 deletion src/core/expression/qgsexpressionfunction.h
Expand Up @@ -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++;
Expand Down

0 comments on commit 85e6a63

Please sign in to comment.