Skip to content
Permalink
Browse files

[Server] Q_FOREACH replaced by for

  • Loading branch information
rldhont committed Aug 7, 2018
1 parent 29d280f commit f6d0fc08f92389b36f52a781dfec5256da38127e
@@ -24,7 +24,7 @@

void QgsAccessControl::resolveFilterFeatures( const QList<QgsMapLayer *> &layers )
{
Q_FOREACH ( QgsMapLayer *l, layers )
for ( QgsMapLayer *l : layers )
{
if ( l->type() == QgsMapLayer::LayerType::VectorLayer )
{
@@ -228,7 +228,7 @@ void QgsRequestHandler::parseInput()
typedef QPair<QString, QString> pair_t;
QUrlQuery query( inputString );
QList<pair_t> items = query.queryItems();
Q_FOREACH ( pair_t pair, items )
for ( pair_t pair : items )
{
// QUrl::fromPercentEncoding doesn't replace '+' with space
const QString key = QUrl::fromPercentEncoding( pair.first.replace( '+', ' ' ).toUtf8() );
@@ -90,7 +90,7 @@ bool QgsServerPlugins::initPlugins( QgsServerInterface *interface )
//Init plugins: loads a list of installed plugins and filter them
//for "server" metadata
bool atLeastOneEnabled = false;
Q_FOREACH ( const QString &pluginName, sPythonUtils->pluginList() )
for ( const QString &pluginName : sPythonUtils->pluginList() )
{
QString pluginService = sPythonUtils->getPluginMetadata( pluginName, QStringLiteral( "server" ) );
if ( pluginService == QLatin1String( "True" ) )
@@ -70,7 +70,7 @@ void QgsServiceNativeLoader::loadModules( const QString &modulePath, QgsServiceR
qDebug() << QString( "Checking %1 for native services modules" ).arg( moduleDir.path() );
//QgsDebugMsg( QString( "Checking %1 for native services modules" ).arg( moduleDir.path() ) );

Q_FOREACH ( const QFileInfo &fi, moduleDir.entryInfoList() )
for ( const QFileInfo &fi : moduleDir.entryInfoList() )
{
QgsServiceModule *module = loadNativeModule( fi.filePath() );
if ( module )
@@ -317,7 +317,7 @@ namespace QgsWfs
accessControl->filterFeatures( vlayer, featureRequest );

QStringList attributes = QStringList();
Q_FOREACH ( int idx, attrIndexes )
for ( int idx : attrIndexes )
{
attributes.append( vlayer->fields().field( idx ).name() );
}
@@ -23,7 +23,7 @@

QgsLayerRestorer::QgsLayerRestorer( const QList<QgsMapLayer *> &layers )
{
Q_FOREACH ( QgsMapLayer *layer, layers )
for ( QgsMapLayer *layer : layers )
{
QgsLayerSettings settings;
settings.name = layer->name();
@@ -113,7 +113,7 @@ namespace QgsWms
// WCS layers
QStringList wcsLayerIds = QgsServerProjectUtils::wcsLayerIds( *project );

Q_FOREACH ( QgsMapLayer *layer, project->mapLayers() )
for ( QgsMapLayer *layer : project->mapLayers() )
{
QString name = layer->name();
if ( useLayerIds )
@@ -1169,7 +1169,7 @@ namespace QgsWms
//href needs to be a prefix
QString hrefString = href.toString( QUrl::FullyDecoded );
hrefString.append( href.hasQuery() ? "&" : "?" );
Q_FOREACH ( QString styleName, currentLayer->styleManager()->styles() )
for ( const QString &styleName : currentLayer->styleManager()->styles() )
{
QDomElement styleElem = doc.createElement( QStringLiteral( "Style" ) );
QDomElement styleNameElem = doc.createElement( QStringLiteral( "Name" ) );
@@ -1268,7 +1268,7 @@ namespace QgsWms
}
else //no crs constraint
{
Q_FOREACH ( const QString &crs, crsList )
for ( const QString &crs : crsList )
{
appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, crs );
}
@@ -1379,7 +1379,7 @@ namespace QgsWms
}
else //no crs constraint
{
Q_FOREACH ( const QString &crs, crsList )
for ( const QString &crs : crsList )
{
appendLayerBoundingBox( doc, layerElem, layerExtent, layerCRS, crs, project );
}
@@ -435,7 +435,7 @@ namespace QgsWms

void appendOwsLayerStyles( QDomDocument &doc, QDomElement &layerElem, QgsMapLayer *currentLayer )
{
Q_FOREACH ( QString styleName, currentLayer->styleManager()->styles() )
for ( const QString &styleName : currentLayer->styleManager()->styles() )
{
QDomElement styleListElem = doc.createElement( QStringLiteral( "StyleList" ) );
//only one default style in project file mode
@@ -133,7 +133,7 @@ namespace QgsWms
// WMS restricted layers
QStringList restrictedLayers = QgsServerProjectUtils::wmsRestrictedLayers( *project );

Q_FOREACH ( QgsMapLayer *layer, project->mapLayers() )
for ( QgsMapLayer *layer : project->mapLayers() )
{
QString name = layer->name();
if ( useLayerIds )
@@ -172,7 +172,7 @@ namespace QgsWms
if ( vlayer->isSpatial() )
{
QString currentStyle = vlayer->styleManager()->currentStyle();
Q_FOREACH ( QString styleName, vlayer->styleManager()->styles() )
for ( const QString &styleName : vlayer->styleManager()->styles() )
{
vlayer->styleManager()->setCurrentStyle( styleName );
QDomElement styleElem = vlayer->renderer()->writeSld( myDocument, styleName );
@@ -111,9 +111,9 @@ namespace QgsWms

QgsLayerTreeModelLegendNode *_findLegendNodeForRule( QgsLayerTreeModel *legendModel, const QString &rule )
{
Q_FOREACH ( QgsLayerTreeLayer *nodeLayer, legendModel->rootGroup()->findLayers() )
for ( QgsLayerTreeLayer *nodeLayer : legendModel->rootGroup()->findLayers() )
{
Q_FOREACH ( QgsLayerTreeModelLegendNode *legendNode, legendModel->layerLegendNodes( nodeLayer ) )
for ( QgsLayerTreeModelLegendNode *legendNode : legendModel->layerLegendNodes( nodeLayer ) )
{
if ( legendNode->data( Qt::DisplayRole ).toString() == rule )
return legendNode;
@@ -181,7 +181,7 @@ namespace QgsWms
std::reverse( layers.begin(), layers.end() );

// check permissions
Q_FOREACH ( QgsMapLayer *ml, layers )
for ( QgsMapLayer *ml : layers )
checkLayerReadPermissions( ml );

// build layer tree model for legend
@@ -241,7 +241,7 @@ namespace QgsWms
{
QgsRenderContext context = QgsRenderContext::fromMapSettings( mapSettings );

Q_FOREACH ( const QString &id, mapSettings.layerIds() )
for ( const QString &id : mapSettings.layerIds() )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( mProject->mapLayer( id ) );
if ( !vl || !vl->renderer() )
@@ -276,7 +276,7 @@ namespace QgsWms
context.expressionContext().setFeature( f );
if ( moreSymbolsPerFeature )
{
Q_FOREACH ( QgsSymbol *s, r->originalSymbolsForFeature( f, context ) )
for ( QgsSymbol *s : r->originalSymbolsForFeature( f, context ) )
usedSymbols.insert( QgsSymbolLayerUtils::symbolProperties( s ) );
}
else
@@ -328,11 +328,11 @@ namespace QgsWms

// configure each layer with opacity, selection filter, ...
bool updateMapExtent = mWmsParameters.bbox().isEmpty();
Q_FOREACH ( QgsMapLayer *layer, layers )
for ( QgsMapLayer *layer : layers )
{
checkLayerReadPermissions( layer );

Q_FOREACH ( QgsWmsParametersLayer param, params )
for ( QgsWmsParametersLayer param : params )
{
if ( param.mNickname == layerNickname( *layer ) )
{
@@ -677,11 +677,11 @@ namespace QgsWms

// configure each layer with opacity, selection filter, ...
bool updateMapExtent = mWmsParameters.bbox().isEmpty();
Q_FOREACH ( QgsMapLayer *layer, layers )
for ( QgsMapLayer *layer : layers )
{
checkLayerReadPermissions( layer );

Q_FOREACH ( QgsWmsParametersLayer param, params )
for ( const QgsWmsParametersLayer param : params )
{
if ( param.mNickname == layerNickname( *layer ) )
{
@@ -774,7 +774,7 @@ namespace QgsWms
// get dxf layers
QList< QgsDxfExport::DxfLayer > dxfLayers;
int layerIdx = -1;
Q_FOREACH ( QgsMapLayer *layer, layers )
for ( QgsMapLayer *layer : layers )
{
layerIdx++;
if ( layer->type() != QgsMapLayer::VectorLayer )
@@ -784,7 +784,7 @@ namespace QgsWms

checkLayerReadPermissions( layer );

Q_FOREACH ( QgsWmsParametersLayer param, params )
for ( QgsWmsParametersLayer param : params )
{
if ( param.mNickname == layerNickname( *layer ) )
{
@@ -951,11 +951,11 @@ namespace QgsWms
// remove non identifiable layers
//removeNonIdentifiableLayers( layers );

Q_FOREACH ( QgsMapLayer *layer, layers )
for ( QgsMapLayer *layer : layers )
{
checkLayerReadPermissions( layer );

Q_FOREACH ( QgsWmsParametersLayer param, params )
for ( QgsWmsParametersLayer param : params )
{
if ( param.mNickname == layerNickname( *layer ) )
{
@@ -1244,11 +1244,11 @@ namespace QgsWms
//layers can have assigned a different name for GetCapabilities
QHash<QString, QString> layerAliasMap = QgsServerProjectUtils::wmsFeatureInfoLayerAliasMap( *mProject );

Q_FOREACH ( QString queryLayer, queryLayers )
for ( const QString &queryLayer : queryLayers )
{
bool validLayer = false;
bool queryableLayer = true;
Q_FOREACH ( QgsMapLayer *layer, layers )
for ( QgsMapLayer *layer : layers )
{
if ( queryLayer == layerNickname( *layer ) )
{
@@ -1456,8 +1456,7 @@ namespace QgsWms
mAccessControl->filterFeatures( layer, fReq );

QStringList attributes;
QgsField field;
Q_FOREACH ( field, layer->fields().toList() )
for ( QgsField field : layer->fields().toList() )
{
attributes.append( field.name() );
}
@@ -2368,13 +2367,13 @@ namespace QgsWms
QStringList restrictedLayersNames;
QgsLayerTreeGroup *root = mProject->layerTreeRoot();

Q_FOREACH ( QString l, restricted )
for ( const QString &l : restricted )
{
QgsLayerTreeGroup *group = root->findGroup( l );
if ( group )
{
QList<QgsLayerTreeLayer *> groupLayers = group->findLayers();
Q_FOREACH ( QgsLayerTreeLayer *treeLayer, groupLayers )
for ( QgsLayerTreeLayer *treeLayer : groupLayers )
{
restrictedLayersNames.append( treeLayer->name() );
}
@@ -2387,7 +2386,7 @@ namespace QgsWms

// build output with names, ids or short name according to the configuration
QList<QgsLayerTreeLayer *> layers = root->findLayers();
Q_FOREACH ( QgsLayerTreeLayer *layer, layers )
for ( QgsLayerTreeLayer *layer : layers )
{
if ( restrictedLayersNames.contains( layer->name() ) )
{
@@ -2398,7 +2397,7 @@ namespace QgsWms

void QgsRenderer::initNicknameLayers()
{
Q_FOREACH ( QgsMapLayer *ml, mProject->mapLayers() )
for ( QgsMapLayer *ml : mProject->mapLayers() )
{
mNicknameLayers[ layerNickname( *ml ) ] = ml;
}
@@ -2469,7 +2468,7 @@ namespace QgsWms

// try to create highlight layer for each geometry
QString crs = mWmsParameters.crs();
Q_FOREACH ( QgsWmsParametersHighlightLayer param, params )
for ( QgsWmsParametersHighlightLayer param : params )
{
// create sld document from symbology
QDomDocument sldDoc;
@@ -2675,7 +2674,7 @@ namespace QgsWms
{
QList<QgsMapLayer *> layers;

Q_FOREACH ( QgsWmsParametersLayer param, params )
for ( QgsWmsParametersLayer param : params )
{
QString nickname = param.mNickname;
QString style = param.mStyle;
@@ -2798,7 +2797,7 @@ namespace QgsWms
if ( layer->type() == QgsMapLayer::VectorLayer )
{
QgsVectorLayer *filteredLayer = qobject_cast<QgsVectorLayer *>( layer );
Q_FOREACH ( QString filter, filters )
for ( const QString &filter : filters )
{
if ( filter.startsWith( QStringLiteral( "<" ) ) && filter.endsWith( QStringLiteral( "Filter>" ) ) )
{
@@ -2850,7 +2849,7 @@ namespace QgsWms
{
QgsFeatureIds selectedIds;

Q_FOREACH ( const QString &id, fids )
for ( const QString &id : fids )
{
selectedIds.insert( STRING_TO_FID( id ) );
}
@@ -2927,7 +2926,7 @@ namespace QgsWms
{
QList<QgsMapLayer *> wantedLayers;

Q_FOREACH ( QgsMapLayer *layer, layers )
for ( QgsMapLayer *layer : layers )
{
if ( !layerScaleVisibility( *layer, scaleDenominator ) )
continue;
@@ -2948,7 +2947,7 @@ namespace QgsWms
{
QList<QgsMapLayer *> wantedLayers;

Q_FOREACH ( QgsMapLayer *layer, layers )
for ( QgsMapLayer *layer : layers )
{
if ( nonIdentifiableLayers.contains( layer->id() ) )
continue;
@@ -2989,7 +2988,7 @@ namespace QgsWms
// build layer tree
rootGroup.clear();
QList<QgsVectorLayerFeatureCounter *> counters;
Q_FOREACH ( QgsMapLayer *ml, layers )
for ( QgsMapLayer *ml : layers )
{
QgsLayerTreeLayer *lt = rootGroup.addLayer( ml );
lt->setCustomProperty( QStringLiteral( "showFeatureCount" ), showFeatureCount );
@@ -3018,7 +3017,7 @@ namespace QgsWms
HitTest hitTest;
getMap( contentBasedMapSettings, &hitTest );

Q_FOREACH ( QgsLayerTreeNode *node, rootGroup.children() )
for ( QgsLayerTreeNode *node : rootGroup.children() )
{
Q_ASSERT( QgsLayerTree::isLayer( node ) );
QgsLayerTreeLayer *nodeLayer = QgsLayerTree::toLayer( node );
@@ -3030,7 +3029,7 @@ namespace QgsWms
const SymbolSet &usedSymbols = hitTest[vl];
QList<int> order;
int i = 0;
Q_FOREACH ( const QgsLegendSymbolItem &legendItem, vl->renderer()->legendSymbolItems() )
for ( const QgsLegendSymbolItem &legendItem : vl->renderer()->legendSymbolItems() )
{
QString sProp = QgsSymbolLayerUtils::symbolProperties( legendItem.legacyRuleKey() );
if ( usedSymbols.contains( sProp ) )
@@ -3053,7 +3052,7 @@ namespace QgsWms
if ( ! ruleDefined )
{
QList<QgsLayerTreeNode *> rootChildren = rootGroup.children();
Q_FOREACH ( QgsLayerTreeNode *node, rootChildren )
for ( QgsLayerTreeNode *node : rootChildren )
{
if ( QgsLayerTree::isLayer( node ) )
{
@@ -3065,14 +3064,14 @@ namespace QgsWms
// rule item titles
if ( !drawLegendItemLabel )
{
Q_FOREACH ( QgsLayerTreeModelLegendNode *legendNode, legendModel->layerLegendNodes( nodeLayer ) )
for ( QgsLayerTreeModelLegendNode *legendNode : legendModel->layerLegendNodes( nodeLayer ) )
{
legendNode->setUserLabel( QStringLiteral( " " ) ); // empty string = no override, so let's use one space
}
}
else if ( !drawLegendLayerLabel )
{
Q_FOREACH ( QgsLayerTreeModelLegendNode *legendNode, legendModel->layerLegendNodes( nodeLayer ) )
for ( QgsLayerTreeModelLegendNode *legendNode : legendModel->layerLegendNodes( nodeLayer ) )
{
if ( legendNode->isEmbeddedInParent() )
legendNode->setEmbeddedInParent( false );

0 comments on commit f6d0fc0

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