Skip to content

Commit

Permalink
More core changes
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 5, 2019
1 parent a6665d4 commit 8cdfaa3
Show file tree
Hide file tree
Showing 43 changed files with 137 additions and 77 deletions.
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -1406,6 +1406,8 @@ IF (Qt5Positioning_FOUND)
) )
ENDIF (Qt5Positioning_FOUND) ENDIF (Qt5Positioning_FOUND)


TARGET_COMPILE_DEFINITIONS(qgis_core PRIVATE "-DQT_NO_FOREACH")

# clang-tidy # clang-tidy
IF(CLANG_TIDY_EXE) IF(CLANG_TIDY_EXE)
SET_TARGET_PROPERTIES( SET_TARGET_PROPERTIES(
Expand Down
13 changes: 8 additions & 5 deletions src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -745,7 +745,8 @@ void QgsLayerTreeModel::nodeAddedChildren( QgsLayerTreeNode *node, int indexFrom


endInsertRows(); endInsertRows();


Q_FOREACH ( QgsLayerTreeLayer *newLayerNode, _layerNodesInSubtree( node, indexFrom, indexTo ) ) const auto subNodes = _layerNodesInSubtree( node, indexFrom, indexTo );
for ( QgsLayerTreeLayer *newLayerNode : subNodes )
connectToLayer( newLayerNode ); connectToLayer( newLayerNode );
} }


Expand All @@ -756,7 +757,8 @@ void QgsLayerTreeModel::nodeWillRemoveChildren( QgsLayerTreeNode *node, int inde
beginRemoveRows( node2index( node ), indexFrom, indexTo ); beginRemoveRows( node2index( node ), indexFrom, indexTo );


// disconnect from layers and remove their legend // disconnect from layers and remove their legend
Q_FOREACH ( QgsLayerTreeLayer *nodeLayer, _layerNodesInSubtree( node, indexFrom, indexTo ) ) const auto subNodes = _layerNodesInSubtree( node, indexFrom, indexTo );
for ( QgsLayerTreeLayer *nodeLayer : subNodes )
disconnectFromLayer( nodeLayer ); disconnectFromLayer( nodeLayer );
} }


