Skip to content
Permalink
Browse files

Less auto

(cherry picked from commit 1a07654)
(cherry picked from commit 3e05f07)
  • Loading branch information
nyalldawson committed Mar 1, 2020
1 parent b7bc1c3 commit 52405677948e7d052d9fec13e9e9c326bef8c1df
Showing with 23 additions and 29 deletions.
  1. +23 −29 src/core/qgsmapthemecollection.cpp
@@ -45,8 +45,8 @@ QgsMapThemeCollection::MapThemeLayerRecord QgsMapThemeCollection::createThemeLay
bool hasCheckableItems = false;
bool someItemsUnchecked = false;
QSet<QString> checkedItems;
const auto constLayerLegendNodes = model->layerLegendNodes( nodeLayer, true );
for ( QgsLayerTreeModelLegendNode *legendNode : constLayerLegendNodes )
const QList<QgsLayerTreeModelLegendNode *> layerLegendNodes = model->layerLegendNodes( nodeLayer, true );
for ( QgsLayerTreeModelLegendNode *legendNode : layerLegendNodes )
{
if ( legendNode->flags() & Qt::ItemIsUserCheckable )
{
@@ -80,7 +80,7 @@ static QString _groupId( QgsLayerTreeNode *node )

void QgsMapThemeCollection::createThemeFromCurrentState( QgsLayerTreeGroup *parent, QgsLayerTreeModel *model, QgsMapThemeCollection::MapThemeRecord &rec )
{
const auto constChildren = parent->children();
const QList<QgsLayerTreeNode *> constChildren = parent->children();
for ( QgsLayerTreeNode *node : constChildren )
{
if ( QgsLayerTree::isGroup( node ) )
@@ -150,7 +150,7 @@ void QgsMapThemeCollection::applyThemeToLayer( QgsLayerTreeLayer *nodeLayer, Qgs
if ( layerRec.usingLegendItems )
{
// some nodes are not checked
const auto constLayerLegendNodes = model->layerLegendNodes( nodeLayer, true );
const QList<QgsLayerTreeModelLegendNode *> constLayerLegendNodes = model->layerLegendNodes( nodeLayer, true );
for ( QgsLayerTreeModelLegendNode *legendNode : constLayerLegendNodes )
{
QString ruleKey = legendNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString();
@@ -163,7 +163,7 @@ void QgsMapThemeCollection::applyThemeToLayer( QgsLayerTreeLayer *nodeLayer, Qgs
else
{
// all nodes should be checked
const auto constLayerLegendNodes = model->layerLegendNodes( nodeLayer, true );
const QList<QgsLayerTreeModelLegendNode *> constLayerLegendNodes = model->layerLegendNodes( nodeLayer, true );
for ( QgsLayerTreeModelLegendNode *legendNode : constLayerLegendNodes )
{
if ( ( legendNode->flags() & Qt::ItemIsUserCheckable ) &&
@@ -183,7 +183,7 @@ void QgsMapThemeCollection::applyThemeToLayer( QgsLayerTreeLayer *nodeLayer, Qgs

void QgsMapThemeCollection::applyThemeToGroup( QgsLayerTreeGroup *parent, QgsLayerTreeModel *model, const QgsMapThemeCollection::MapThemeRecord &rec )
{
const auto constChildren = parent->children();
const QList<QgsLayerTreeNode *> constChildren = parent->children();
for ( QgsLayerTreeNode *node : constChildren )
{
if ( QgsLayerTree::isGroup( node ) )
@@ -234,8 +234,8 @@ QList<QgsMapLayer *> QgsMapThemeCollection::masterLayerOrder() const

QList<QgsMapLayer *> QgsMapThemeCollection::masterVisibleLayers() const
{
QList< QgsMapLayer *> allLayers = masterLayerOrder();
QList< QgsMapLayer * > visibleLayers = mProject->layerTreeRoot()->checkedLayers();
const QList< QgsMapLayer *> allLayers = masterLayerOrder();
const QList< QgsMapLayer * > visibleLayers = mProject->layerTreeRoot()->checkedLayers();

if ( allLayers.isEmpty() )
{
@@ -245,8 +245,7 @@ QList<QgsMapLayer *> QgsMapThemeCollection::masterVisibleLayers() const
else
{
QList< QgsMapLayer * > orderedVisibleLayers;
const auto constAllLayers = allLayers;
for ( QgsMapLayer *layer : constAllLayers )
for ( QgsMapLayer *layer : allLayers )
{
if ( visibleLayers.contains( layer ) )
orderedVisibleLayers << layer;
@@ -309,7 +308,7 @@ QStringList QgsMapThemeCollection::mapThemes() const
QStringList QgsMapThemeCollection::mapThemeVisibleLayerIds( const QString &name ) const
{
QStringList layerIds;
const auto constMapThemeVisibleLayers = mapThemeVisibleLayers( name );
const QList<QgsMapLayer *> constMapThemeVisibleLayers = mapThemeVisibleLayers( name );
for ( QgsMapLayer *layer : constMapThemeVisibleLayers )
{
layerIds << layer->id();
@@ -320,12 +319,12 @@ QStringList QgsMapThemeCollection::mapThemeVisibleLayerIds( const QString &name
QList<QgsMapLayer *> QgsMapThemeCollection::mapThemeVisibleLayers( const QString &name ) const
{
QList<QgsMapLayer *> layers;
const QList<MapThemeLayerRecord> &recs = mMapThemes.value( name ).mLayerRecords;
QList<QgsMapLayer *> layerOrder = masterLayerOrder();
const QList<MapThemeLayerRecord> recs = mMapThemes.value( name ).mLayerRecords;
const QList<QgsMapLayer *> layerOrder = masterLayerOrder();
if ( layerOrder.isEmpty() )
{
// no master layer order - so we have to just use the stored theme layer order as a fallback
const auto records {mMapThemes.value( name ).mLayerRecords};
const QList<MapThemeLayerRecord> records { mMapThemes.value( name ).mLayerRecords };
for ( const MapThemeLayerRecord &layerRec : records )
{
if ( layerRec.isVisible && layerRec.layer() )
@@ -334,11 +333,9 @@ QList<QgsMapLayer *> QgsMapThemeCollection::mapThemeVisibleLayers( const QString
}
else
{
const auto constLayerOrder = layerOrder;
for ( QgsMapLayer *layer : constLayerOrder )
for ( QgsMapLayer *layer : layerOrder )
{
const auto constRecs = recs;
for ( const MapThemeLayerRecord &layerRec : constRecs )
for ( const MapThemeLayerRecord &layerRec : recs )
{
if ( layerRec.isVisible && layerRec.layer() == layer )
layers << layerRec.layer();
@@ -379,7 +376,7 @@ QMap<QString, QString> QgsMapThemeCollection::mapThemeStyleOverrides( const QStr
if ( !mMapThemes.contains( presetName ) )
return styleOverrides;

const auto records {mMapThemes.value( presetName ).mLayerRecords};
const QList<MapThemeLayerRecord> records {mMapThemes.value( presetName ).mLayerRecords};
for ( const MapThemeLayerRecord &layerRec : records )
{
if ( !layerRec.layer() )
@@ -408,8 +405,7 @@ void QgsMapThemeCollection::reconnectToLayersStyleManager()
// disconnect( 0, 0, this, SLOT( layerStyleRenamed( QString, QString ) ) );

QSet<QgsMapLayer *> layers;
const auto constMMapThemes = mMapThemes;
for ( const MapThemeRecord &rec : constMMapThemes )
for ( const MapThemeRecord &rec : qgis::as_const( mMapThemes ) )
{
for ( const MapThemeLayerRecord &layerRec : qgis::as_const( rec.mLayerRecords ) )
{
@@ -418,7 +414,7 @@ void QgsMapThemeCollection::reconnectToLayersStyleManager()
}
}

const auto constLayers = layers;
const QSet<QgsMapLayer *> constLayers = layers;
for ( QgsMapLayer *ml : constLayers )
{
connect( ml->styleManager(), &QgsMapLayerStyleManager::styleRenamed, this, &QgsMapThemeCollection::layerStyleRenamed );
@@ -562,7 +558,7 @@ void QgsMapThemeCollection::writeXml( QDomDocument &doc )
{
QDomElement visPresetsElem = doc.createElement( QStringLiteral( "visibility-presets" ) );

auto keys = mMapThemes.keys();
QList< QString > keys = mMapThemes.keys();

std::sort( keys.begin(), keys.end() );

@@ -668,8 +664,7 @@ void QgsMapThemeCollection::registryLayersRemoved( const QStringList &layerIDs )
}
}

const auto constChangedThemes = changedThemes;
for ( const QString &theme : constChangedThemes )
for ( const QString &theme : qgis::as_const( changedThemes ) )
{
emit mapThemeChanged( theme );
}
@@ -701,8 +696,8 @@ void QgsMapThemeCollection::layerStyleRenamed( const QString &oldName, const QSt
}
}
}
const auto constChangedThemes = changedThemes;
for ( const QString &theme : constChangedThemes )

for ( const QString &theme : qgis::as_const( changedThemes ) )
{
emit mapThemeChanged( theme );
}
@@ -726,8 +721,7 @@ void QgsMapThemeCollection::MapThemeRecord::addLayerRecord( const QgsMapThemeCol
QHash<QgsMapLayer *, QgsMapThemeCollection::MapThemeLayerRecord> QgsMapThemeCollection::MapThemeRecord::validLayerRecords() const
{
QHash<QgsMapLayer *, MapThemeLayerRecord> validSet;
const auto constMLayerRecords = mLayerRecords;
for ( const MapThemeLayerRecord &layerRec : constMLayerRecords )
for ( const MapThemeLayerRecord &layerRec : mLayerRecords )
{
if ( layerRec.layer() )
validSet.insert( layerRec.layer(), layerRec );

0 comments on commit 5240567

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