Navigation Menu

Skip to content

Commit

Permalink
Less auto
Browse files Browse the repository at this point in the history
(cherry picked from commit 1a07654)
(cherry picked from commit 3e05f07)
  • Loading branch information
nyalldawson committed Mar 17, 2020
1 parent b7bc1c3 commit 5240567
Showing 1 changed file with 23 additions and 29 deletions.
52 changes: 23 additions & 29 deletions src/core/qgsmapthemecollection.cpp
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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 ) )
Expand Down Expand Up @@ -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();
Expand All @@ -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 ) &&
Expand All @@ -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 ) )
Expand Down Expand Up @@ -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() )
{
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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() )
Expand All @@ -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();
Expand Down Expand Up @@ -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() )
Expand Down Expand Up @@ -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 ) )
{
Expand All @@ -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 );
Expand Down Expand Up @@ -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() );

Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 );
}
Expand All @@ -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 );
Expand Down

0 comments on commit 5240567

Please sign in to comment.