Expand Down Expand Up @@ -1522,7 +1524,8 @@ QgsLayerTreeModelLegendNode *QgsLayerTreeModel::findLegendNode( const QString &l
QgsLayerTreeLayer *layer = it.key(); QgsLayerTreeLayer *layer = it.key();
if ( layer->layerId() == layerId ) if ( layer->layerId() == layerId )
{ {
Q_FOREACH ( QgsLayerTreeModelLegendNode *legendNode, mLegend.value( layer ).activeNodes ) const auto activeNodes = mLegend.value( layer ).activeNodes;
for ( QgsLayerTreeModelLegendNode *legendNode : activeNodes )
{ {
if ( legendNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString() == ruleKey ) if ( legendNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString() == ruleKey )
{ {
Expand Down Expand Up @@ -1561,7 +1564,7 @@ void QgsLayerTreeModel::invalidateLegendMapBasedData()
{ {
QList<QgsSymbolLegendNode *> symbolNodes; QList<QgsSymbolLegendNode *> symbolNodes;
QMap<QString, int> widthMax; QMap<QString, int> widthMax;
Q_FOREACH ( QgsLayerTreeModelLegendNode *legendNode, data.originalNodes ) for ( QgsLayerTreeModelLegendNode *legendNode : qgis::as_const( data.originalNodes ) )
{ {
QgsSymbolLegendNode *n = qobject_cast<QgsSymbolLegendNode *>( legendNode ); QgsSymbolLegendNode *n = qobject_cast<QgsSymbolLegendNode *>( legendNode );
if ( n ) if ( n )
Expand All @@ -1581,7 +1584,7 @@ void QgsLayerTreeModel::invalidateLegendMapBasedData()
const int twiceMarginWidth = 2; // a one pixel margin avoids hugly rendering of icon const int twiceMarginWidth = 2; // a one pixel margin avoids hugly rendering of icon
n->setIconSize( QSize( widthMax[parentKey] + twiceMarginWidth, n->iconSize().rheight() + twiceMarginWidth ) ); n->setIconSize( QSize( widthMax[parentKey] + twiceMarginWidth, n->iconSize().rheight() + twiceMarginWidth ) );
} }
Q_FOREACH ( QgsLayerTreeModelLegendNode *legendNode, data.originalNodes ) for ( QgsLayerTreeModelLegendNode *legendNode : qgis::as_const( data.originalNodes ) )
legendNode->invalidateMapBasedData(); legendNode->invalidateMapBasedData();
} }


Expand Down
3 changes: 2 additions & 1 deletion src/core/layertree/qgslayertreenode.cpp
Expand Up @@ -37,7 +37,8 @@ QgsLayerTreeNode::QgsLayerTreeNode( const QgsLayerTreeNode &other )
, mProperties( other.mProperties ) , mProperties( other.mProperties )
{ {
QList<QgsLayerTreeNode *> clonedChildren; QList<QgsLayerTreeNode *> clonedChildren;
Q_FOREACH ( QgsLayerTreeNode *child, other.mChildren )
for ( QgsLayerTreeNode *child : qgis::as_const( other.mChildren ) )
clonedChildren << child->clone(); clonedChildren << child->clone();
insertChildrenPrivate( -1, clonedChildren ); insertChildrenPrivate( -1, clonedChildren );
} }
Expand Down
3 changes: 2 additions & 1 deletion src/core/layout/qgslayoutguidecollection.cpp
Expand Up @@ -518,7 +518,8 @@ void QgsLayoutGuideCollection::setVisible( bool visible )
void QgsLayoutGuideCollection::pageAboutToBeRemoved( int pageNumber ) void QgsLayoutGuideCollection::pageAboutToBeRemoved( int pageNumber )
{ {
mBlockUndoCommands = true; mBlockUndoCommands = true;
Q_FOREACH ( QgsLayoutGuide *guide, guidesOnPage( pageNumber ) ) const auto constGuidesOnPage = guidesOnPage( pageNumber );
for ( QgsLayoutGuide *guide : constGuidesOnPage )
{ {
removeGuide( guide ); removeGuide( guide );
} }
Expand Down
3 changes: 2 additions & 1 deletion src/core/layout/qgslayoutsnapper.cpp
Expand Up @@ -282,7 +282,8 @@ double QgsLayoutSnapper::snapPointsToGuides( const QList<double> &points, Qt::Or


for ( double p : points ) for ( double p : points )
{ {
Q_FOREACH ( QgsLayoutGuide *guide, mLayout->guides().guides( orientation ) ) const auto constGuides = mLayout->guides().guides( orientation );
for ( QgsLayoutGuide *guide : constGuides )
{ {
double guidePos = guide->layoutPosition(); double guidePos = guide->layoutPosition();
double diff = std::fabs( p - guidePos ); double diff = std::fabs( p - guidePos );
Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/feature.cpp
Expand Up @@ -67,7 +67,7 @@ FeaturePart::FeaturePart( const FeaturePart &other )
: PointSet( other ) : PointSet( other )
, mLF( other.mLF ) , mLF( other.mLF )
{ {
Q_FOREACH ( const FeaturePart *hole, other.mHoles ) for ( const FeaturePart *hole : qgis::as_const( other.mHoles ) )
{ {
mHoles << new FeaturePart( *hole ); mHoles << new FeaturePart( *hole );
mHoles.last()->holeOf = this; mHoles.last()->holeOf = this;
Expand Down
6 changes: 4 additions & 2 deletions src/core/pal/pal.cpp
Expand Up @@ -333,7 +333,8 @@ std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeom


if ( isCanceled() ) if ( isCanceled() )
{ {
Q_FOREACH ( Feats *feat, *fFeats ) const auto constFFeats = *fFeats;
for ( Feats *feat : constFFeats )
{ {
qDeleteAll( feat->lPos ); qDeleteAll( feat->lPos );
feat->lPos.clear(); feat->lPos.clear();
Expand Down Expand Up @@ -397,7 +398,8 @@ std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeom
{ {
if ( isCanceled() ) if ( isCanceled() )
{ {
Q_FOREACH ( Feats *feat, *fFeats ) const auto constFFeats = *fFeats;
for ( Feats *feat : constFFeats )
{ {
qDeleteAll( feat->lPos ); qDeleteAll( feat->lPos );
feat->lPos.clear(); feat->lPos.clear();
Expand Down
12 changes: 8 additions & 4 deletions src/core/processing/models/qgsprocessingmodelalgorithm.cpp
Expand Up @@ -268,7 +268,8 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
continue; continue;


bool canExecute = true; bool canExecute = true;
Q_FOREACH ( const QString &dependency, dependsOnChildAlgorithms( childId ) ) const auto constDependsOnChildAlgorithms = dependsOnChildAlgorithms( childId );
for ( const QString &dependency : constDependsOnChildAlgorithms )
{ {
if ( !executed.contains( dependency ) ) if ( !executed.contains( dependency ) )
{ {
Expand Down Expand Up @@ -510,7 +511,8 @@ QStringList QgsProcessingModelAlgorithm::asPythonCode( const QgsProcessing::Pyth
continue; continue;


bool canExecute = true; bool canExecute = true;
Q_FOREACH ( const QString &dependency, dependsOnChildAlgorithms( childId ) ) const auto constDependsOnChildAlgorithms = dependsOnChildAlgorithms( childId );
for ( const QString &dependency : constDependsOnChildAlgorithms )
{ {
if ( !executed.contains( dependency ) ) if ( !executed.contains( dependency ) )
{ {
Expand Down Expand Up @@ -1239,7 +1241,8 @@ bool QgsProcessingModelAlgorithm::removeChildAlgorithm( const QString &id )


void QgsProcessingModelAlgorithm::deactivateChildAlgorithm( const QString &id ) void QgsProcessingModelAlgorithm::deactivateChildAlgorithm( const QString &id )
{ {
Q_FOREACH ( const QString &child, dependentChildAlgorithms( id ) ) const auto constDependentChildAlgorithms = dependentChildAlgorithms( id );
for ( const QString &child : constDependentChildAlgorithms )
{ {
childAlgorithm( child ).setActive( false ); childAlgorithm( child ).setActive( false );
} }
Expand All @@ -1249,7 +1252,8 @@ void QgsProcessingModelAlgorithm::deactivateChildAlgorithm( const QString &id )


bool QgsProcessingModelAlgorithm::activateChildAlgorithm( const QString &id ) bool QgsProcessingModelAlgorithm::activateChildAlgorithm( const QString &id )
{ {
Q_FOREACH ( const QString &child, dependsOnChildAlgorithms( id ) ) const auto constDependsOnChildAlgorithms = dependsOnChildAlgorithms( id );
for ( const QString &child : constDependsOnChildAlgorithms )
{ {
if ( !childAlgorithm( child ).isActive() ) if ( !childAlgorithm( child ).isActive() )
return false; return false;
Expand Down
9 changes: 6 additions & 3 deletions src/core/processing/qgsprocessingparameters.cpp
Expand Up @@ -293,7 +293,8 @@ QList<int> QgsProcessingParameters::parameterAsEnums( const QgsProcessingParamet
} }
else if ( val.type() == QVariant::String ) else if ( val.type() == QVariant::String )
{ {
Q_FOREACH ( const QString &var, val.toString().split( ',' ) ) const auto constSplit = val.toString().split( ',' );
for ( const QString &var : constSplit )
resultList << var; resultList << var;
} }
else else
Expand All @@ -314,7 +315,8 @@ QList<int> QgsProcessingParameters::parameterAsEnums( const QgsProcessingParamet
} }
else if ( definition->defaultValue().type() == QVariant::String ) else if ( definition->defaultValue().type() == QVariant::String )
{ {
Q_FOREACH ( const QString &var, definition->defaultValue().toString().split( ',' ) ) const auto constSplit = definition->defaultValue().toString().split( ',' );
for ( const QString &var : constSplit )
resultList << var; resultList << var;
} }
else else
Expand Down Expand Up @@ -1283,7 +1285,8 @@ QVariantList QgsProcessingParameters::parameterAsMatrix( const QgsProcessingPara
} }


QVariantList result; QVariantList result;
Q_FOREACH ( const QString &s, resultString.split( ',' ) ) const auto constSplit = resultString.split( ',' );
for ( const QString &s : constSplit )
result << s; result << s;


return result; return result;
Expand Down
11 changes: 7 additions & 4 deletions src/core/qgsapplication.cpp
Expand Up @@ -659,7 +659,8 @@ QString QgsApplication::resolvePkgPath()
// check if QGIS is run from build directory (not the install directory) // check if QGIS is run from build directory (not the install directory)
QFile f; QFile f;
// "/../../.." is for Mac bundled app in build directory // "/../../.." is for Mac bundled app in build directory
Q_FOREACH ( const QString &path, QStringList() << "" << "/.." << "/bin" << "/../../.." ) static const QStringList paths { QStringList() << QString() << QStringLiteral( "/.." ) << QStringLiteral( "/bin" ) << QStringLiteral( "/../../.." ) };
for ( const QString &path : paths )
{ {
f.setFileName( prefix + path + "/qgisbuildpath.txt" ); f.setFileName( prefix + path + "/qgisbuildpath.txt" );
if ( f.exists() ) if ( f.exists() )
Expand Down Expand Up @@ -951,7 +952,7 @@ QStringList QgsApplication::svgPaths()
if ( !paths.contains( path ) ) if ( !paths.contains( path ) )
paths.append( path ); paths.append( path );
} }
Q_FOREACH ( const QString &path, ABISYM( mDefaultSvgPaths ) ) for ( const QString &path : qgis::as_const( ABISYM( mDefaultSvgPaths ) ) )
{ {
if ( !paths.contains( path ) ) if ( !paths.contains( path ) )
paths.append( path ); paths.append( path );
Expand Down Expand Up @@ -1512,14 +1513,16 @@ void QgsApplication::copyPath( const QString &src, const QString &dst )
if ( ! dir.exists() ) if ( ! dir.exists() )
return; return;


Q_FOREACH ( const QString &d, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) ) const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
for ( const QString &d : subDirectories )
{ {
QString dst_path = dst + QDir::separator() + d; QString dst_path = dst + QDir::separator() + d;
dir.mkpath( dst_path ); dir.mkpath( dst_path );
copyPath( src + QDir::separator() + d, dst_path ); copyPath( src + QDir::separator() + d, dst_path );
} }


Q_FOREACH ( const QString &f, dir.entryList( QDir::Files ) ) const auto files = dir.entryList( QDir::Files );
for ( const QString &f : files )
{ {
QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f ); QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
} }
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsbrowsermodel.cpp
Expand Up @@ -102,7 +102,8 @@ void QgsBrowserModel::addRootItems()
} }


// add drives // add drives
Q_FOREACH ( const QFileInfo &drive, QDir::drives() ) const auto drives { QDir::drives() };
for ( const QFileInfo &drive : drives )
{ {
const QString path = drive.absolutePath(); const QString path = drive.absolutePath();


Expand Down
3 changes: 2 additions & 1 deletion src/core/qgscolorramp.cpp
Expand Up @@ -64,7 +64,8 @@ QgsColorRamp *QgsGradientColorRamp::create( const QgsStringMap &props )
QgsGradientStopsList stops; QgsGradientStopsList stops;
if ( props.contains( QStringLiteral( "stops" ) ) ) if ( props.contains( QStringLiteral( "stops" ) ) )
{ {
Q_FOREACH ( const QString &stop, props["stops"].split( ':' ) ) const auto constSplit = props["stops"].split( ':' );
for ( const QString &stop : constSplit )
{ {
int i = stop.indexOf( ';' ); int i = stop.indexOf( ';' );
if ( i == -1 ) if ( i == -1 )
Expand Down
9 changes: 6 additions & 3 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -789,7 +789,8 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
// also with parameters containing spaces (e.g. +nadgrids) // also with parameters containing spaces (e.g. +nadgrids)
// make sure result is trimmed (#5598) // make sure result is trimmed (#5598)
QStringList myParams; QStringList myParams;
Q_FOREACH ( const QString &param, myProj4String.split( QRegExp( "\\s+(?=\\+)" ), QString::SkipEmptyParts ) ) const auto constSplit = myProj4String.split( QRegExp( "\\s+(?=\\+)" ), QString::SkipEmptyParts );
for ( const QString &param : constSplit )
{ {
QString arg = QStringLiteral( "' '||parameters||' ' LIKE %1" ).arg( QgsSqliteUtils::quotedString( QStringLiteral( "% %1 %" ).arg( param.trimmed() ) ) ); QString arg = QStringLiteral( "' '||parameters||' ' LIKE %1" ).arg( QgsSqliteUtils::quotedString( QStringLiteral( "% %1 %" ).arg( param.trimmed() ) ) );
if ( param.startsWith( QLatin1String( "+datum=" ) ) ) if ( param.startsWith( QLatin1String( "+datum=" ) ) )
Expand Down Expand Up @@ -819,7 +820,8 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
{ {
// Bugfix 8487 : test param lists are equal, except for +datum // Bugfix 8487 : test param lists are equal, except for +datum
QStringList foundParams; QStringList foundParams;
Q_FOREACH ( const QString &param, myRecord["parameters"].split( QRegExp( "\\s+(?=\\+)" ), QString::SkipEmptyParts ) ) const auto constSplit = myRecord["parameters"].split( QRegExp( "\\s+(?=\\+)" ), QString::SkipEmptyParts );
for ( const QString &param : constSplit )
{ {
if ( !param.startsWith( QLatin1String( "+datum=" ) ) ) if ( !param.startsWith( QLatin1String( "+datum=" ) ) )
foundParams << param.trimmed(); foundParams << param.trimmed();
Expand Down Expand Up @@ -1772,7 +1774,8 @@ bool QgsCoordinateReferenceSystem::loadIds( QHash<int, QString> &wkts )
{ {
OGRSpatialReferenceH crs = OSRNewSpatialReference( nullptr ); OGRSpatialReferenceH crs = OSRNewSpatialReference( nullptr );


Q_FOREACH ( const QString &csv, QStringList() << "gcs.csv" << "pcs.csv" << "vertcs.csv" << "compdcs.csv" << "geoccs.csv" ) static const QStringList csvs { QStringList() << QStringLiteral( "gcs.csv" ) << QStringLiteral( "pcs.csv" ) << QStringLiteral( "vertcs.csv" ) << QStringLiteral( "compdcs.csv" ) << QStringLiteral( "geoccs.csv" ) };
for ( const QString &csv : csvs )
{ {
QString filename = CPLFindFile( "gdal", csv.toUtf8() ); QString filename = CPLFindFile( "gdal", csv.toUtf8() );


Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsdatadefinedsizelegend.cpp
Expand Up @@ -87,7 +87,8 @@ void QgsDataDefinedSizeLegend::updateFromSymbolAndProperty( const QgsMarkerSymbo
if ( sizeTransformer && mSizeClasses.isEmpty() ) if ( sizeTransformer && mSizeClasses.isEmpty() )
{ {
mSizeClasses.clear(); mSizeClasses.clear();
Q_FOREACH ( double v, QgsSymbolLayerUtils::prettyBreaks( sizeTransformer->minValue(), sizeTransformer->maxValue(), 4 ) ) const auto prettyBreaks { QgsSymbolLayerUtils::prettyBreaks( sizeTransformer->minValue(), sizeTransformer->maxValue(), 4 ) };
for ( double v : prettyBreaks )
{ {
mSizeClasses << SizeClass( v, QString::number( v ) ); mSizeClasses << SizeClass( v, QString::number( v ) );
} }
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsdiagramrenderer.cpp
Expand Up @@ -780,7 +780,8 @@ QList< QgsLayerTreeModelLegendNode * > QgsLinearlyInterpolatedDiagramRenderer::l
if ( ddSizeLegend.classes().isEmpty() ) if ( ddSizeLegend.classes().isEmpty() )
{ {
// automatic class creation if the classes are not defined manually // automatic class creation if the classes are not defined manually
Q_FOREACH ( double v, QgsSymbolLayerUtils::prettyBreaks( mInterpolationSettings.lowerValue, mInterpolationSettings.upperValue, 4 ) ) const auto prettyBreaks { QgsSymbolLayerUtils::prettyBreaks( mInterpolationSettings.lowerValue, mInterpolationSettings.upperValue, 4 ) };
for ( double v : prettyBreaks )
{ {
double size = mDiagram->legendSize( v, mSettings, mInterpolationSettings ); double size = mDiagram->legendSize( v, mSettings, mInterpolationSettings );
sizeClasses << QgsDataDefinedSizeLegend::SizeClass( size, QString::number( v ) ); sizeClasses << QgsDataDefinedSizeLegend::SizeClass( size, QString::number( v ) );
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsexpressioncontext.cpp
Expand Up @@ -239,7 +239,7 @@ QgsExpressionContext::QgsExpressionContext( const QList<QgsExpressionContextScop


QgsExpressionContext::QgsExpressionContext( const QgsExpressionContext &other ) QgsExpressionContext::QgsExpressionContext( const QgsExpressionContext &other )
{ {
Q_FOREACH ( const QgsExpressionContextScope *scope, other.mStack ) for ( const QgsExpressionContextScope *scope : qgis::as_const( other.mStack ) )
{ {
mStack << new QgsExpressionContextScope( *scope ); mStack << new QgsExpressionContextScope( *scope );
} }
Expand Down Expand Up @@ -268,7 +268,7 @@ QgsExpressionContext &QgsExpressionContext::operator=( const QgsExpressionContex
{ {
qDeleteAll( mStack ); qDeleteAll( mStack );
mStack.clear(); mStack.clear();
Q_FOREACH ( const QgsExpressionContextScope *scope, other.mStack ) for ( const QgsExpressionContextScope *scope : qgis::as_const( other.mStack ) )
{ {
mStack << new QgsExpressionContextScope( *scope ); mStack << new QgsExpressionContextScope( *scope );
} }
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsfeaturefiltermodel.cpp
Expand Up @@ -382,7 +382,8 @@ QSet<QString> QgsFeatureFilterModel::requestedAttributes() const
if ( mDisplayExpression.isField() ) if ( mDisplayExpression.isField() )
{ {
QString fieldName = *mDisplayExpression.referencedColumns().constBegin(); QString fieldName = *mDisplayExpression.referencedColumns().constBegin();
Q_FOREACH ( const QgsConditionalStyle &style, mSourceLayer->conditionalStyles()->fieldStyles( fieldName ) ) const auto constFieldStyles = mSourceLayer->conditionalStyles()->fieldStyles( fieldName );
for ( const QgsConditionalStyle &style : constFieldStyles )
{ {
QgsExpression exp( style.rule() ); QgsExpression exp( style.rule() );
requestedAttrs += exp.referencedColumns(); requestedAttrs += exp.referencedColumns();
Expand Down
6 changes: 4 additions & 2 deletions src/core/qgsfontutils.cpp
Expand Up @@ -165,7 +165,8 @@ bool QgsFontUtils::updateFontViaStyle( QFont &f, const QString &fontstyle, bool
testFont.setPointSize( defaultSize ); testFont.setPointSize( defaultSize );


// prefer a style that mostly matches the passed-in font // prefer a style that mostly matches the passed-in font
Q_FOREACH ( const QString &style, fontDB.styles( f.family() ) ) const auto constFamily = fontDB.styles( f.family() );
for ( const QString &style : constFamily )
{ {
styledfont = fontDB.font( f.family(), style, defaultSize ); styledfont = fontDB.font( f.family(), style, defaultSize );
styledfont = styledfont.resolve( f ); styledfont = styledfont.resolve( f );
Expand All @@ -179,7 +180,8 @@ bool QgsFontUtils::updateFontViaStyle( QFont &f, const QString &fontstyle, bool
// fallback to first style found that works // fallback to first style found that works
if ( !foundmatch ) if ( !foundmatch )
{ {
Q_FOREACH ( const QString &style, fontDB.styles( f.family() ) ) const auto constFamily = fontDB.styles( f.family() );
for ( const QString &style : constFamily )
{ {
styledfont = fontDB.font( f.family(), style, defaultSize ); styledfont = fontDB.font( f.family(), style, defaultSize );
if ( QApplication::font() != styledfont ) if ( QApplication::font() != styledfont )
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgslayerdefinition.cpp
Expand Up @@ -385,7 +385,8 @@ void QgsLayerDefinition::DependencySorter::init( const QDomDocument &doc )
QDomNode node = it->second; QDomNode node = it->second;
mHasCycle = true; mHasCycle = true;
bool resolved = true; bool resolved = true;
Q_FOREACH ( const QString &dep, dependencies[idToSort] ) const auto deps { dependencies.value( idToSort ) };
for ( const QString &dep : deps )
{ {
if ( !sortedLayers.contains( dep ) ) if ( !sortedLayers.contains( dep ) )
{ {
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgslegendrenderer.cpp
Expand Up @@ -555,7 +555,7 @@ QSizeF QgsLegendRenderer::drawAtomInternal( const Atom &atom, QgsRenderContext *
{ {
bool first = true; bool first = true;
QSizeF size = QSizeF( atom.size ); QSizeF size = QSizeF( atom.size );
Q_FOREACH ( const Nucleon &nucleon, atom.nucleons ) for ( const Nucleon &nucleon : qgis::as_const( atom.nucleons ) )
{ {
if ( QgsLayerTreeGroup *groupItem = qobject_cast<QgsLayerTreeGroup *>( nucleon.item ) ) if ( QgsLayerTreeGroup *groupItem = qobject_cast<QgsLayerTreeGroup *>( nucleon.item ) )
{ {
Expand Down
6 changes: 4 additions & 2 deletions src/core/qgsmaphittest.cpp
Expand Up @@ -173,14 +173,16 @@ void QgsMapHitTest::runHitTestLayer( QgsVectorLayer *vl, SymbolSet &usedSymbols,


//make sure we store string representation of symbol, not pointer //make sure we store string representation of symbol, not pointer
//otherwise layer style override changes will delete original symbols and leave hanging pointers //otherwise layer style override changes will delete original symbols and leave hanging pointers
Q_FOREACH ( const QString &legendKey, r->legendKeysForFeature( f, context ) ) const auto constLegendKeysForFeature = r->legendKeysForFeature( f, context );
for ( const QString &legendKey : constLegendKeysForFeature )
{ {
lUsedSymbolsRuleKey.insert( legendKey ); lUsedSymbolsRuleKey.insert( legendKey );
} }


if ( moreSymbolsPerFeature ) if ( moreSymbolsPerFeature )
{ {
Q_FOREACH ( QgsSymbol *s, r->originalSymbolsForFeature( f, context ) ) const auto constOriginalSymbolsForFeature = r->originalSymbolsForFeature( f, context );
for ( QgsSymbol *s : constOriginalSymbolsForFeature )
{ {
if ( s ) if ( s )
lUsedSymbols.insert( QgsSymbolLayerUtils::symbolProperties( s ) ); lUsedSymbols.insert( QgsSymbolLayerUtils::symbolProperties( s ) );
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsmaplayer.cpp
Expand Up @@ -1848,7 +1848,8 @@ static bool _depHasCycleDFS( const QgsMapLayer *n, QHash<const QgsMapLayer *, in
if ( mark.value( n ) == 0 ) // not visited if ( mark.value( n ) == 0 ) // not visited
{ {
mark[n] = 1; // temporary mark[n] = 1; // temporary
Q_FOREACH ( const QgsMapLayer *m, _depOutEdges( n, that, layers ) ) const auto depOutEdges { _depOutEdges( n, that, layers ) };
for ( const QgsMapLayer *m : depOutEdges )
{ {
if ( _depHasCycleDFS( m, mark, that, layers ) ) if ( _depHasCycleDFS( m, mark, that, layers ) )
return true; return true;
Expand Down

0 comments on commit 8cdfaa3

Please sign in to comment.