Skip to content
Permalink
Browse files

Massive Q_FOREACH to range-based-for conversion

  • Loading branch information
m-kuhn committed Apr 5, 2019
1 parent 2bb049e commit 6958b7a2513dbb16d072fce03f910359e34e1f90
Showing with 851 additions and 437 deletions.
  1. +4 −2 src/core/expression/qgsexpressioncontextutils.cpp
  2. +6 −3 src/core/layertree/qgslayertree.cpp
  3. +22 −11 src/core/layertree/qgslayertreegroup.cpp
  4. +25 −14 src/core/layertree/qgslayertreemodel.cpp
  5. +6 −3 src/core/layertree/qgslayertreenode.cpp
  6. +6 −3 src/core/layertree/qgslayertreeregistrybridge.cpp
  7. +8 −4 src/core/layertree/qgslayertreeutils.cpp
  8. +11 −6 src/core/layout/qgslayoutguidecollection.cpp
  9. +16 −8 src/core/layout/qgslayoutpagecollection.cpp
  10. +10 −5 src/core/layout/qgslayouttable.cpp
  11. +2 −1 src/core/layout/qgspagesizeregistry.cpp
  12. +2 −1 src/core/pal/feature.cpp
  13. +2 −1 src/core/pal/layer.cpp
  14. +2 −1 src/core/pal/pal.cpp
  15. +14 −8 src/core/processing/models/qgsprocessingmodelalgorithm.cpp
  16. +2 −1 src/core/processing/qgsprocessingalgorithm.cpp
  17. +20 −10 src/core/processing/qgsprocessingparameters.cpp
  18. +2 −1 src/core/processing/qgsprocessingregistry.cpp
  19. +2 −1 src/core/providers/memory/qgsmemoryprovider.cpp
  20. +2 −1 src/core/qgsaction.cpp
  21. +2 −1 src/core/qgsactionscoperegistry.cpp
  22. +6 −3 src/core/qgsapplication.cpp
  23. +2 −1 src/core/qgsattributeeditorelement.cpp
  24. +4 −2 src/core/qgsattributetableconfig.cpp
  25. +6 −3 src/core/qgsbrowsermodel.cpp
  26. +2 −1 src/core/qgscolorramp.cpp
  27. +2 −1 src/core/qgscolorscheme.cpp
  28. +10 −5 src/core/qgsconditionalstyle.cpp
  29. +2 −1 src/core/qgscoordinatereferencesystem.cpp
  30. +8 −6 src/core/qgsdatadefinedsizelegend.cpp
  31. +34 −17 src/core/qgsdataitem.cpp
  32. +2 −1 src/core/qgsdataitemproviderregistry.cpp
  33. +2 −1 src/core/qgsdatasourceuri.cpp
  34. +2 −1 src/core/qgsdatetimestatisticalsummary.cpp
  35. +2 −1 src/core/qgseditformconfig.cpp
  36. +2 −1 src/core/qgserror.cpp
  37. +20 −10 src/core/qgsexpressioncontext.cpp
  38. +4 −2 src/core/qgsexpressionfieldbuffer.cpp
  39. +2 −1 src/core/qgsfeatureiterator.cpp
  40. +6 −3 src/core/qgsfeaturerequest.cpp
  41. +2 −1 src/core/qgsfontutils.cpp
  42. +8 −4 src/core/qgsgml.cpp
  43. +8 −4 src/core/qgsgmlschema.cpp
  44. +2 −1 src/core/qgsinterval.cpp
  45. +4 −2 src/core/qgsjsonutils.cpp
  46. +4 −2 src/core/qgslabelingengine.cpp
  47. +16 −8 src/core/qgslayerdefinition.cpp
  48. +6 −3 src/core/qgslegendrenderer.cpp
  49. +4 −2 src/core/qgsmaplayer.cpp
  50. +6 −3 src/core/qgsmaplayerlegend.cpp
  51. +6 −3 src/core/qgsmaplayermodel.cpp
  52. +4 −2 src/core/qgsmaplayerproxymodel.cpp
  53. +10 −5 src/core/qgsmaplayerstore.cpp
  54. +6 −3 src/core/qgsmaprenderercache.cpp
  55. +4 −2 src/core/qgsmaprendererjob.cpp
  56. +6 −3 src/core/qgsmaprenderertask.cpp
  57. +2 −1 src/core/qgsmapsettings.cpp
  58. +16 −8 src/core/qgsmapthemecollection.cpp
  59. +8 −4 src/core/qgsmimedatautils.cpp
  60. +4 −2 src/core/qgsmultirenderchecker.cpp
  61. +2 −1 src/core/qgsnetworkreplyparser.cpp
  62. +10 −5 src/core/qgsogcutils.cpp
  63. +2 −1 src/core/qgspluginlayerregistry.cpp
  64. +8 −4 src/core/qgsproject.cpp
  65. +2 −1 src/core/qgsprojectbadlayerhandler.cpp
  66. +18 −9 src/core/qgspropertycollection.cpp
  67. +6 −3 src/core/qgspropertytransformer.cpp
  68. +16 −8 src/core/qgsrelationmanager.cpp
  69. +4 −2 src/core/qgssnappingconfig.cpp
  70. +16 −9 src/core/qgssnappingutils.cpp
  71. +22 −11 src/core/qgssqlstatement.cpp
  72. +2 −1 src/core/qgsstatisticalsummary.cpp
  73. +4 −2 src/core/qgsstringstatisticalsummary.cpp
  74. +4 −2 src/core/qgsstringutils.cpp
  75. +20 −10 src/core/qgstaskmanager.cpp
  76. +5 −3 src/core/qgstextrenderer.cpp
  77. +7 −4 src/core/qgstracer.cpp
  78. +2 −1 src/core/qgstransaction.cpp
  79. +10 −5 src/core/qgstransactiongroup.cpp
  80. +2 −1 src/core/qgsvectordataprovider.cpp
  81. +8 −4 src/core/qgsvectorfilewriter.cpp
  82. +21 −14 src/core/qgsvectorlayer.cpp
  83. +8 −4 src/core/qgsvectorlayercache.cpp
  84. +16 −8 src/core/qgsvectorlayereditbuffer.cpp
  85. +2 −1 src/core/qgsvectorlayerexporter.cpp
  86. +2 −1 src/core/qgsvectorlayerfeaturecounter.cpp
  87. +2 −1 src/core/qgsvectorlayerfeatureiterator.cpp
  88. +10 −5 src/core/qgsvectorlayerjoinbuffer.cpp
  89. +2 −1 src/core/qgsvectorlayerlabelprovider.cpp
  90. +2 −1 src/core/qgsvectorlayerutils.cpp
  91. +4 −2 src/core/qgsxmlutils.cpp
  92. +6 −3 src/core/raster/qgspalettedrasterrenderer.cpp
  93. +2 −1 src/core/raster/qgsrasterfilewriter.cpp
  94. +8 −4 src/core/raster/qgsrasterinterface.cpp
  95. +2 −1 src/core/raster/qgsrasterlayer.cpp
  96. +2 −1 src/core/raster/qgsrasterpipe.cpp
  97. +24 −12 src/core/symbology/qgscptcityarchive.cpp
  98. +22 −11 src/core/symbology/qgsgraduatedsymbolrenderer.cpp
  99. +6 −3 src/core/symbology/qgsinvertedpolygonrenderer.cpp
  100. +4 −2 src/core/symbology/qgspointdistancerenderer.cpp
  101. +6 −3 src/core/symbology/qgsrenderer.cpp
  102. +2 −1 src/core/symbology/qgsrendererregistry.cpp
  103. +44 −22 src/core/symbology/qgsrulebasedrenderer.cpp
  104. +4 −2 src/core/symbology/qgsstyle.cpp
  105. +70 −36 src/core/symbology/qgssymbol.cpp
