mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
More Q_FOREACH to range-based for loop conversion
This commit is contained in:
parent
6958b7a251
commit
398f7f27b8
@ -614,7 +614,8 @@ void QgsLayerTreeModel::setLegendFilterByScale( double scale )
|
||||
|
||||
// this could be later done in more efficient way
|
||||
// by just updating active legend nodes, without refreshing original legend nodes
|
||||
Q_FOREACH ( QgsLayerTreeLayer *nodeLayer, mRootNode->findLayers() )
|
||||
const auto constFindLayers = mRootNode->findLayers();
|
||||
for ( QgsLayerTreeLayer *nodeLayer : constFindLayers )
|
||||
refreshLayerLegend( nodeLayer );
|
||||
}
|
||||
|
||||
@ -634,7 +635,8 @@ void QgsLayerTreeModel::setLegendFilter( const QgsMapSettings *settings, bool us
|
||||
// collect expression filters
|
||||
if ( useExpressions )
|
||||
{
|
||||
Q_FOREACH ( QgsLayerTreeLayer *nodeLayer, mRootNode->findLayers() )
|
||||
const auto constFindLayers = mRootNode->findLayers();
|
||||
for ( QgsLayerTreeLayer *nodeLayer : constFindLayers )
|
||||
{
|
||||
bool enabled;
|
||||
QString expr = QgsLayerTreeUtils::legendFilterByExpression( *nodeLayer, &enabled );
|
||||
@ -670,7 +672,8 @@ void QgsLayerTreeModel::setLegendFilter( const QgsMapSettings *settings, bool us
|
||||
|
||||
// this could be later done in more efficient way
|
||||
// by just updating active legend nodes, without refreshing original legend nodes
|
||||
Q_FOREACH ( QgsLayerTreeLayer *nodeLayer, mRootNode->findLayers() )
|
||||
const auto constFindLayers = mRootNode->findLayers();
|
||||
for ( QgsLayerTreeLayer *nodeLayer : constFindLayers )
|
||||
refreshLayerLegend( nodeLayer );
|
||||
|
||||
setAutoCollapseLegendNodes( bkAutoCollapse );
|
||||
@ -902,7 +905,8 @@ void QgsLayerTreeModel::connectToLayer( QgsLayerTreeLayer *nodeLayer )
|
||||
static int _numLayerCount( QgsLayerTreeGroup *group, const QString &layerId )
|
||||
{
|
||||
int count = 0;
|
||||
Q_FOREACH ( QgsLayerTreeNode *child, group->children() )
|
||||
const auto constChildren = group->children();
|
||||
for ( QgsLayerTreeNode *child : constChildren )
|
||||
{
|
||||
if ( QgsLayerTree::isLayer( child ) )
|
||||
{
|
||||
@ -938,7 +942,8 @@ void QgsLayerTreeModel::disconnectFromLayer( QgsLayerTreeLayer *nodeLayer )
|
||||
|
||||
void QgsLayerTreeModel::connectToLayers( QgsLayerTreeGroup *parentGroup )
|
||||
{
|
||||
Q_FOREACH ( QgsLayerTreeNode *node, parentGroup->children() )
|
||||
const auto constChildren = parentGroup->children();
|
||||
for ( QgsLayerTreeNode *node : constChildren )
|
||||
{
|
||||
if ( QgsLayerTree::isGroup( node ) )
|
||||
connectToLayers( QgsLayerTree::toGroup( node ) );
|
||||
@ -949,7 +954,8 @@ void QgsLayerTreeModel::connectToLayers( QgsLayerTreeGroup *parentGroup )
|
||||
|
||||
void QgsLayerTreeModel::disconnectFromLayers( QgsLayerTreeGroup *parentGroup )
|
||||
{
|
||||
Q_FOREACH ( QgsLayerTreeNode *node, parentGroup->children() )
|
||||
const auto constChildren = parentGroup->children();
|
||||
for ( QgsLayerTreeNode *node : constChildren )
|
||||
{
|
||||
if ( QgsLayerTree::isGroup( node ) )
|
||||
disconnectFromLayers( QgsLayerTree::toGroup( node ) );
|
||||
|
@ -142,7 +142,8 @@ void fetchCheckedLayers( const QgsLayerTreeNode *node, QList<QgsMapLayer *> &lay
|
||||
layers << nodeLayer->layer();
|
||||
}
|
||||
|
||||
Q_FOREACH ( QgsLayerTreeNode *child, node->children() )
|
||||
const auto constChildren = node->children();
|
||||
for ( QgsLayerTreeNode *child : constChildren )
|
||||
fetchCheckedLayers( child, layers );
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,8 @@ static QDomElement _writeOldLegendGroup( QDomDocument &doc, QgsLayerTreeGroup *n
|
||||
|
||||
static void _writeOldLegendGroupChildren( QDomDocument &doc, QDomElement &groupElem, QgsLayerTreeGroup *nodeGroup, bool hasCustomOrder, const QList<QgsMapLayer *> &order )
|
||||
{
|
||||
Q_FOREACH ( QgsLayerTreeNode *node, nodeGroup->children() )
|
||||
const auto constChildren = nodeGroup->children();
|
||||
for ( QgsLayerTreeNode *node : constChildren )
|
||||
{
|
||||
if ( QgsLayerTree::isGroup( node ) )
|
||||
{
|
||||
@ -294,7 +295,8 @@ bool QgsLayerTreeUtils::layersModified( const QList<QgsLayerTreeLayer *> &layerN
|
||||
void QgsLayerTreeUtils::removeInvalidLayers( QgsLayerTreeGroup *group )
|
||||
{
|
||||
QList<QgsLayerTreeNode *> nodesToRemove;
|
||||
Q_FOREACH ( QgsLayerTreeNode *node, group->children() )
|
||||
const auto constChildren = group->children();
|
||||
for ( QgsLayerTreeNode *node : constChildren )
|
||||
{
|
||||
if ( QgsLayerTree::isGroup( node ) )
|
||||
removeInvalidLayers( QgsLayerTree::toGroup( node ) );
|
||||
@ -382,7 +384,8 @@ QStringList QgsLayerTreeUtils::invisibleLayerList( QgsLayerTreeNode *node )
|
||||
|
||||
void QgsLayerTreeUtils::replaceChildrenOfEmbeddedGroups( QgsLayerTreeGroup *group )
|
||||
{
|
||||
Q_FOREACH ( QgsLayerTreeNode *child, group->children() )
|
||||
const auto constChildren = group->children();
|
||||
for ( QgsLayerTreeNode *child : constChildren )
|
||||
{
|
||||
if ( QgsLayerTree::isGroup( child ) )
|
||||
{
|
||||
@ -402,7 +405,8 @@ void QgsLayerTreeUtils::replaceChildrenOfEmbeddedGroups( QgsLayerTreeGroup *grou
|
||||
|
||||
void QgsLayerTreeUtils::updateEmbeddedGroupsProjectPath( QgsLayerTreeGroup *group, const QgsProject *project )
|
||||
{
|
||||
Q_FOREACH ( QgsLayerTreeNode *node, group->children() )
|
||||
const auto constChildren = group->children();
|
||||
for ( QgsLayerTreeNode *node : constChildren )
|
||||
{
|
||||
if ( !node->customProperty( QStringLiteral( "embedded_project" ) ).toString().isEmpty() )
|
||||
{
|
||||
@ -433,7 +437,8 @@ QString QgsLayerTreeUtils::legendFilterByExpression( const QgsLayerTreeLayer &la
|
||||
|
||||
bool QgsLayerTreeUtils::hasLegendFilterExpression( const QgsLayerTreeGroup &group )
|
||||
{
|
||||
Q_FOREACH ( QgsLayerTreeLayer *l, group.findLayers() )
|
||||
const auto constFindLayers = group.findLayers();
|
||||
for ( QgsLayerTreeLayer *l : constFindLayers )
|
||||
{
|
||||
bool exprEnabled;
|
||||
QString expr = legendFilterByExpression( *l, &exprEnabled );
|
||||
@ -453,7 +458,8 @@ QgsLayerTreeLayer *QgsLayerTreeUtils::insertLayerBelow( QgsLayerTreeGroup *group
|
||||
return nullptr;
|
||||
|
||||
int idx = 0;
|
||||
Q_FOREACH ( QgsLayerTreeNode *vl, inTree->parent()->children() )
|
||||
const auto constChildren = inTree->parent()->children();
|
||||
for ( QgsLayerTreeNode *vl : constChildren )
|
||||
{
|
||||
if ( vl->nodeType() == QgsLayerTreeNode::NodeLayer && static_cast<QgsLayerTreeLayer *>( vl )->layer() == refLayer )
|
||||
{
|
||||
|
@ -744,7 +744,8 @@ void QgsLayoutItemLegend::mapLayerStyleOverridesChanged()
|
||||
{
|
||||
mLegendModel->setLayerStyleOverrides( mMap->layerStyleOverrides() );
|
||||
|
||||
Q_FOREACH ( QgsLayerTreeLayer *nodeLayer, mLegendModel->rootGroup()->findLayers() )
|
||||
const auto constFindLayers = mLegendModel->rootGroup()->findLayers();
|
||||
for ( QgsLayerTreeLayer *nodeLayer : constFindLayers )
|
||||
mLegendModel->refreshLayerLegend( nodeLayer );
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,8 @@ bool QgsNativeMetadataBaseValidator::validate( const QgsAbstractMetadataBase *me
|
||||
|
||||
// validate contacts
|
||||
index = 0;
|
||||
Q_FOREACH ( const QgsAbstractMetadataBase::Contact &contact, metadata->contacts() )
|
||||
const auto constContacts = metadata->contacts();
|
||||
for ( const QgsAbstractMetadataBase::Contact &contact : constContacts )
|
||||
{
|
||||
if ( contact.name.isEmpty() )
|
||||
{
|
||||
@ -106,7 +107,8 @@ bool QgsNativeMetadataBaseValidator::validate( const QgsAbstractMetadataBase *me
|
||||
|
||||
// validate links
|
||||
index = 0;
|
||||
Q_FOREACH ( const QgsAbstractMetadataBase::Link &link, metadata->links() )
|
||||
const auto constLinks = metadata->links();
|
||||
for ( const QgsAbstractMetadataBase::Link &link : constLinks )
|
||||
{
|
||||
if ( link.name.isEmpty() )
|
||||
{
|
||||
@ -158,7 +160,8 @@ bool QgsNativeMetadataValidator::validate( const QgsAbstractMetadataBase *baseMe
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
Q_FOREACH ( const QgsLayerMetadata::SpatialExtent &extent, metadata->extent().spatialExtents() )
|
||||
const auto constSpatialExtents = metadata->extent().spatialExtents();
|
||||
for ( const QgsLayerMetadata::SpatialExtent &extent : constSpatialExtents )
|
||||
{
|
||||
if ( !extent.extentCrs.isValid() )
|
||||
{
|
||||
|
@ -99,7 +99,8 @@ QgsProcessingAlgorithm::Flags QgsProcessingModelAlgorithm::flags() const
|
||||
QVariantMap QgsProcessingModelAlgorithm::parametersForChildAlgorithm( const QgsProcessingModelChildAlgorithm &child, const QVariantMap &modelParameters, const QVariantMap &results, const QgsExpressionContext &expressionContext ) const
|
||||
{
|
||||
QVariantMap childParams;
|
||||
Q_FOREACH ( const QgsProcessingParameterDefinition *def, child.algorithm()->parameterDefinitions() )
|
||||
const auto constParameterDefinitions = child.algorithm()->parameterDefinitions();
|
||||
for ( const QgsProcessingParameterDefinition *def : constParameterDefinitions )
|
||||
{
|
||||
if ( !def->isDestination() )
|
||||
{
|
||||
@ -219,7 +220,8 @@ bool QgsProcessingModelAlgorithm::childOutputIsRequired( const QString &childId,
|
||||
QMap<QString, QgsProcessingModelChildParameterSources>::const_iterator childParamIt = candidateChildParams.constBegin();
|
||||
for ( ; childParamIt != candidateChildParams.constEnd(); ++childParamIt )
|
||||
{
|
||||
Q_FOREACH ( const QgsProcessingModelChildParameterSource &source, childParamIt.value() )
|
||||
const auto constValue = childParamIt.value();
|
||||
for ( const QgsProcessingModelChildParameterSource &source : constValue )
|
||||
{
|
||||
if ( source.source() == QgsProcessingModelChildParameterSource::ChildOutput
|
||||
&& source.outputChildId() == childId
|
||||
@ -869,7 +871,8 @@ QgsProcessingModelChildParameterSources QgsProcessingModelAlgorithm::availableSo
|
||||
continue;
|
||||
|
||||
bool ok = sourceDef->dataTypes().isEmpty();
|
||||
Q_FOREACH ( int type, sourceDef->dataTypes() )
|
||||
const auto constDataTypes = sourceDef->dataTypes();
|
||||
for ( int type : constDataTypes )
|
||||
{
|
||||
if ( dataTypes.contains( type ) || type == QgsProcessing::TypeMapLayer || type == QgsProcessing::TypeVector || type == QgsProcessing::TypeVectorAnyGeometry )
|
||||
{
|
||||
@ -905,7 +908,8 @@ QgsProcessingModelChildParameterSources QgsProcessingModelAlgorithm::availableSo
|
||||
if ( !alg )
|
||||
continue;
|
||||
|
||||
Q_FOREACH ( const QgsProcessingOutputDefinition *out, alg->outputDefinitions() )
|
||||
const auto constOutputDefinitions = alg->outputDefinitions();
|
||||
for ( const QgsProcessingOutputDefinition *out : constOutputDefinitions )
|
||||
{
|
||||
if ( outputTypes.contains( out->type() ) )
|
||||
{
|
||||
@ -1283,7 +1287,8 @@ bool QgsProcessingModelAlgorithm::childAlgorithmsDependOnParameter( const QStrin
|
||||
QMap<QString, QgsProcessingModelChildParameterSources>::const_iterator paramIt = childParams.constBegin();
|
||||
for ( ; paramIt != childParams.constEnd(); ++paramIt )
|
||||
{
|
||||
Q_FOREACH ( const QgsProcessingModelChildParameterSource &source, paramIt.value() )
|
||||
const auto constValue = paramIt.value();
|
||||
for ( const QgsProcessingModelChildParameterSource &source : constValue )
|
||||
{
|
||||
if ( source.source() == QgsProcessingModelChildParameterSource::ModelParameter
|
||||
&& source.parameterName() == name )
|
||||
@ -1336,7 +1341,8 @@ void QgsProcessingModelAlgorithm::dependentChildAlgorithmsRecursive( const QStri
|
||||
QMap<QString, QgsProcessingModelChildParameterSources>::const_iterator paramIt = childParams.constBegin();
|
||||
for ( ; paramIt != childParams.constEnd(); ++paramIt )
|
||||
{
|
||||
Q_FOREACH ( const QgsProcessingModelChildParameterSource &source, paramIt.value() )
|
||||
const auto constValue = paramIt.value();
|
||||
for ( const QgsProcessingModelChildParameterSource &source : constValue )
|
||||
{
|
||||
if ( source.source() == QgsProcessingModelChildParameterSource::ChildOutput
|
||||
&& source.outputChildId() == childId )
|
||||
@ -1372,7 +1378,8 @@ void QgsProcessingModelAlgorithm::dependsOnChildAlgorithmsRecursive( const QStri
|
||||
const QgsProcessingModelChildAlgorithm &alg = mChildAlgorithms.value( childId );
|
||||
|
||||
// add direct dependencies
|
||||
Q_FOREACH ( const QString &c, alg.dependencies() )
|
||||
const auto constDependencies = alg.dependencies();
|
||||
for ( const QString &c : constDependencies )
|
||||
{
|
||||
if ( !depends.contains( c ) )
|
||||
{
|
||||
@ -1386,7 +1393,8 @@ void QgsProcessingModelAlgorithm::dependsOnChildAlgorithmsRecursive( const QStri
|
||||
QMap<QString, QgsProcessingModelChildParameterSources>::const_iterator paramIt = childParams.constBegin();
|
||||
for ( ; paramIt != childParams.constEnd(); ++paramIt )
|
||||
{
|
||||
Q_FOREACH ( const QgsProcessingModelChildParameterSource &source, paramIt.value() )
|
||||
const auto constValue = paramIt.value();
|
||||
for ( const QgsProcessingModelChildParameterSource &source : constValue )
|
||||
{
|
||||
if ( source.source() == QgsProcessingModelChildParameterSource::ChildOutput && !depends.contains( source.outputChildId() ) )
|
||||
{
|
||||
|
@ -98,7 +98,8 @@ QVariant QgsProcessingModelChildAlgorithm::toVariant() const
|
||||
for ( ; paramIt != mParams.constEnd(); ++paramIt )
|
||||
{
|
||||
QVariantList sources;
|
||||
Q_FOREACH ( const QgsProcessingModelChildParameterSource &source, paramIt.value() )
|
||||
const auto constValue = paramIt.value();
|
||||
for ( const QgsProcessingModelChildParameterSource &source : constValue )
|
||||
{
|
||||
sources << source.toVariant();
|
||||
}
|
||||
@ -137,7 +138,8 @@ bool QgsProcessingModelChildAlgorithm::loadVariant( const QVariant &child )
|
||||
for ( ; paramIt != paramMap.constEnd(); ++paramIt )
|
||||
{
|
||||
QgsProcessingModelChildParameterSources sources;
|
||||
Q_FOREACH ( const QVariant &sourceVar, paramIt->toList() )
|
||||
const auto constToList = paramIt->toList();
|
||||
for ( const QVariant &sourceVar : constToList )
|
||||
{
|
||||
QgsProcessingModelChildParameterSource param;
|
||||
if ( !param.loadVariant( sourceVar.toMap() ) )
|
||||
|
@ -287,7 +287,8 @@ QList<int> QgsProcessingParameters::parameterAsEnums( const QgsProcessingParamet
|
||||
resultList << val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
|
||||
else if ( val.type() == QVariant::List )
|
||||
{
|
||||
Q_FOREACH ( const QVariant &var, val.toList() )
|
||||
const auto constToList = val.toList();
|
||||
for ( const QVariant &var : constToList )
|
||||
resultList << var;
|
||||
}
|
||||
else if ( val.type() == QVariant::String )
|
||||
@ -307,7 +308,8 @@ QList<int> QgsProcessingParameters::parameterAsEnums( const QgsProcessingParamet
|
||||
// check default
|
||||
if ( definition->defaultValue().type() == QVariant::List )
|
||||
{
|
||||
Q_FOREACH ( const QVariant &var, definition->defaultValue().toList() )
|
||||
const auto constToList = definition->defaultValue().toList();
|
||||
for ( const QVariant &var : constToList )
|
||||
resultList << var;
|
||||
}
|
||||
else if ( definition->defaultValue().type() == QVariant::String )
|
||||
@ -1313,14 +1315,16 @@ QList<QgsMapLayer *> QgsProcessingParameters::parameterAsLayerList( const QgsPro
|
||||
{
|
||||
if ( var.type() == QVariant::List )
|
||||
{
|
||||
Q_FOREACH ( const QVariant &listVar, var.toList() )
|
||||
const auto constToList = var.toList();
|
||||
for ( const QVariant &listVar : constToList )
|
||||
{
|
||||
processVariant( listVar );
|
||||
}
|
||||
}
|
||||
else if ( var.type() == QVariant::StringList )
|
||||
{
|
||||
Q_FOREACH ( const QString &s, var.toStringList() )
|
||||
const auto constToStringList = var.toStringList();
|
||||
for ( const QString &s : constToStringList )
|
||||
{
|
||||
processVariant( s );
|
||||
}
|
||||
@ -1360,7 +1364,8 @@ QList<QgsMapLayer *> QgsProcessingParameters::parameterAsLayerList( const QgsPro
|
||||
}
|
||||
else if ( definition->defaultValue().type() == QVariant::List )
|
||||
{
|
||||
Q_FOREACH ( const QVariant &var, definition->defaultValue().toList() )
|
||||
const auto constToList = definition->defaultValue().toList();
|
||||
for ( const QVariant &var : constToList )
|
||||
{
|
||||
if ( QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
|
||||
{
|
||||
@ -1398,7 +1403,8 @@ QList<double> QgsProcessingParameters::parameterAsRange( const QgsProcessingPara
|
||||
resultStringList << val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
|
||||
else if ( val.type() == QVariant::List )
|
||||
{
|
||||
Q_FOREACH ( const QVariant &var, val.toList() )
|
||||
const auto constToList = val.toList();
|
||||
for ( const QVariant &var : constToList )
|
||||
resultStringList << var.toString();
|
||||
}
|
||||
else
|
||||
@ -1410,7 +1416,8 @@ QList<double> QgsProcessingParameters::parameterAsRange( const QgsProcessingPara
|
||||
// check default
|
||||
if ( definition->defaultValue().type() == QVariant::List )
|
||||
{
|
||||
Q_FOREACH ( const QVariant &var, definition->defaultValue().toList() )
|
||||
const auto constToList = definition->defaultValue().toList();
|
||||
for ( const QVariant &var : constToList )
|
||||
resultStringList << var.toString();
|
||||
}
|
||||
else
|
||||
@ -1450,7 +1457,8 @@ QStringList QgsProcessingParameters::parameterAsFields( const QgsProcessingParam
|
||||
resultStringList << val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
|
||||
else if ( val.type() == QVariant::List )
|
||||
{
|
||||
Q_FOREACH ( const QVariant &var, val.toList() )
|
||||
const auto constToList = val.toList();
|
||||
for ( const QVariant &var : constToList )
|
||||
resultStringList << var.toString();
|
||||
}
|
||||
else
|
||||
@ -1465,7 +1473,8 @@ QStringList QgsProcessingParameters::parameterAsFields( const QgsProcessingParam
|
||||
{
|
||||
if ( definition->defaultValue().type() == QVariant::List )
|
||||
{
|
||||
Q_FOREACH ( const QVariant &var, definition->defaultValue().toList() )
|
||||
const auto constToList = definition->defaultValue().toList();
|
||||
for ( const QVariant &var : constToList )
|
||||
resultStringList << var.toString();
|
||||
}
|
||||
else
|
||||
@ -2353,7 +2362,8 @@ QString QgsProcessingParameterMatrix::valueAsPythonString( const QVariant &value
|
||||
if ( v.type() == QVariant::List )
|
||||
{
|
||||
QStringList parts2;
|
||||
Q_FOREACH ( const QVariant &v2, v.toList() )
|
||||
const auto constToList = v.toList();
|
||||
for ( const QVariant &v2 : constToList )
|
||||
{
|
||||
if ( v2.isNull() || !v2.isValid() )
|
||||
parts2 << QStringLiteral( "None" );
|
||||
@ -2503,7 +2513,8 @@ bool QgsProcessingParameterMultipleLayers::checkValueIsAcceptable( const QVarian
|
||||
if ( !context )
|
||||
return true;
|
||||
|
||||
Q_FOREACH ( const QVariant &v, input.toList() )
|
||||
const auto constToList = input.toList();
|
||||
for ( const QVariant &v : constToList )
|
||||
{
|
||||
if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
|
||||
continue;
|
||||
@ -2524,7 +2535,8 @@ bool QgsProcessingParameterMultipleLayers::checkValueIsAcceptable( const QVarian
|
||||
if ( !context )
|
||||
return true;
|
||||
|
||||
Q_FOREACH ( const QString &v, input.toStringList() )
|
||||
const auto constToStringList = input.toStringList();
|
||||
for ( const QString &v : constToStringList )
|
||||
{
|
||||
if ( !QgsProcessingUtils::mapLayerFromString( v, *context ) )
|
||||
return false;
|
||||
@ -2582,7 +2594,8 @@ QString QgsProcessingParameterMultipleLayers::asScriptCode() const
|
||||
if ( mDefault.type() == QVariant::List )
|
||||
{
|
||||
QStringList parts;
|
||||
Q_FOREACH ( const QVariant &var, mDefault.toList() )
|
||||
const auto constToList = mDefault.toList();
|
||||
for ( const QVariant &var : constToList )
|
||||
{
|
||||
parts << var.toString();
|
||||
}
|
||||
@ -3097,7 +3110,8 @@ QString QgsProcessingParameterEnum::valueAsPythonString( const QVariant &value,
|
||||
if ( value.type() == QVariant::List )
|
||||
{
|
||||
QStringList parts;
|
||||
Q_FOREACH ( const QVariant &val, value.toList() )
|
||||
const auto constToList = value.toList();
|
||||
for ( const QVariant &val : constToList )
|
||||
{
|
||||
parts << QString::number( static_cast< int >( val.toDouble() ) );
|
||||
}
|
||||
@ -3723,7 +3737,8 @@ QString QgsProcessingParameterField::valueAsPythonString( const QVariant &value,
|
||||
if ( value.type() == QVariant::List )
|
||||
{
|
||||
QStringList parts;
|
||||
Q_FOREACH ( const QVariant &val, value.toList() )
|
||||
const auto constToList = value.toList();
|
||||
for ( const QVariant &val : constToList )
|
||||
{
|
||||
parts << QgsProcessingUtils::stringToPythonLiteral( val.toString() );
|
||||
}
|
||||
@ -3732,7 +3747,8 @@ QString QgsProcessingParameterField::valueAsPythonString( const QVariant &value,
|
||||
else if ( value.type() == QVariant::StringList )
|
||||
{
|
||||
QStringList parts;
|
||||
Q_FOREACH ( QString s, value.toStringList() )
|
||||
const auto constToStringList = value.toStringList();
|
||||
for ( QString s : constToStringList )
|
||||
{
|
||||
parts << QgsProcessingUtils::stringToPythonLiteral( s );
|
||||
}
|
||||
|
@ -138,7 +138,8 @@ const QgsProcessingAlgorithm *QgsProcessingRegistry::algorithmById( const QStrin
|
||||
QMap<QString, QgsProcessingProvider *>::const_iterator it = mProviders.constBegin();
|
||||
for ( ; it != mProviders.constEnd(); ++it )
|
||||
{
|
||||
Q_FOREACH ( const QgsProcessingAlgorithm *alg, it.value()->algorithms() )
|
||||
const auto constAlgorithms = it.value()->algorithms();
|
||||
for ( const QgsProcessingAlgorithm *alg : constAlgorithms )
|
||||
if ( alg->id() == id )
|
||||
return alg;
|
||||
}
|
||||
|
@ -333,7 +333,8 @@ void QgsBlockingNetworkRequest::replyFinished()
|
||||
QNetworkCacheMetaData cmd = nam->cache()->metaData( mReply->request().url() );
|
||||
|
||||
QNetworkCacheMetaData::RawHeaderList hl;
|
||||
Q_FOREACH ( const QNetworkCacheMetaData::RawHeader &h, cmd.rawHeaders() )
|
||||
const auto constRawHeaders = cmd.rawHeaders();
|
||||
for ( const QNetworkCacheMetaData::RawHeader &h : constRawHeaders )
|
||||
{
|
||||
if ( h.first != "Cache-Control" )
|
||||
hl.append( h );
|
||||
|
@ -147,7 +147,8 @@ void QgsBrowserModel::addRootItems()
|
||||
}
|
||||
|
||||
// add as sorted groups by QgsDataProvider::DataCapability enum
|
||||
Q_FOREACH ( int key, providerMap.uniqueKeys() )
|
||||
const auto constUniqueKeys = providerMap.uniqueKeys();
|
||||
for ( int key : constUniqueKeys )
|
||||
{
|
||||
QList<QgsDataItem *> providerGroup = providerMap.values( key );
|
||||
if ( providerGroup.size() > 1 )
|
||||
|
@ -588,8 +588,9 @@ void QgsDataSourceUri::setEncodedUri( const QByteArray &uri )
|
||||
mParams.clear();
|
||||
QUrl url;
|
||||
url.setEncodedQuery( uri );
|
||||
QPair<QString, QString> item;
|
||||
Q_FOREACH ( item, url.queryItems() )
|
||||
|
||||
const auto constQueryItems = url.queryItems();
|
||||
for ( const QPair<QString, QString> &item : constQueryItems )
|
||||
{
|
||||
mParams.insertMulti( item.first, item.second );
|
||||
}
|
||||
|
@ -474,7 +474,8 @@ QSet<QString> QgsDiagramRenderer::referencedFields( const QgsExpressionContext &
|
||||
Q_FOREACH ( const QString &att, diagramAttributes() )
|
||||
{
|
||||
QgsExpression *expression = mDiagram->getExpression( att, context );
|
||||
Q_FOREACH ( const QString &field, expression->referencedColumns() )
|
||||
const auto constReferencedColumns = expression->referencedColumns();
|
||||
for ( const QString &field : constReferencedColumns )
|
||||
{
|
||||
referenced << field;
|
||||
}
|
||||
@ -632,7 +633,8 @@ QSet<QString> QgsLinearlyInterpolatedDiagramRenderer::referencedFields( const Qg
|
||||
if ( mInterpolationSettings.classificationAttributeIsExpression )
|
||||
{
|
||||
QgsExpression *expression = mDiagram->getExpression( mInterpolationSettings.classificationAttributeExpression, context );
|
||||
Q_FOREACH ( const QString &field, expression->referencedColumns() )
|
||||
const auto constReferencedColumns = expression->referencedColumns();
|
||||
for ( const QString &field : constReferencedColumns )
|
||||
{
|
||||
referenced << field;
|
||||
}
|
||||
@ -786,7 +788,8 @@ QList< QgsLayerTreeModelLegendNode * > QgsLinearlyInterpolatedDiagramRenderer::l
|
||||
else
|
||||
{
|
||||
// manual classes need to get size scaled because the QgsSizeScaleTransformer is not used in diagrams :-(
|
||||
Q_FOREACH ( const QgsDataDefinedSizeLegend::SizeClass &sc, ddSizeLegend.classes() )
|
||||
const auto constClasses = ddSizeLegend.classes();
|
||||
for ( const QgsDataDefinedSizeLegend::SizeClass &sc : constClasses )
|
||||
{
|
||||
double size = mDiagram->legendSize( sc.size, mSettings, mInterpolationSettings );
|
||||
sizeClasses << QgsDataDefinedSizeLegend::SizeClass( size, sc.label );
|
||||
@ -794,7 +797,8 @@ QList< QgsLayerTreeModelLegendNode * > QgsLinearlyInterpolatedDiagramRenderer::l
|
||||
}
|
||||
ddSizeLegend.setClasses( sizeClasses );
|
||||
|
||||
Q_FOREACH ( const QgsLegendSymbolItem &si, ddSizeLegend.legendSymbolList() )
|
||||
const auto constLegendSymbolList = ddSizeLegend.legendSymbolList();
|
||||
for ( const QgsLegendSymbolItem &si : constLegendSymbolList )
|
||||
{
|
||||
if ( si.dataDefinedSizeLegendSettings() )
|
||||
nodes << new QgsDataDefinedSizeLegendNode( nodeLayer, *si.dataDefinedSizeLegendSettings() );
|
||||
|
@ -319,7 +319,8 @@ QDataStream &operator>>( QDataStream &in, QgsFeature &feature )
|
||||
uint qHash( const QgsFeature &key, uint seed )
|
||||
{
|
||||
uint hash = seed;
|
||||
Q_FOREACH ( const QVariant &attr, key.attributes() )
|
||||
const auto constAttributes = key.attributes();
|
||||
for ( const QVariant &attr : constAttributes )
|
||||
{
|
||||
hash ^= qHash( attr.toString() );
|
||||
}
|
||||
|
@ -81,7 +81,8 @@ QgsInterval QgsInterval::fromString( const QString &string )
|
||||
for ( ; it != map.constEnd(); ++it )
|
||||
{
|
||||
int duration = it.key();
|
||||
Q_FOREACH ( const QString &name, it.value() )
|
||||
const auto constValue = it.value();
|
||||
for ( const QString &name : constValue )
|
||||
{
|
||||
if ( match.contains( name, Qt::CaseInsensitive ) )
|
||||
{
|
||||
|
@ -340,7 +340,8 @@ QVariantList QgsJsonUtils::parseArray( const QString &json, QVariant::Type type
|
||||
QgsLogger::warning( QStringLiteral( "Cannot parse json (%1) as array: %2" ).arg( error.errorString(), json ) );
|
||||
return result;
|
||||
}
|
||||
Q_FOREACH ( const QJsonValue &cur, jsonDoc.array() )
|
||||
const auto constArray = jsonDoc.array();
|
||||
for ( const QJsonValue &cur : constArray )
|
||||
{
|
||||
QVariant curVariant = cur.toVariant();
|
||||
if ( curVariant.convert( type ) )
|
||||
|
@ -236,7 +236,8 @@ QList<QgsLegendRenderer::Atom> QgsLegendRenderer::createAtomList( QgsLayerTreeGr
|
||||
|
||||
if ( !parentGroup ) return atoms;
|
||||
|
||||
Q_FOREACH ( QgsLayerTreeNode *node, parentGroup->children() )
|
||||
const auto constChildren = parentGroup->children();
|
||||
for ( QgsLayerTreeNode *node : constChildren )
|
||||
{
|
||||
if ( QgsLayerTree::isGroup( node ) )
|
||||
{
|
||||
|
@ -56,7 +56,8 @@ void QgsMapHitTest::run()
|
||||
QgsRenderContext context = QgsRenderContext::fromMapSettings( mSettings );
|
||||
context.setPainter( &painter ); // we are not going to draw anything, but we still need a working painter
|
||||
|
||||
Q_FOREACH ( QgsMapLayer *layer, mSettings.layers() )
|
||||
const auto constLayers = mSettings.layers();
|
||||
for ( QgsMapLayer *layer : constLayers )
|
||||
{
|
||||
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
|
||||
if ( !vl || !vl->renderer() )
|
||||
|
@ -110,7 +110,8 @@ void QgsMapLayer::clone( QgsMapLayer *layer ) const
|
||||
{
|
||||
layer->setBlendMode( blendMode() );
|
||||
|
||||
Q_FOREACH ( const QString &s, styleManager()->styles() )
|
||||
const auto constStyles = styleManager()->styles();
|
||||
for ( const QString &s : constStyles )
|
||||
{
|
||||
layer->styleManager()->addStyle( s, styleManager()->style( s ) );
|
||||
}
|
||||
@ -1830,7 +1831,8 @@ static QList<const QgsMapLayer *> _depOutEdges( const QgsMapLayer *vl, const Qgs
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_FOREACH ( const QgsMapLayerDependency &dep, vl->dependencies() )
|
||||
const auto constDependencies = vl->dependencies();
|
||||
for ( const QgsMapLayerDependency &dep : constDependencies )
|
||||
{
|
||||
if ( const QgsMapLayer *l = QgsProject::instance()->mapLayer( dep.layerId() ) )
|
||||
lst << l;
|
||||
|
@ -216,7 +216,8 @@ QList<QgsLayerTreeModelLegendNode *> QgsDefaultVectorLayerLegend::createLayerTre
|
||||
nodes.append( new QgsSimpleLegendNode( nodeLayer, r->legendClassificationAttribute() ) );
|
||||
}
|
||||
|
||||
Q_FOREACH ( const QgsLegendSymbolItem &i, r->legendSymbolItems() )
|
||||
const auto constLegendSymbolItems = r->legendSymbolItems();
|
||||
for ( const QgsLegendSymbolItem &i : constLegendSymbolItems )
|
||||
{
|
||||
if ( i.dataDefinedSizeLegendSettings() )
|
||||
nodes << new QgsDataDefinedSizeLegendNode( nodeLayer, *i.dataDefinedSizeLegendSettings() );
|
||||
|
@ -419,7 +419,8 @@ void QgsMapRendererJob::cleanupJobs( LayerRenderJobs &jobs )
|
||||
|
||||
if ( job.renderer )
|
||||
{
|
||||
Q_FOREACH ( const QString &message, job.renderer->errors() )
|
||||
const auto constErrors = job.renderer->errors();
|
||||
for ( const QString &message : constErrors )
|
||||
mErrors.append( Error( job.renderer->layerId(), message ) );
|
||||
|
||||
delete job.renderer;
|
||||
|
@ -28,7 +28,8 @@ const QStringList QgsMapSettingsUtils::containsAdvancedEffects( const QgsMapSett
|
||||
QSet< QString > layers;
|
||||
|
||||
QgsTextFormat layerFormat;
|
||||
Q_FOREACH ( QgsMapLayer *layer, mapSettings.layers() )
|
||||
const auto constLayers = mapSettings.layers();
|
||||
for ( QgsMapLayer *layer : constLayers )
|
||||
{
|
||||
if ( layer )
|
||||
{
|
||||
|
@ -78,7 +78,8 @@ static QString _groupId( QgsLayerTreeNode *node )
|
||||
|
||||
void QgsMapThemeCollection::createThemeFromCurrentState( QgsLayerTreeGroup *parent, QgsLayerTreeModel *model, QgsMapThemeCollection::MapThemeRecord &rec )
|
||||
{
|
||||
Q_FOREACH ( QgsLayerTreeNode *node, parent->children() )
|
||||
const auto constChildren = parent->children();
|
||||
for ( QgsLayerTreeNode *node : constChildren )
|
||||
{
|
||||
if ( QgsLayerTree::isGroup( node ) )
|
||||
{
|
||||
@ -170,7 +171,8 @@ void QgsMapThemeCollection::applyThemeToLayer( QgsLayerTreeLayer *nodeLayer, Qgs
|
||||
|
||||
void QgsMapThemeCollection::applyThemeToGroup( QgsLayerTreeGroup *parent, QgsLayerTreeModel *model, const QgsMapThemeCollection::MapThemeRecord &rec )
|
||||
{
|
||||
Q_FOREACH ( QgsLayerTreeNode *node, parent->children() )
|
||||
const auto constChildren = parent->children();
|
||||
for ( QgsLayerTreeNode *node : constChildren )
|
||||
{
|
||||
if ( QgsLayerTree::isGroup( node ) )
|
||||
{
|
||||
@ -344,7 +346,8 @@ void QgsMapThemeCollection::applyMapThemeCheckedLegendNodesToLayer( const MapThe
|
||||
|
||||
bool someNodesUnchecked = layerRec.usingLegendItems;
|
||||
|
||||
Q_FOREACH ( const QgsLegendSymbolItem &item, vlayer->renderer()->legendSymbolItems() )
|
||||
const auto constLegendSymbolItems = vlayer->renderer()->legendSymbolItems();
|
||||
for ( const QgsLegendSymbolItem &item : constLegendSymbolItems )
|
||||
{
|
||||
bool checked = renderer->legendSymbolItemChecked( item.ruleKey() );
|
||||
bool shouldBeChecked = someNodesUnchecked ? layerRec.checkedLegendItems.contains( item.ruleKey() ) : true;
|
||||
|
@ -58,7 +58,8 @@ class QgsNetworkProxyFactory : public QNetworkProxyFactory
|
||||
QgsNetworkAccessManager *nam = QgsNetworkAccessManager::instance();
|
||||
|
||||
// iterate proxies factories and take first non empty list
|
||||
Q_FOREACH ( QNetworkProxyFactory *f, nam->proxyFactories() )
|
||||
const auto constProxyFactories = nam->proxyFactories();
|
||||
for ( QNetworkProxyFactory *f : constProxyFactories )
|
||||
{
|
||||
QList<QNetworkProxy> systemproxies = f->systemProxyForQuery( query );
|
||||
if ( !systemproxies.isEmpty() )
|
||||
@ -75,7 +76,8 @@ class QgsNetworkProxyFactory : public QNetworkProxyFactory
|
||||
|
||||
QString url = query.url().toString();
|
||||
|
||||
Q_FOREACH ( const QString &exclude, nam->excludeList() )
|
||||
const auto constExcludeList = nam->excludeList();
|
||||
for ( const QString &exclude : constExcludeList )
|
||||
{
|
||||
if ( !exclude.trimmed().isEmpty() && url.startsWith( exclude ) )
|
||||
{
|
||||
|
@ -38,7 +38,8 @@ QgsNetworkReplyParser::QgsNetworkReplyParser( QNetworkReply *reply )
|
||||
{
|
||||
// reply is not multipart, copy body and headers
|
||||
QMap<QByteArray, QByteArray> headers;
|
||||
Q_FOREACH ( QByteArray h, mReply->rawHeaderList() )
|
||||
const auto constRawHeaderList = mReply->rawHeaderList();
|
||||
for ( QByteArray h : constRawHeaderList )
|
||||
{
|
||||
headers.insert( h, mReply->rawHeader( h ) );
|
||||
}
|
||||
|
@ -128,7 +128,8 @@ void QgsObjectCustomProperties::writeXml( QDomNode &parentNode, QDomDocument &do
|
||||
}
|
||||
else if ( it.value().canConvert<QStringList>() )
|
||||
{
|
||||
Q_FOREACH ( const QString &value, it.value().toStringList() )
|
||||
const auto constToStringList = it.value().toStringList();
|
||||
for ( const QString &value : constToStringList )
|
||||
{
|
||||
QDomElement itemElement = doc.createElement( QStringLiteral( "value" ) );
|
||||
itemElement.appendChild( doc.createTextNode( value ) );
|
||||
|
@ -2112,7 +2112,8 @@ QDomElement QgsOgcUtilsExprToFilter::expressionInOperatorToOgcFilter( const QgsE
|
||||
QDomElement orElem = mDoc.createElement( mFilterPrefix + ":Or" );
|
||||
QDomElement leftNode = expressionNodeToOgcFilter( node->node(), expression, context );
|
||||
|
||||
Q_FOREACH ( QgsExpressionNode *n, node->list()->list() )
|
||||
const auto constList = node->list()->list();
|
||||
for ( QgsExpressionNode *n : constList )
|
||||
{
|
||||
QDomElement listNode = expressionNodeToOgcFilter( n, expression, context );
|
||||
if ( !mErrorMessage.isEmpty() )
|
||||
@ -2317,7 +2318,8 @@ QDomElement QgsOgcUtilsExprToFilter::expressionFunctionToOgcFilter( const QgsExp
|
||||
// this is somehow wrong - we are just hoping that the other side supports the same functions as we do...
|
||||
QDomElement funcElem = mDoc.createElement( mFilterPrefix + ":Function" );
|
||||
funcElem.setAttribute( QStringLiteral( "name" ), fd->name() );
|
||||
Q_FOREACH ( QgsExpressionNode *n, node->args()->list() )
|
||||
const auto constList = node->args()->list();
|
||||
for ( QgsExpressionNode *n : constList )
|
||||
{
|
||||
QDomElement childElem = expressionNodeToOgcFilter( n, expression, context );
|
||||
if ( !mErrorMessage.isEmpty() )
|
||||
@ -2563,7 +2565,8 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement:
|
||||
QDomElement orElem = mDoc.createElement( mFilterPrefix + ":Or" );
|
||||
QDomElement leftNode = toOgcFilter( node->node() );
|
||||
|
||||
Q_FOREACH ( QgsSQLStatement::Node *n, node->list()->list() )
|
||||
const auto constList = node->list()->list();
|
||||
for ( QgsSQLStatement::Node *n : constList )
|
||||
{
|
||||
QDomElement listNode = toOgcFilter( n );
|
||||
if ( !mErrorMessage.isEmpty() )
|
||||
@ -2975,7 +2978,8 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement:
|
||||
// Other function
|
||||
QDomElement funcElem = mDoc.createElement( mFilterPrefix + ":Function" );
|
||||
funcElem.setAttribute( QStringLiteral( "name" ), node->name() );
|
||||
Q_FOREACH ( QgsSQLStatement::Node *n, node->args()->list() )
|
||||
const auto constList = node->args()->list();
|
||||
for ( QgsSQLStatement::Node *n : constList )
|
||||
{
|
||||
QDomElement childElem = toOgcFilter( n );
|
||||
if ( !mErrorMessage.isEmpty() )
|
||||
@ -2996,7 +3000,8 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement:
|
||||
}
|
||||
|
||||
QList<QDomElement> listElem;
|
||||
Q_FOREACH ( const QString &columnName, node->usingColumns() )
|
||||
const auto constUsingColumns = node->usingColumns();
|
||||
for ( const QString &columnName : constUsingColumns )
|
||||
{
|
||||
QDomElement eqElem = mDoc.createElement( mFilterPrefix + ":PropertyIsEqualTo" );
|
||||
QDomElement propElem1 = mDoc.createElement( mFilterPrefix + ":" + mPropertyName );
|
||||
@ -3050,11 +3055,13 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement:
|
||||
}
|
||||
|
||||
// Register all table name aliases
|
||||
Q_FOREACH ( QgsSQLStatement::NodeTableDef *table, node->tables() )
|
||||
const auto constTables = node->tables();
|
||||
for ( QgsSQLStatement::NodeTableDef *table : constTables )
|
||||
{
|
||||
visit( table );
|
||||
}
|
||||
Q_FOREACH ( QgsSQLStatement::NodeJoin *join, node->joins() )
|
||||
const auto constJoins = node->joins();
|
||||
for ( QgsSQLStatement::NodeJoin *join : constJoins )
|
||||
{
|
||||
visit( join->tableDef() );
|
||||
}
|
||||
@ -3062,7 +3069,7 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement:
|
||||
// Process JOIN conditions
|
||||
QList< QgsSQLStatement::NodeTableDef *> nodeTables = node->tables();
|
||||
QString leftTable = nodeTables.at( nodeTables.length() - 1 )->name();
|
||||
Q_FOREACH ( QgsSQLStatement::NodeJoin *join, node->joins() )
|
||||
for ( QgsSQLStatement::NodeJoin *join : constJoins )
|
||||
{
|
||||
QDomElement joinElem = toOgcFilter( join, leftTable );
|
||||
if ( !mErrorMessage.isEmpty() )
|
||||
|
@ -1435,7 +1435,8 @@ bool QgsProject::readProjectFile( const QString &filename )
|
||||
void QgsProject::loadEmbeddedNodes( QgsLayerTreeGroup *group )
|
||||
{
|
||||
|
||||
Q_FOREACH ( QgsLayerTreeNode *child, group->children() )
|
||||
const auto constChildren = group->children();
|
||||
for ( QgsLayerTreeNode *child : constChildren )
|
||||
{
|
||||
if ( QgsLayerTree::isGroup( child ) )
|
||||
{
|
||||
@ -1449,7 +1450,8 @@ void QgsProject::loadEmbeddedNodes( QgsLayerTreeGroup *group )
|
||||
if ( newGroup )
|
||||
{
|
||||
QList<QgsLayerTreeNode *> clonedChildren;
|
||||
Q_FOREACH ( QgsLayerTreeNode *newGroupChild, newGroup->children() )
|
||||
const auto constChildren = newGroup->children();
|
||||
for ( QgsLayerTreeNode *newGroupChild : constChildren )
|
||||
clonedChildren << newGroupChild->clone();
|
||||
delete newGroup;
|
||||
|
||||
@ -1865,7 +1867,8 @@ bool QgsProject::writeProjectFile( const QString &filename )
|
||||
qgisNode.appendChild( projectLayersNode );
|
||||
|
||||
QDomElement layerOrderNode = doc->createElement( QStringLiteral( "layerorder" ) );
|
||||
Q_FOREACH ( QgsMapLayer *layer, mRootGroup->customLayerOrder() )
|
||||
const auto constCustomLayerOrder = mRootGroup->customLayerOrder();
|
||||
for ( QgsMapLayer *layer : constCustomLayerOrder )
|
||||
{
|
||||
QDomElement mapLayerElem = doc->createElement( QStringLiteral( "layer" ) );
|
||||
mapLayerElem.setAttribute( QStringLiteral( "id" ), layer->id() );
|
||||
@ -2393,7 +2396,8 @@ QgsLayerTreeGroup *QgsProject::createEmbeddedGroup( const QString &groupName, co
|
||||
mLayerTreeRegistryBridge->setEnabled( true );
|
||||
|
||||
// consider the layers might be identify disabled in its project
|
||||
Q_FOREACH ( const QString &layerId, newGroup->findLayerIds() )
|
||||
const auto constFindLayerIds = newGroup->findLayerIds();
|
||||
for ( const QString &layerId : constFindLayerIds )
|
||||
{
|
||||
QgsLayerTreeLayer *layer = newGroup->findLayer( layerId );
|
||||
if ( layer )
|
||||
@ -2408,7 +2412,8 @@ QgsLayerTreeGroup *QgsProject::createEmbeddedGroup( const QString &groupName, co
|
||||
|
||||
void QgsProject::initializeEmbeddedSubtree( const QString &projectFilePath, QgsLayerTreeGroup *group )
|
||||
{
|
||||
Q_FOREACH ( QgsLayerTreeNode *child, group->children() )
|
||||
const auto constChildren = group->children();
|
||||
for ( QgsLayerTreeNode *child : constChildren )
|
||||
{
|
||||
// all nodes in the subtree will have "embedded" custom property set
|
||||
child->setCustomProperty( QStringLiteral( "embedded" ), 1 );
|
||||
|
@ -125,7 +125,8 @@ void QgsProviderRegistry::init()
|
||||
fileRegexp.setPattern( filePattern );
|
||||
}
|
||||
|
||||
Q_FOREACH ( const QFileInfo &fi, mLibraryDirectory.entryInfoList() )
|
||||
const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
|
||||
for ( const QFileInfo &fi : constEntryInfoList )
|
||||
{
|
||||
if ( !fileRegexp.isEmpty() )
|
||||
{
|
||||
|
@ -126,7 +126,8 @@ QList<QgsRelation> QgsRelationManager::referencingRelations( const QgsVectorLaye
|
||||
if ( fieldIdx != -2 )
|
||||
{
|
||||
bool containsField = false;
|
||||
Q_FOREACH ( const QgsRelation::FieldPair &fp, rel.fieldPairs() )
|
||||
const auto constFieldPairs = rel.fieldPairs();
|
||||
for ( const QgsRelation::FieldPair &fp : constFieldPairs )
|
||||
{
|
||||
if ( fieldIdx == layer->fields().lookupField( fp.referencingField() ) )
|
||||
{
|
||||
|
@ -148,7 +148,8 @@ void QgsSnappingConfig::reset()
|
||||
|
||||
// set advanced config
|
||||
mIndividualLayerSettings = QHash<QgsVectorLayer *, IndividualLayerSettings>();
|
||||
Q_FOREACH ( QgsMapLayer *ml, mProject->mapLayers() )
|
||||
const auto constMapLayers = mProject->mapLayers();
|
||||
for ( QgsMapLayer *ml : constMapLayers )
|
||||
{
|
||||
QgsVectorLayer *vl = dynamic_cast<QgsVectorLayer *>( ml );
|
||||
if ( vl )
|
||||
|
@ -124,7 +124,8 @@ static QgsPointLocator::Match _findClosestSegmentIntersection( const QgsPointXY
|
||||
QList<QgsPointXY> newPoints;
|
||||
if ( g.wkbType() == QgsWkbTypes::LineString )
|
||||
{
|
||||
Q_FOREACH ( const QgsPointXY &p, g.asPolyline() )
|
||||
const auto constAsPolyline = g.asPolyline();
|
||||
for ( const QgsPointXY &p : constAsPolyline )
|
||||
{
|
||||
if ( !endpoints.contains( p ) )
|
||||
newPoints << p;
|
||||
@ -132,7 +133,8 @@ static QgsPointLocator::Match _findClosestSegmentIntersection( const QgsPointXY
|
||||
}
|
||||
if ( g.wkbType() == QgsWkbTypes::MultiLineString )
|
||||
{
|
||||
Q_FOREACH ( const QgsPolylineXY &pl, g.asMultiPolyline() )
|
||||
const auto constAsMultiPolyline = g.asMultiPolyline();
|
||||
for ( const QgsPolylineXY &pl : constAsMultiPolyline )
|
||||
{
|
||||
const auto constPl = pl;
|
||||
for ( const QgsPointXY &p : constPl )
|
||||
@ -306,7 +308,8 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPointXY &pointMap,
|
||||
QgsRectangle aoi = _areaOfInterest( pointMap, tolerance );
|
||||
|
||||
QList<LayerAndAreaOfInterest> layers;
|
||||
Q_FOREACH ( QgsMapLayer *layer, mMapSettings.layers() )
|
||||
const auto constLayers = mMapSettings.layers();
|
||||
for ( QgsMapLayer *layer : constLayers )
|
||||
if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer ) )
|
||||
layers << qMakePair( vl, aoi );
|
||||
prepareIndex( layers );
|
||||
@ -314,8 +317,7 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPointXY &pointMap,
|
||||
QgsPointLocator::MatchList edges; // for snap on intersection
|
||||
QgsPointLocator::Match bestMatch;
|
||||
|
||||
const auto constLayers = layers;
|
||||
for ( const LayerAndAreaOfInterest &entry : constLayers )
|
||||
for ( const LayerAndAreaOfInterest &entry : qgis::as_const( layers ) )
|
||||
{
|
||||
QgsVectorLayer *vl = entry.first;
|
||||
if ( QgsPointLocator *loc = locatorForLayerUsingStrategy( vl, pointMap, tolerance ) )
|
||||
@ -525,7 +527,8 @@ QString QgsSnappingUtils::dump()
|
||||
}
|
||||
else if ( mSnappingConfig.mode() == QgsSnappingConfig::AllLayers )
|
||||
{
|
||||
Q_FOREACH ( QgsMapLayer *layer, mMapSettings.layers() )
|
||||
const auto constLayers = mMapSettings.layers();
|
||||
for ( QgsMapLayer *layer : constLayers )
|
||||
{
|
||||
if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer ) )
|
||||
layers << LayerConfig( vl, _snappingTypeToPointLocatorType( mSnappingConfig.type() ), mSnappingConfig.tolerance(), mSnappingConfig.units() );
|
||||
|
@ -340,7 +340,8 @@ QgsSqlExpressionCompiler::Result QgsSqlExpressionCompiler::compileNode( const Qg
|
||||
QStringList list;
|
||||
|
||||
Result inResult = Complete;
|
||||
Q_FOREACH ( const QgsExpressionNode *ln, n->list()->list() )
|
||||
const auto constList = n->list()->list();
|
||||
for ( const QgsExpressionNode *ln : constList )
|
||||
{
|
||||
QString s;
|
||||
Result r = compileNode( ln, s );
|
||||
@ -377,7 +378,8 @@ QgsSqlExpressionCompiler::Result QgsSqlExpressionCompiler::compileNode( const Qg
|
||||
// compile arguments
|
||||
QStringList args;
|
||||
Result inResult = Complete;
|
||||
Q_FOREACH ( const QgsExpressionNode *ln, n->args()->list() )
|
||||
const auto constList = n->args()->list();
|
||||
for ( const QgsExpressionNode *ln : constList )
|
||||
{
|
||||
QString s;
|
||||
Result r = compileNode( ln, s );
|
||||
|
@ -160,22 +160,26 @@ const QgsSQLStatement::Node *QgsSQLStatement::rootNode() const
|
||||
|
||||
void QgsSQLStatement::RecursiveVisitor::visit( const QgsSQLStatement::NodeSelect &n )
|
||||
{
|
||||
Q_FOREACH ( QgsSQLStatement::NodeTableDef *table, n.tables() )
|
||||
const auto constTables = n.tables();
|
||||
for ( QgsSQLStatement::NodeTableDef *table : constTables )
|
||||
{
|
||||
table->accept( *this );
|
||||
}
|
||||
Q_FOREACH ( QgsSQLStatement::NodeSelectedColumn *column, n.columns() )
|
||||
const auto constColumns = n.columns();
|
||||
for ( QgsSQLStatement::NodeSelectedColumn *column : constColumns )
|
||||
{
|
||||
column->accept( *this );
|
||||
}
|
||||
Q_FOREACH ( QgsSQLStatement::NodeJoin *join, n.joins() )
|
||||
const auto constJoins = n.joins();
|
||||
for ( QgsSQLStatement::NodeJoin *join : constJoins )
|
||||
{
|
||||
join->accept( *this );
|
||||
}
|
||||
QgsSQLStatement::Node *where = n.where();
|
||||
if ( where )
|
||||
where->accept( *this );
|
||||
Q_FOREACH ( QgsSQLStatement::NodeColumnSorted *column, n.orderBy() )
|
||||
const auto constOrderBy = n.orderBy();
|
||||
for ( QgsSQLStatement::NodeColumnSorted *column : constOrderBy )
|
||||
{
|
||||
column->accept( *this );
|
||||
}
|
||||
|
@ -434,22 +434,31 @@ void extractLinework( const QgsGeometry &g, QgsMultiPolylineXY &mpl )
|
||||
break;
|
||||
|
||||
case QgsWkbTypes::Polygon:
|
||||
Q_FOREACH ( const QgsPolylineXY &ring, geom.asPolygon() )
|
||||
{
|
||||
const auto polygon = geom.asPolygon();
|
||||
for ( const QgsPolylineXY &ring : polygon )
|
||||
mpl << ring;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case QgsWkbTypes::MultiLineString:
|
||||
Q_FOREACH ( const QgsPolylineXY &linestring, geom.asMultiPolyline() )
|
||||
{
|
||||
const auto multiPolyline = geom.asMultiPolyline();
|
||||
for ( const QgsPolylineXY &linestring : multiPolyline )
|
||||
mpl << linestring;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case QgsWkbTypes::MultiPolygon:
|
||||
Q_FOREACH ( const QgsPolygonXY &polygon, geom.asMultiPolygon() )
|
||||
{
|
||||
const auto multiPolygon = geom.asMultiPolygon();
|
||||
for ( const QgsPolygonXY &polygon : multiPolygon )
|
||||
{
|
||||
for ( const QgsPolylineXY &ring : polygon )
|
||||
mpl << ring;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break; // unknown type - do nothing
|
||||
|
@ -233,7 +233,8 @@ QgsVectorLayer *QgsVectorLayer::clone() const
|
||||
layer->setOpacity( opacity() );
|
||||
layer->setReadExtentFromXml( readExtentFromXml() );
|
||||
|
||||
Q_FOREACH ( const QgsAction &action, actions()->actions() )
|
||||
const auto constActions = actions()->actions();
|
||||
for ( const QgsAction &action : constActions )
|
||||
{
|
||||
layer->actions()->addAction( action );
|
||||
}
|
||||
|
@ -243,7 +243,8 @@ void QgsVectorLayerCache::onJoinAttributeValueChanged( QgsFeatureId fid, int fie
|
||||
{
|
||||
const QgsVectorLayer *joinLayer = qobject_cast<const QgsVectorLayer *>( sender() );
|
||||
|
||||
Q_FOREACH ( const QgsVectorLayerJoinInfo &info, mLayer->vectorJoins() )
|
||||
const auto constVectorJoins = mLayer->vectorJoins();
|
||||
for ( const QgsVectorLayerJoinInfo &info : constVectorJoins )
|
||||
{
|
||||
if ( joinLayer == info.joinLayer() )
|
||||
{
|
||||
@ -455,7 +456,8 @@ bool QgsVectorLayerCache::checkInformationCovered( const QgsFeatureRequest &feat
|
||||
|
||||
void QgsVectorLayerCache::connectJoinedLayers() const
|
||||
{
|
||||
Q_FOREACH ( const QgsVectorLayerJoinInfo &info, mLayer->vectorJoins() )
|
||||
const auto constVectorJoins = mLayer->vectorJoins();
|
||||
for ( const QgsVectorLayerJoinInfo &info : constVectorJoins )
|
||||
{
|
||||
const QgsVectorLayer *vl = info.joinLayer();
|
||||
if ( vl )
|
||||
|
@ -549,10 +549,12 @@ bool QgsVectorLayerEditBuffer::commitChanges( QStringList &commitErrors )
|
||||
commitErrors << tr( "ERROR: %n attribute value change(s) not applied.", "not changed attribute values count", mChangedAttributeValues.size() );
|
||||
#if 0
|
||||
QString list = "ERROR: pending changes:";
|
||||
Q_FOREACH ( QgsFeatureId id, mChangedAttributeValues.keys() )
|
||||
const auto constKeys = mChangedAttributeValues.keys();
|
||||
for ( QgsFeatureId id : constKeys )
|
||||
{
|
||||
list.append( "\n " + FID_TO_STRING( id ) + '[' );
|
||||
Q_FOREACH ( int idx, mChangedAttributeValues[ id ].keys() )
|
||||
const auto constKeys = mChangedAttributeValues[ id ].keys();
|
||||
for ( int idx : constKeys )
|
||||
{
|
||||
list.append( QString( " %1:%2" ).arg( L->fields().at( idx ).name() ).arg( mChangedAttributeValues[id][idx].toString() ) );
|
||||
}
|
||||
@ -680,7 +682,8 @@ bool QgsVectorLayerEditBuffer::commitChanges( QStringList &commitErrors )
|
||||
if ( !success && provider->hasErrors() )
|
||||
{
|
||||
commitErrors << tr( "\n Provider errors:" );
|
||||
Q_FOREACH ( QString e, provider->errors() )
|
||||
const auto constErrors = provider->errors();
|
||||
for ( QString e : constErrors )
|
||||
{
|
||||
commitErrors << " " + e.replace( '\n', QLatin1String( "\n " ) );
|
||||
}
|
||||
|
@ -203,7 +203,8 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayerFeat
|
||||
if ( mProviderRequest.filterType() == QgsFeatureRequest::FilterExpression )
|
||||
{
|
||||
const bool needsGeom = mProviderRequest.filterExpression()->needsGeometry();
|
||||
Q_FOREACH ( const QString &field, mProviderRequest.filterExpression()->referencedColumns() )
|
||||
const auto constReferencedColumns = mProviderRequest.filterExpression()->referencedColumns();
|
||||
for ( const QString &field : constReferencedColumns )
|
||||
{
|
||||
int idx = source->mFields.lookupField( field );
|
||||
|
||||
@ -628,7 +629,7 @@ void QgsVectorLayerFeatureIterator::prepareExpression( int fieldIdx )
|
||||
const QList<QgsExpressionFieldBuffer::ExpressionField> &exps = mSource->mExpressionFieldBuffer->expressions();
|
||||
|
||||
int oi = mSource->mFields.fieldOriginIndex( fieldIdx );
|
||||
QgsExpression *exp = new QgsExpression( exps[oi].cachedExpression );
|
||||
std::unique_ptr<QgsExpression> exp = qgis::make_unique<QgsExpression>( exps[oi].cachedExpression );
|
||||
|
||||
QgsDistanceArea da;
|
||||
da.setSourceCrs( mSource->mCrs, QgsProject::instance()->transformContext() );
|
||||
@ -638,18 +639,18 @@ void QgsVectorLayerFeatureIterator::prepareExpression( int fieldIdx )
|
||||
exp->setAreaUnits( QgsProject::instance()->areaUnits() );
|
||||
|
||||
exp->prepare( mExpressionContext.get() );
|
||||
Q_FOREACH ( const QString &col, exp->referencedColumns() )
|
||||
const auto referencedColumns = exp->referencedColumns();
|
||||
for ( const QString &col : referencedColumns )
|
||||
{
|
||||
if ( mSource->fields().lookupField( col ) == fieldIdx )
|
||||
{
|
||||
// circular reference - expression depends on column itself
|
||||
delete exp;
|
||||
return;
|
||||
}
|
||||
}
|
||||
mExpressionFieldInfo.insert( fieldIdx, exp );
|
||||
mExpressionFieldInfo.insert( fieldIdx, exp.release() );
|
||||
|
||||
Q_FOREACH ( const QString &col, exp->referencedColumns() )
|
||||
for ( const QString &col : referencedColumns )
|
||||
{
|
||||
int dependentFieldIdx = mSource->mFields.lookupField( col );
|
||||
if ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes )
|
||||
|
@ -33,7 +33,8 @@ QgsVectorLayerJoinBuffer::QgsVectorLayerJoinBuffer( QgsVectorLayer *layer )
|
||||
static QList<QgsVectorLayer *> _outEdges( QgsVectorLayer *vl )
|
||||
{
|
||||
QList<QgsVectorLayer *> lst;
|
||||
Q_FOREACH ( const QgsVectorLayerJoinInfo &info, vl->vectorJoins() )
|
||||
const auto constVectorJoins = vl->vectorJoins();
|
||||
for ( const QgsVectorLayerJoinInfo &info : constVectorJoins )
|
||||
{
|
||||
if ( QgsVectorLayer *joinVl = info.joinLayer() )
|
||||
lst << joinVl;
|
||||
|
@ -59,7 +59,8 @@ QgsVirtualLayerDefinition QgsVirtualLayerDefinitionUtils::fromJoinedLayer( QgsVe
|
||||
}
|
||||
|
||||
int joinIdx = 0;
|
||||
Q_FOREACH ( const QgsVectorLayerJoinInfo &join, layer->vectorJoins() )
|
||||
const auto constVectorJoins = layer->vectorJoins();
|
||||
for ( const QgsVectorLayerJoinInfo &join : constVectorJoins )
|
||||
{
|
||||
QString joinName = QStringLiteral( "j%1" ).arg( ++joinIdx );
|
||||
QgsVectorLayer *joinedLayer = join.joinLayer();
|
||||
|
@ -1504,10 +1504,11 @@ QModelIndex QgsCptCityBrowserModel::findPath( const QString &path )
|
||||
// if we are using a selection collection, search for target in the mapping in this group
|
||||
if ( item->type() == QgsCptCityDataItem::Selection )
|
||||
{
|
||||
const QgsCptCitySelectionItem *selItem = dynamic_cast<const QgsCptCitySelectionItem *>( item );
|
||||
const QgsCptCitySelectionItem *selItem = qobject_cast<const QgsCptCitySelectionItem *>( item );
|
||||
if ( selItem )
|
||||
{
|
||||
Q_FOREACH ( QString childPath, selItem->selectionsList() )
|
||||
const auto constSelectionsList = selItem->selectionsList();
|
||||
for ( QString childPath : constSelectionsList )
|
||||
{
|
||||
if ( childPath.endsWith( '/' ) )
|
||||
childPath.chop( 1 );
|
||||
|
@ -1163,7 +1163,8 @@ void QgsRuleBasedRenderer::refineRuleCategories( QgsRuleBasedRenderer::Rule *ini
|
||||
attr = QgsExpression::quotedColumnRef( attr );
|
||||
}
|
||||
|
||||
Q_FOREACH ( const QgsRendererCategory &cat, r->categories() )
|
||||
const auto constCategories = r->categories();
|
||||
for ( const QgsRendererCategory &cat : constCategories )
|
||||
{
|
||||
QString value;
|
||||
// not quoting numbers saves a type cast
|
||||
@ -1199,7 +1200,8 @@ void QgsRuleBasedRenderer::refineRuleRanges( QgsRuleBasedRenderer::Rule *initial
|
||||
}
|
||||
|
||||
bool firstRange = true;
|
||||
Q_FOREACH ( const QgsRendererRange &rng, r->ranges() )
|
||||
const auto constRanges = r->ranges();
|
||||
for ( const QgsRendererRange &rng : constRanges )
|
||||
{
|
||||
// due to the loss of precision in double->string conversion we may miss out values at the limit of the range
|
||||
// TODO: have a possibility to construct expressions directly as a parse tree to avoid loss of precision
|
||||
|
Loading…
x
Reference in New Issue
Block a user