Skip to content
Permalink
Browse files

foreach -> Q_FOREACH

  • Loading branch information
nyalldawson committed Feb 2, 2016
1 parent c3a5743 commit c3ed6b9fa3981ccbfec34a618f78649f3c3dfb31
@@ -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 );
@@ -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 );
@@ -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 )
{
@@ -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:

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

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

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

0 comments on commit c3ed6b9

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