@@ -325,7 +325,8 @@ QgsExpressionContextScope *QgsExpressionContextUtils::layerScope( const QgsMapLa
QStringList variableValues = layer->customProperty( QStringLiteral( "variableValues" ) ).toStringList();

int varIndex = 0;
Q_FOREACH ( const QString &variableName, variableNames )
const auto constVariableNames = variableNames;
for ( const QString &variableName : constVariableNames )
{
if ( varIndex >= variableValues.length() )
{
@@ -529,7 +530,8 @@ QgsExpressionContextScope *QgsExpressionContextUtils::layoutScope( const QgsLayo
QStringList variableValues = layout->customProperty( QStringLiteral( "variableValues" ) ).toStringList();

int varIndex = 0;
Q_FOREACH ( const QString &variableName, variableNames )
const auto constVariableNames = variableNames;
for ( const QString &variableName : constVariableNames )
{
if ( varIndex >= variableValues.length() )
{
@@ -129,14 +129,16 @@ void QgsLayerTree::writeXml( QDomElement &parentElement, const QgsReadWriteConte

writeCommonXml( elem );

Q_FOREACH ( QgsLayerTreeNode *node, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *node : constMChildren )
node->writeXml( elem, context );

QDomElement customOrderElem = doc.createElement( QStringLiteral( "custom-order" ) );
customOrderElem.setAttribute( QStringLiteral( "enabled" ), mHasCustomLayerOrder ? 1 : 0 );
elem.appendChild( customOrderElem );

Q_FOREACH ( QgsMapLayer *layer, mCustomLayerOrder )
const auto constMCustomLayerOrder = mCustomLayerOrder;
for ( QgsMapLayer *layer : constMCustomLayerOrder )
{
// Safety belt, see https://issues.qgis.org/issues/19145
// Crash when deleting an item from the layout legend
@@ -186,7 +188,8 @@ void QgsLayerTree::nodeAddedChildren( QgsLayerTreeNode *node, int indexFrom, int
}
}

Q_FOREACH ( QgsMapLayer *layer, layers )
const auto constLayers = layers;
for ( QgsMapLayer *layer : constLayers )
{
if ( !mCustomLayerOrder.contains( layer ) && layer )
mCustomLayerOrder.append( layer );
@@ -138,7 +138,8 @@ void QgsLayerTreeGroup::removeChildNode( QgsLayerTreeNode *node )

void QgsLayerTreeGroup::removeLayer( QgsMapLayer *layer )
{
Q_FOREACH ( QgsLayerTreeNode *child, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *child : constMChildren )
{
if ( QgsLayerTree::isLayer( child ) )
{
@@ -201,7 +202,8 @@ QgsLayerTreeLayer *QgsLayerTreeGroup::findLayer( QgsMapLayer *layer ) const

QgsLayerTreeLayer *QgsLayerTreeGroup::findLayer( const QString &layerId ) const
{
Q_FOREACH ( QgsLayerTreeNode *child, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *child : constMChildren )
{
if ( QgsLayerTree::isLayer( child ) )
{
@@ -222,7 +224,8 @@ QgsLayerTreeLayer *QgsLayerTreeGroup::findLayer( const QString &layerId ) const
QList<QgsLayerTreeLayer *> QgsLayerTreeGroup::findLayers() const
{
QList<QgsLayerTreeLayer *> list;
Q_FOREACH ( QgsLayerTreeNode *child, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *child : constMChildren )
{
if ( QgsLayerTree::isLayer( child ) )
list << QgsLayerTree::toLayer( child );
@@ -234,7 +237,8 @@ QList<QgsLayerTreeLayer *> QgsLayerTreeGroup::findLayers() const

QgsLayerTreeGroup *QgsLayerTreeGroup::findGroup( const QString &name )
{
Q_FOREACH ( QgsLayerTreeNode *child, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *child : constMChildren )
{
if ( QgsLayerTree::isGroup( child ) )
{
@@ -310,7 +314,8 @@ void QgsLayerTreeGroup::writeXml( QDomElement &parentElement, const QgsReadWrite

writeCommonXml( elem );

Q_FOREACH ( QgsLayerTreeNode *node, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *node : constMChildren )
node->writeXml( elem, context );

parentElement.appendChild( elem );
@@ -336,7 +341,8 @@ QString QgsLayerTreeGroup::dump() const
{
QString header = QStringLiteral( "GROUP: %1 checked=%2 expanded=%3\n" ).arg( name() ).arg( mChecked ).arg( mExpanded );
QStringList childrenDump;
Q_FOREACH ( QgsLayerTreeNode *node, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *node : constMChildren )
childrenDump << node->dump().split( '\n' );
for ( int i = 0; i < childrenDump.count(); ++i )
childrenDump[i].prepend( " " );
@@ -350,7 +356,8 @@ QgsLayerTreeGroup *QgsLayerTreeGroup::clone() const

void QgsLayerTreeGroup::resolveReferences( const QgsProject *project, bool looseMatching )
{
Q_FOREACH ( QgsLayerTreeNode *node, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *node : constMChildren )
node->resolveReferences( project, looseMatching );
}

@@ -379,7 +386,8 @@ void QgsLayerTreeGroup::setIsMutuallyExclusive( bool enabled, int initialChildIn
{
// try to use first checked index
int index = 0;
Q_FOREACH ( QgsLayerTreeNode *child, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *child : constMChildren )
{
if ( _nodeIsChecked( child ) )
{
@@ -396,7 +404,8 @@ void QgsLayerTreeGroup::setIsMutuallyExclusive( bool enabled, int initialChildIn
QStringList QgsLayerTreeGroup::findLayerIds() const
{
QStringList lst;
Q_FOREACH ( QgsLayerTreeNode *child, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *child : constMChildren )
{
if ( QgsLayerTree::isGroup( child ) )
lst << QgsLayerTree::toGroup( child )->findLayerIds();
@@ -432,7 +441,8 @@ void QgsLayerTreeGroup::updateChildVisibilityMutuallyExclusive()
mChangingChildVisibility = true; // guard against running again setVisible() triggered from children

int index = 0;
Q_FOREACH ( QgsLayerTreeNode *child, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *child : constMChildren )
{
child->setItemVisibilityChecked( index == mMutuallyExclusiveChildIndex );
++index;
@@ -448,7 +458,8 @@ void QgsLayerTreeGroup::setItemVisibilityCheckedRecursive( bool checked )
mChangingChildVisibility = true; // guard against running again setVisible() triggered from children

int index = 0;
Q_FOREACH ( QgsLayerTreeNode *child, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *child : constMChildren )
{
child->setItemVisibilityCheckedRecursive( checked && ( mMutuallyExclusiveChildIndex < 0 || index == mMutuallyExclusiveChildIndex ) );
++index;
@@ -474,7 +474,8 @@ static bool _isChildOfNode( QgsLayerTreeNode *child, QgsLayerTreeNode *node )

static bool _isChildOfNodes( QgsLayerTreeNode *child, const QList<QgsLayerTreeNode *> &nodes )
{
Q_FOREACH ( QgsLayerTreeNode *n, nodes )
const auto constNodes = nodes;
for ( QgsLayerTreeNode *n : constNodes )
{
if ( _isChildOfNode( child, n ) )
return true;
@@ -487,7 +488,8 @@ static bool _isChildOfNodes( QgsLayerTreeNode *child, const QList<QgsLayerTreeNo
QList<QgsLayerTreeNode *> QgsLayerTreeModel::indexes2nodes( const QModelIndexList &list, bool skipInternal ) const
{
QList<QgsLayerTreeNode *> nodes;
Q_FOREACH ( const QModelIndex &index, list )
const auto constList = list;
for ( const QModelIndex &index : constList )
{
QgsLayerTreeNode *node = index2node( index );
if ( !node )
@@ -501,7 +503,8 @@ QList<QgsLayerTreeNode *> QgsLayerTreeModel::indexes2nodes( const QModelIndexLis

// remove any children of nodes if both parent node and children are selected
QList<QgsLayerTreeNode *> nodesFinal;
Q_FOREACH ( QgsLayerTreeNode *node, nodes )
const auto constNodes = nodes;
for ( QgsLayerTreeNode *node : constNodes )
{
if ( !_isChildOfNodes( node, nodes ) )
nodesFinal << node;
@@ -1039,7 +1042,8 @@ QMimeData *QgsLayerTreeModel::mimeData( const QModelIndexList &indexes ) const

QDomDocument doc;
QDomElement rootElem = doc.createElement( QStringLiteral( "layer_tree_model_data" ) );
Q_FOREACH ( QgsLayerTreeNode *node, nodesFinal )
const auto constNodesFinal = nodesFinal;
for ( QgsLayerTreeNode *node : constNodesFinal )
node->writeXml( rootElem, QgsReadWriteContext() );
doc.appendChild( rootElem );
QString txt = doc.toString();
@@ -1144,7 +1148,8 @@ QList<QgsLayerTreeModelLegendNode *> QgsLayerTreeModel::filterLegendNodes( const

if ( mLegendFilterByScale > 0 )
{
Q_FOREACH ( QgsLayerTreeModelLegendNode *node, nodes )
const auto constNodes = nodes;
for ( QgsLayerTreeModelLegendNode *node : constNodes )
{
if ( node->isScaleOK( mLegendFilterByScale ) )
filtered << node;
@@ -1154,7 +1159,8 @@ QList<QgsLayerTreeModelLegendNode *> QgsLayerTreeModel::filterLegendNodes( const
{
if ( !nodes.isEmpty() && mLegendFilterMapSettings->layers().contains( nodes.at( 0 )->layerNode()->layer() ) )
{
Q_FOREACH ( QgsLayerTreeModelLegendNode *node, nodes )
const auto constNodes = nodes;
for ( QgsLayerTreeModelLegendNode *node : constNodes )
{
QString ruleKey = node->data( QgsSymbolLegendNode::RuleKeyRole ).toString();
bool checked = mLegendFilterUsesExtent || node->data( Qt::CheckStateRole ).toInt() == Qt::Checked;
@@ -1190,7 +1196,8 @@ QList<QgsLayerTreeModelLegendNode *> QgsLayerTreeModel::filterLegendNodes( const

void QgsLayerTreeModel::legendCleanup()
{
Q_FOREACH ( const LayerLegendData &data, mLegend )
const auto constMLegend = mLegend;
for ( const LayerLegendData &data : constMLegend )
{
qDeleteAll( data.originalNodes );
delete data.tree;
@@ -1242,7 +1249,8 @@ void QgsLayerTreeModel::addLegendToLayer( QgsLayerTreeLayer *nodeL )

QList<QgsLayerTreeModelLegendNode *> filteredLstNew = filterLegendNodes( lstNew );

Q_FOREACH ( QgsLayerTreeModelLegendNode *n, lstNew )
const auto constLstNew = lstNew;
for ( QgsLayerTreeModelLegendNode *n : constLstNew )
{
n->setParent( this );
connect( n, &QgsLayerTreeModelLegendNode::dataChanged, this, &QgsLayerTreeModel::legendNodeDataChanged );
@@ -1252,7 +1260,8 @@ void QgsLayerTreeModel::addLegendToLayer( QgsLayerTreeLayer *nodeL )
// Legend node embedded in parent does not have to be the first one,
// there can be also nodes generated for embedded widgets
QgsLayerTreeModelLegendNode *embeddedNode = nullptr;
Q_FOREACH ( QgsLayerTreeModelLegendNode *legendNode, filteredLstNew )
const auto constFilteredLstNew = filteredLstNew;
for ( QgsLayerTreeModelLegendNode *legendNode : constFilteredLstNew )
{
if ( legendNode->isEmbeddedInParent() )
{
@@ -1292,7 +1301,7 @@ QgsLayerTreeModel::LayerLegendTree *QgsLayerTreeModel::tryBuildLegendTree( const
{
// first check whether there are any legend nodes that are not top-level
bool hasParentKeys = false;
Q_FOREACH ( QgsLayerTreeModelLegendNode *n, nodes )
for ( QgsLayerTreeModelLegendNode *n : nodes )
{
if ( !n->data( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString().isEmpty() )
{
@@ -1306,7 +1315,7 @@ QgsLayerTreeModel::LayerLegendTree *QgsLayerTreeModel::tryBuildLegendTree( const
// make mapping from rules to nodes and do some sanity checks
QHash<QString, QgsLayerTreeModelLegendNode *> rule2node;
rule2node[QString()] = nullptr;
Q_FOREACH ( QgsLayerTreeModelLegendNode *n, nodes )
for ( QgsLayerTreeModelLegendNode *n : nodes )
{
QString ruleKey = n->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString();
if ( ruleKey.isEmpty() ) // in tree all nodes must have key
@@ -1318,7 +1327,7 @@ QgsLayerTreeModel::LayerLegendTree *QgsLayerTreeModel::tryBuildLegendTree( const

// create the tree structure
LayerLegendTree *tree = new LayerLegendTree;
Q_FOREACH ( QgsLayerTreeModelLegendNode *n, nodes )
for ( QgsLayerTreeModelLegendNode *n : nodes )
{
QString parentRuleKey = n->data( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString();
QgsLayerTreeModelLegendNode *parent = rule2node.value( parentRuleKey, nullptr );
@@ -1541,7 +1550,8 @@ void QgsLayerTreeModel::invalidateLegendMapBasedData()

std::unique_ptr<QgsRenderContext> context( createTemporaryRenderContext() );

Q_FOREACH ( const LayerLegendData &data, mLegend )
const auto constMLegend = mLegend;
for ( const LayerLegendData &data : constMLegend )
{
QList<QgsSymbolLegendNode *> symbolNodes;
QMap<QString, int> widthMax;
@@ -1557,7 +1567,8 @@ void QgsLayerTreeModel::invalidateLegendMapBasedData()
symbolNodes.append( n );
}
}
Q_FOREACH ( QgsSymbolLegendNode *n, symbolNodes )
const auto constSymbolNodes = symbolNodes;
for ( QgsSymbolLegendNode *n : constSymbolNodes )
{
const QString parentKey( n->data( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString() );
Q_ASSERT( widthMax[parentKey] > 0 );
@@ -109,7 +109,8 @@ bool QgsLayerTreeNode::isItemVisibilityCheckedRecursive() const
{
if ( !mChecked )
return false;
Q_FOREACH ( QgsLayerTreeNode *child, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *child : constMChildren )
{
if ( !child->isItemVisibilityCheckedRecursive() )
return false;
@@ -122,7 +123,8 @@ bool QgsLayerTreeNode::isItemVisibilityUncheckedRecursive() const
{
if ( mChecked )
return false;
Q_FOREACH ( QgsLayerTreeNode *child, mChildren )
const auto constMChildren = mChildren;
for ( QgsLayerTreeNode *child : constMChildren )
{
if ( !child->isItemVisibilityUncheckedRecursive() )
return false;
@@ -199,7 +201,8 @@ void QgsLayerTreeNode::insertChildrenPrivate( int index, QList<QgsLayerTreeNode
if ( nodes.isEmpty() )
return;

Q_FOREACH ( QgsLayerTreeNode *node, nodes )
const auto constNodes = nodes;
for ( QgsLayerTreeNode *node : constNodes )
{
Q_ASSERT( !node->mParent );
node->mParent = this;
@@ -49,7 +49,8 @@ void QgsLayerTreeRegistryBridge::layersAdded( const QList<QgsMapLayer *> &layers
return;

QList<QgsLayerTreeNode *> nodes;
Q_FOREACH ( QgsMapLayer *layer, layers )
const auto constLayers = layers;
for ( QgsMapLayer *layer : constLayers )
{
QgsLayerTreeLayer *nodeLayer = new QgsLayerTreeLayer( layer );
nodeLayer->setItemVisibilityChecked( mNewLayersVisible );
@@ -83,7 +84,8 @@ void QgsLayerTreeRegistryBridge::layersWillBeRemoved( const QStringList &layerId
// the registry _again_ in groupRemovedChildren() - this prevents it
mRegistryRemovingLayers = true;

Q_FOREACH ( const QString &layerId, layerIds )
const auto constLayerIds = layerIds;
for ( const QString &layerId : constLayerIds )
{
QgsLayerTreeLayer *nodeLayer = mRoot->findLayer( layerId );
if ( nodeLayer )
@@ -131,7 +133,8 @@ void QgsLayerTreeRegistryBridge::groupRemovedChildren()
// remove only those that really do not exist in the tree
// (ignores layers that were dragged'n'dropped: 1. drop new 2. remove old)
QStringList toRemove;
Q_FOREACH ( const QString &layerId, mLayerIdsForRemoval )
const auto constMLayerIdsForRemoval = mLayerIdsForRemoval;
for ( const QString &layerId : constMLayerIdsForRemoval )
if ( !mRoot->findLayer( layerId ) )
toRemove << layerId;
mLayerIdsForRemoval.clear();
@@ -93,7 +93,8 @@ bool QgsLayerTreeUtils::readOldLegendLayerOrder( const QDomElement &legendElem,
if ( !res && hasCustomOrder )
return false; // invalid state

Q_FOREACH ( const QString &layerId, layerIndexes )
const auto constLayerIndexes = layerIndexes;
for ( const QString &layerId : constLayerIndexes )
{
QgsDebugMsg( layerId );
order.append( layerId );
@@ -262,7 +263,8 @@ static void _readOldLegendLayer( const QDomElement &layerElem, QgsLayerTreeGroup

bool QgsLayerTreeUtils::layersEditable( const QList<QgsLayerTreeLayer *> &layerNodes )
{
Q_FOREACH ( QgsLayerTreeLayer *layerNode, layerNodes )
const auto constLayerNodes = layerNodes;
for ( QgsLayerTreeLayer *layerNode : constLayerNodes )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layerNode->layer() );
if ( !vl )
@@ -276,7 +278,8 @@ bool QgsLayerTreeUtils::layersEditable( const QList<QgsLayerTreeLayer *> &layerN

bool QgsLayerTreeUtils::layersModified( const QList<QgsLayerTreeLayer *> &layerNodes )
{
Q_FOREACH ( QgsLayerTreeLayer *layerNode, layerNodes )
const auto constLayerNodes = layerNodes;
for ( QgsLayerTreeLayer *layerNode : constLayerNodes )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layerNode->layer() );
if ( !vl )
@@ -302,7 +305,8 @@ void QgsLayerTreeUtils::removeInvalidLayers( QgsLayerTreeGroup *group )
}
}

Q_FOREACH ( QgsLayerTreeNode *node, nodesToRemove )
const auto constNodesToRemove = nodesToRemove;
for ( QgsLayerTreeNode *node : constNodesToRemove )
group->removeChildNode( node );
}

0 comments on commit 6958b7a

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