Skip to content

Commit

Permalink
foreach -> Q_FOREACH
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 2, 2016
1 parent c3a5743 commit c3ed6b9
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -573,7 +573,7 @@ void QgsLayerTreeModel::setLegendFilter( const QgsMapSettings* settings, bool us
// collect expression filters
if ( useExpressions )
{
foreach ( QgsLayerTreeLayer* nodeLayer, mRootNode->findLayers() )
Q_FOREACH ( QgsLayerTreeLayer* nodeLayer, mRootNode->findLayers() )
{
bool enabled;
QString expr = QgsLayerTreeUtils::legendFilterByExpression( *nodeLayer, &enabled );
Expand Down
4 changes: 2 additions & 2 deletions src/core/layertree/qgslayertreeutils.cpp
Expand Up @@ -383,7 +383,7 @@ QString QgsLayerTreeUtils::legendFilterByExpression( const QgsLayerTreeLayer& la

bool QgsLayerTreeUtils::hasLegendFilterExpression( const QgsLayerTreeGroup& group )
{
foreach ( QgsLayerTreeLayer* l, group.findLayers() )
Q_FOREACH ( QgsLayerTreeLayer* l, group.findLayers() )
{
bool exprEnabled;
QString expr = legendFilterByExpression( *l, &exprEnabled );
Expand All @@ -403,7 +403,7 @@ QgsLayerTreeLayer* QgsLayerTreeUtils::insertLayerBelow( QgsLayerTreeGroup* group
return nullptr;

int idx = 0;
foreach ( QgsLayerTreeNode* vl, inTree->parent()->children() )
Q_FOREACH ( QgsLayerTreeNode* vl, inTree->parent()->children() )
{
if ( vl->nodeType() == QgsLayerTreeNode::NodeLayer && static_cast<QgsLayerTreeLayer*>( vl )->layer() == refLayer )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgscoordinatetransform.h
Expand Up @@ -247,7 +247,7 @@ class CORE_EXPORT QgsCoordinateTransform : public QObject

signals:
/** Signal when an invalid pj_transform() has occurred */
void invalidTransformInput() const;
void invalidTransformInput() const;

private:

Expand Down
20 changes: 10 additions & 10 deletions src/core/qgstracer.cpp
Expand Up @@ -123,7 +123,7 @@ QgsTracerGraph* makeGraph( const QVector<QgsPolyline>& edges )
g->joinedVertices = 0;
QHash<QgsPoint, int> point2vertex;

foreach ( const QgsPolyline& line, edges )
Q_FOREACH ( const QgsPolyline& line, edges )
{
QgsPoint p1( line[0] );
QgsPoint p2( line[line.count() - 1] );
Expand Down Expand Up @@ -243,7 +243,7 @@ QVector<QgsPoint> shortestPath( const QgsTracerGraph& g, int v1, int v2 )
}

std::reverse( path.begin(), path.end() );
//foreach (int x, path)
//Q_FOREACH (int x, path)
// qDebug("e: %d", x);

std::reverse( points.begin(), points.end() );
Expand Down Expand Up @@ -377,7 +377,7 @@ void resetGraph( QgsTracerGraph& g )
g.joinedVertices = 0;

// fix vertices of deactivated edges
foreach ( int eIdx, g.inactiveEdges )
Q_FOREACH ( int eIdx, g.inactiveEdges )
{
if ( eIdx >= g.e.count() )
continue;
Expand Down Expand Up @@ -412,18 +412,18 @@ void extractLinework( const QgsGeometry* g, QgsMultiPolyline& mpl )
break;

case QgsWKBTypes::Polygon:
foreach ( const QgsPolyline& ring, g->asPolygon() )
Q_FOREACH ( const QgsPolyline& ring, g->asPolygon() )
mpl << ring;
break;

case QgsWKBTypes::MultiLineString:
foreach ( const QgsPolyline& linestring, g->asMultiPolyline() )
Q_FOREACH ( const QgsPolyline& linestring, g->asMultiPolyline() )
mpl << linestring;
break;

case QgsWKBTypes::MultiPolygon:
foreach ( const QgsPolygon& polygon, g->asMultiPolygon() )
foreach ( const QgsPolyline& ring, polygon )
Q_FOREACH ( const QgsPolygon& polygon, g->asMultiPolygon() )
Q_FOREACH ( const QgsPolyline& ring, polygon )
mpl << ring;
break;

Expand Down Expand Up @@ -459,7 +459,7 @@ bool QgsTracer::initGraph()

t1.start();
int featuresCounted = 0;
foreach ( QgsVectorLayer* vl, mLayers )
Q_FOREACH ( QgsVectorLayer* vl, mLayers )
{
QgsCoordinateTransform ct( vl->crs(), mCRS );

Expand Down Expand Up @@ -545,7 +545,7 @@ void QgsTracer::setLayers( const QList<QgsVectorLayer*>& layers )
if ( mLayers == layers )
return;

foreach ( QgsVectorLayer* layer, mLayers )
Q_FOREACH ( QgsVectorLayer* layer, mLayers )
{
disconnect( layer, SIGNAL( featureAdded( QgsFeatureId ) ), this, SLOT( onFeatureAdded( QgsFeatureId ) ) );
disconnect( layer, SIGNAL( featureDeleted( QgsFeatureId ) ), this, SLOT( onFeatureDeleted( QgsFeatureId ) ) );
Expand All @@ -555,7 +555,7 @@ void QgsTracer::setLayers( const QList<QgsVectorLayer*>& layers )

mLayers = layers;

foreach ( QgsVectorLayer* layer, mLayers )
Q_FOREACH ( QgsVectorLayer* layer, mLayers )
{
connect( layer, SIGNAL( featureAdded( QgsFeatureId ) ), this, SLOT( onFeatureAdded( QgsFeatureId ) ) );
connect( layer, SIGNAL( featureDeleted( QgsFeatureId ) ), this, SLOT( onFeatureDeleted( QgsFeatureId ) ) );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.cpp
Expand Up @@ -1630,7 +1630,7 @@ bool QgsVectorLayer::writeXml( QDomNode & layer_node,

// dependencies
QDomElement dependenciesElement = document.createElement( "layerDependencies" );
foreach ( QString layerId, layerDependencies() )
Q_FOREACH ( QString layerId, layerDependencies() )
{
QDomElement depElem = document.createElement( "layer" );
depElem.setAttribute( "id", layerId );
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsvirtuallayerdefinition.cpp
Expand Up @@ -170,7 +170,7 @@ QUrl QgsVirtualLayerDefinition::toUrl() const
QUrl url;
url.setPath( filePath() );

foreach ( const QgsVirtualLayerDefinition::SourceLayer& l, sourceLayers() )
Q_FOREACH ( const QgsVirtualLayerDefinition::SourceLayer& l, sourceLayers() )
{
if ( l.isReferenced() )
url.addQueryItem( "layer_ref", QString( "%1:%2" ).arg( l.reference(), l.name() ) );
Expand Down Expand Up @@ -231,7 +231,7 @@ void QgsVirtualLayerDefinition::addSource( const QString& name, const QString& s

bool QgsVirtualLayerDefinition::hasSourceLayer( const QString& name ) const
{
foreach ( const QgsVirtualLayerDefinition::SourceLayer& l, sourceLayers() )
Q_FOREACH ( const QgsVirtualLayerDefinition::SourceLayer& l, sourceLayers() )
{
if ( l.name() == name )
{
Expand All @@ -243,7 +243,7 @@ bool QgsVirtualLayerDefinition::hasSourceLayer( const QString& name ) const

bool QgsVirtualLayerDefinition::hasReferencedLayers() const
{
foreach ( const QgsVirtualLayerDefinition::SourceLayer& l, sourceLayers() )
Q_FOREACH ( const QgsVirtualLayerDefinition::SourceLayer& l, sourceLayers() )
{
if ( l.isReferenced() )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvirtuallayerdefinitionutils.cpp
Expand Up @@ -49,15 +49,15 @@ QgsVirtualLayerDefinition QgsVirtualLayerDefinitionUtils::fromJoinedLayer( QgsVe
}

int joinIdx = 0;
foreach ( const QgsVectorJoinInfo& join, layer->vectorJoins() )
Q_FOREACH ( const QgsVectorJoinInfo& join, layer->vectorJoins() )
{
QString joinName = QString( "j%1" ).arg( ++joinIdx );
QString prefix = join.prefix.isEmpty() ? layer->name() + "_" : join.prefix;

leftJoins << QString( "LEFT JOIN %1 AS %2 ON t.\"%3\"=%2.\"%5\"" ).arg( join.joinLayerId, joinName, join.joinFieldName, join.targetFieldName );
if ( join.joinFieldNamesSubset() )
{
foreach ( const QString& f, *join.joinFieldNamesSubset() )
Q_FOREACH ( const QString& f, *join.joinFieldNamesSubset() )
{
columns << joinName + "." + f + " AS " + prefix + f;
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsmapcanvastracer.cpp
Expand Up @@ -93,15 +93,15 @@ void QgsMapCanvasTracer::configure()
}
break;
case QgsSnappingUtils::SnapAllLayers:
foreach ( const QString& layerId, visibleLayerIds )
Q_FOREACH ( const QString& layerId, visibleLayerIds )
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerId ) );
if ( vl )
layers << vl;
}
break;
case QgsSnappingUtils::SnapAdvanced:
foreach ( const QgsSnappingUtils::LayerConfig& cfg, mCanvas->snappingUtils()->layers() )
Q_FOREACH ( const QgsSnappingUtils::LayerConfig& cfg, mCanvas->snappingUtils()->layers() )
{
if ( visibleLayerIds.contains( cfg.layer->id() ) )
layers << cfg.layer;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/symbology-ng/qgsstylev2groupselectiondialog.cpp
Expand Up @@ -98,7 +98,7 @@ void QgsStyleV2GroupSelectionDialog::groupTreeSelectionChanged( const QItemSelec
QModelIndexList selectedItems = selected.indexes();
QModelIndexList deselectedItems = deselected.indexes();

foreach ( index, deselectedItems )
Q_FOREACH ( index, deselectedItems )
{
if ( index.data( Qt::UserRole + 2 ).toString() == "groupsheader" )
{
Expand All @@ -121,7 +121,7 @@ void QgsStyleV2GroupSelectionDialog::groupTreeSelectionChanged( const QItemSelec
emit groupDeselected( index.data( ).toString() );
}
}
foreach ( index, selectedItems )
Q_FOREACH ( index, selectedItems )
{
if ( index.data( Qt::UserRole + 2 ).toString( ) == "groupsheader" )
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/virtual/qgsvirtuallayerprovider.cpp
Expand Up @@ -602,7 +602,7 @@ QgsAttributeList QgsVirtualLayerProvider::pkAttributeIndexes()
QSet<QString> QgsVirtualLayerProvider::layerDependencies() const
{
QSet<QString> deps;
foreach ( const QgsVirtualLayerDefinition::SourceLayer& l, mDefinition.sourceLayers() )
Q_FOREACH ( const QgsVirtualLayerDefinition::SourceLayer& l, mDefinition.sourceLayers() )
{
if ( l.isReferenced() )
deps << l.reference();
Expand Down
6 changes: 3 additions & 3 deletions src/providers/virtual/qgsvirtuallayersourceselect.cpp
Expand Up @@ -45,7 +45,7 @@ QgsVirtualLayerSourceSelect::QgsVirtualLayerSourceSelect( QWidget* parent, Qt::W
if ( treeView )
{
QgsLayerTreeModel* model = qobject_cast<QgsLayerTreeModel*>( treeView->model() );
foreach ( QgsLayerTreeLayer* layer, model->rootGroup()->findLayers() )
Q_FOREACH ( QgsLayerTreeLayer* layer, model->rootGroup()->findLayers() )
{
if ( layer->layer()->type() == QgsMapLayer::VectorLayer && static_cast<QgsVectorLayer*>( layer->layer() )->providerType() == "virtual" )
{
Expand Down Expand Up @@ -87,13 +87,13 @@ QgsVirtualLayerSourceSelect::QgsVirtualLayerSourceSelect( QWidget* parent, Qt::W
}

// configure auto completion with table and column names
foreach ( QgsMapLayer* l, QgsMapLayerRegistry::instance()->mapLayers().values() )
Q_FOREACH ( QgsMapLayer* l, QgsMapLayerRegistry::instance()->mapLayers().values() )
{
if ( l->type() == QgsMapLayer::VectorLayer )
{
apis->add( l->name() );
QgsVectorLayer* vl = static_cast<QgsVectorLayer*>( l );
foreach ( const QgsField& f, vl->fields().toList() )
Q_FOREACH ( const QgsField& f, vl->fields().toList() )
{
apis->add( f.name() );
}
Expand Down
4 changes: 2 additions & 2 deletions src/providers/virtual/qgsvirtuallayersqlitemodule.cpp
Expand Up @@ -842,7 +842,7 @@ void registerQgisFunctions( sqlite3* db )
QStringList reservedFunctions;
reservedFunctions << "left" << "right" << "union";
// register QGIS expression functions
foreach ( QgsExpression::Function* foo, QgsExpression::Functions() )
Q_FOREACH ( QgsExpression::Function* foo, QgsExpression::Functions() )
{
if ( foo->usesgeometry() || foo->lazyEval() )
{
Expand All @@ -857,7 +857,7 @@ void registerQgisFunctions( sqlite3* db )
names << foo->name();
names << foo->aliases();

foreach ( QString name, names ) // for each alias
Q_FOREACH ( QString name, names ) // for each alias
{
if ( reservedFunctions.contains( name ) ) // reserved keyword
name = "_" + name;
Expand Down
2 changes: 1 addition & 1 deletion src/server/qgswfsserver.cpp
Expand Up @@ -553,7 +553,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
mAccessControl->filterFeatures( layer, fReq );

QStringList attributes = QStringList();
foreach ( int idx, attrIndexes )
Q_FOREACH ( int idx, attrIndexes )
{
attributes.append( layer->pendingFields().field( idx ).name() );
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/qgswmsprojectparser.cpp
Expand Up @@ -535,7 +535,7 @@ QgsComposition* QgsWMSProjectParser::initComposition( const QString& composerTem
{
QgsLayerTreeGroup* root = model->rootGroup();
QStringList layerIds = root->findLayerIds();
// foreach layer find in the layer tree
// for each layer find in the layer tree
// load it if the layer id is not QgsMapLayerRegistry
Q_FOREACH ( const QString& layerId, layerIds )
{
Expand Down
8 changes: 4 additions & 4 deletions src/server/qgswmsserver.cpp
Expand Up @@ -1250,7 +1250,7 @@ QByteArray* QgsWMSServer::getPrint( const QString& formatString )
QMap<QString, QString> originalLayerFilters = applyRequestedLayerFilters( layersList );

#ifdef HAVE_SERVER_PYTHON_PLUGINS
foreach ( QgsMapLayer *layer, QgsMapLayerRegistry::instance()->mapLayers() )
Q_FOREACH ( QgsMapLayer *layer, QgsMapLayerRegistry::instance()->mapLayers() )
{
if ( !mAccessControl->layerReadPermission( layer ) )
{
Expand Down Expand Up @@ -1384,7 +1384,7 @@ QImage* QgsWMSServer::getMap( HitTest* hitTest )
QMap<QString, QString> originalLayerFilters = applyRequestedLayerFilters( layersList );

#ifdef HAVE_SERVER_PYTHON_PLUGINS
foreach ( QgsMapLayer *layer, QgsMapLayerRegistry::instance()->mapLayers() )
Q_FOREACH ( QgsMapLayer *layer, QgsMapLayerRegistry::instance()->mapLayers() )
{
if ( !mAccessControl->layerReadPermission( layer ) )
{
Expand Down Expand Up @@ -2188,7 +2188,7 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,

QStringList attributes;
QgsField field;
foreach ( field, layer->pendingFields().toList() )
Q_FOREACH ( field, layer->pendingFields().toList() )
{
attributes.append( field.name() );
}
Expand Down Expand Up @@ -2599,7 +2599,7 @@ void QgsWMSServer::applyAccessControlLayersFilters( const QStringList& layerList
Q_FOREACH ( const QString& layerName, layerList )
{
QList<QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayersByName( layerName );
foreach ( QgsMapLayer* mapLayer, mapLayers )
Q_FOREACH ( QgsMapLayer* mapLayer, mapLayers )
{
applyAccessControlLayerFilters( mapLayer, originalLayerFilters );
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testqgslegendrenderer.cpp
Expand Up @@ -440,7 +440,7 @@ void TestQgsLegendRenderer::testFilterByPolygon()
mapSettings.setOutputSize( QSize( 400, 100 ) );
mapSettings.setOutputDpi( 96 );
QStringList ll;
foreach ( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
Q_FOREACH ( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
{
ll << l->id();
}
Expand Down Expand Up @@ -475,7 +475,7 @@ void TestQgsLegendRenderer::testFilterByExpression()
mapSettings.setOutputSize( QSize( 400, 100 ) );
mapSettings.setOutputDpi( 96 );
QStringList ll;
foreach ( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
Q_FOREACH ( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
{
ll << l->id();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgstracer.cpp
Expand Up @@ -63,7 +63,7 @@ static QgsVectorLayer* make_layer( const QStringList& wkts )
Q_ASSERT( vl->isValid() );

vl->startEditing();
foreach ( const QString& wkt, wkts )
Q_FOREACH ( const QString& wkt, wkts )
{
QgsFeature f( make_feature( wkt ) );
vl->addFeature( f, false );
Expand Down

0 comments on commit c3ed6b9

Please sign in to comment.