Skip to content
Permalink
Browse files

More core changes

  • Loading branch information
m-kuhn committed Apr 5, 2019
1 parent a6665d4 commit 8cdfaa395f655ff4b1c1321ee697a735b72999cb
Showing with 137 additions and 77 deletions.
  1. +2 −0 src/core/CMakeLists.txt
  2. +8 −5 src/core/layertree/qgslayertreemodel.cpp
  3. +2 −1 src/core/layertree/qgslayertreenode.cpp
  4. +2 −1 src/core/layout/qgslayoutguidecollection.cpp
  5. +2 −1 src/core/layout/qgslayoutsnapper.cpp
  6. +1 −1 src/core/pal/feature.cpp
  7. +4 −2 src/core/pal/pal.cpp
  8. +8 −4 src/core/processing/models/qgsprocessingmodelalgorithm.cpp
  9. +6 −3 src/core/processing/qgsprocessingparameters.cpp
  10. +7 −4 src/core/qgsapplication.cpp
  11. +2 −1 src/core/qgsbrowsermodel.cpp
  12. +2 −1 src/core/qgscolorramp.cpp
  13. +6 −3 src/core/qgscoordinatereferencesystem.cpp
  14. +2 −1 src/core/qgsdatadefinedsizelegend.cpp
  15. +2 −1 src/core/qgsdiagramrenderer.cpp
  16. +2 −2 src/core/qgsexpressioncontext.cpp
  17. +2 −1 src/core/qgsfeaturefiltermodel.cpp
  18. +4 −2 src/core/qgsfontutils.cpp
  19. +2 −1 src/core/qgslayerdefinition.cpp
  20. +1 −1 src/core/qgslegendrenderer.cpp
  21. +4 −2 src/core/qgsmaphittest.cpp
  22. +2 −1 src/core/qgsmaplayer.cpp
  23. +4 −2 src/core/qgsmaplayerlegend.cpp
  24. +2 −1 src/core/qgsmaprenderercache.cpp
  25. +16 −10 src/core/qgsmapthemecollection.cpp
  26. +2 −1 src/core/qgspointlocator.cpp
  27. +2 −2 src/core/qgspropertycollection.cpp
  28. +2 −1 src/core/qgsrelationmanager.cpp
  29. +2 −1 src/core/qgssqlstatement.cpp
  30. +5 −3 src/core/qgstaskmanager.cpp
  31. +1 −1 src/core/qgstracer.cpp
  32. +2 −1 src/core/qgsvectordataprovider.cpp
  33. +2 −1 src/core/qgsvectorfilewriter.cpp
  34. +2 −1 src/core/qgsvectorlayerjoinbuffer.cpp
  35. +2 −1 src/core/qgsvirtuallayerdefinitionutils.cpp
  36. +2 −1 src/core/raster/qgsrasterlayer.cpp
  37. +2 −1 src/core/symbology/qgscptcityarchive.cpp
  38. +2 −2 src/core/symbology/qgsgraduatedsymbolrenderer.cpp
  39. +1 −1 src/core/symbology/qgsinvertedpolygonrenderer.cpp
  40. +2 −1 src/core/symbology/qgspointdistancerenderer.cpp
  41. +2 −1 src/core/symbology/qgsrenderer.cpp
  42. +1 −1 src/core/symbology/qgsrulebasedrenderer.cpp
  43. +8 −4 src/core/symbology/qgssymbollayerutils.cpp
@@ -1406,6 +1406,8 @@ IF (Qt5Positioning_FOUND)
)
ENDIF (Qt5Positioning_FOUND)

TARGET_COMPILE_DEFINITIONS(qgis_core PRIVATE "-DQT_NO_FOREACH")

# clang-tidy
IF(CLANG_TIDY_EXE)
SET_TARGET_PROPERTIES(
@@ -745,7 +745,8 @@ void QgsLayerTreeModel::nodeAddedChildren( QgsLayerTreeNode *node, int indexFrom

endInsertRows();

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

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

// 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 );
}

@@ -1522,7 +1524,8 @@ QgsLayerTreeModelLegendNode *QgsLayerTreeModel::findLegendNode( const QString &l
QgsLayerTreeLayer *layer = it.key();
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 )
{
@@ -1561,7 +1564,7 @@ void QgsLayerTreeModel::invalidateLegendMapBasedData()
{
QList<QgsSymbolLegendNode *> symbolNodes;
QMap<QString, int> widthMax;
Q_FOREACH ( QgsLayerTreeModelLegendNode *legendNode, data.originalNodes )
for ( QgsLayerTreeModelLegendNode *legendNode : qgis::as_const( data.originalNodes ) )
{
QgsSymbolLegendNode *n = qobject_cast<QgsSymbolLegendNode *>( legendNode );
if ( n )
@@ -1581,7 +1584,7 @@ void QgsLayerTreeModel::invalidateLegendMapBasedData()
const int twiceMarginWidth = 2; // a one pixel margin avoids hugly rendering of icon
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();
}

@@ -37,7 +37,8 @@ QgsLayerTreeNode::QgsLayerTreeNode( const QgsLayerTreeNode &other )
, mProperties( other.mProperties )
{
QList<QgsLayerTreeNode *> clonedChildren;
Q_FOREACH ( QgsLayerTreeNode *child, other.mChildren )

for ( QgsLayerTreeNode *child : qgis::as_const( other.mChildren ) )
clonedChildren << child->clone();
insertChildrenPrivate( -1, clonedChildren );
}
@@ -518,7 +518,8 @@ void QgsLayoutGuideCollection::setVisible( bool visible )
void QgsLayoutGuideCollection::pageAboutToBeRemoved( int pageNumber )
{
mBlockUndoCommands = true;
Q_FOREACH ( QgsLayoutGuide *guide, guidesOnPage( pageNumber ) )
const auto constGuidesOnPage = guidesOnPage( pageNumber );
for ( QgsLayoutGuide *guide : constGuidesOnPage )
{
removeGuide( guide );
}
@@ -282,7 +282,8 @@ double QgsLayoutSnapper::snapPointsToGuides( const QList<double> &points, Qt::Or

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 diff = std::fabs( p - guidePos );
@@ -67,7 +67,7 @@ FeaturePart::FeaturePart( const FeaturePart &other )
: PointSet( other )
, mLF( other.mLF )
{
Q_FOREACH ( const FeaturePart *hole, other.mHoles )
for ( const FeaturePart *hole : qgis::as_const( other.mHoles ) )
{
mHoles << new FeaturePart( *hole );
mHoles.last()->holeOf = this;
@@ -333,7 +333,8 @@ std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeom

if ( isCanceled() )
{
Q_FOREACH ( Feats *feat, *fFeats )
const auto constFFeats = *fFeats;
for ( Feats *feat : constFFeats )
{
qDeleteAll( feat->lPos );
feat->lPos.clear();
@@ -397,7 +398,8 @@ std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeom
{
if ( isCanceled() )
{
Q_FOREACH ( Feats *feat, *fFeats )
const auto constFFeats = *fFeats;
for ( Feats *feat : constFFeats )
{
qDeleteAll( feat->lPos );
feat->lPos.clear();
@@ -268,7 +268,8 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
continue;

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

bool canExecute = true;
Q_FOREACH ( const QString &dependency, dependsOnChildAlgorithms( childId ) )
const auto constDependsOnChildAlgorithms = dependsOnChildAlgorithms( childId );
for ( const QString &dependency : constDependsOnChildAlgorithms )
{
if ( !executed.contains( dependency ) )
{
@@ -1239,7 +1241,8 @@ bool QgsProcessingModelAlgorithm::removeChildAlgorithm( 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 );
}
@@ -1249,7 +1252,8 @@ void QgsProcessingModelAlgorithm::deactivateChildAlgorithm( 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() )
return false;
@@ -293,7 +293,8 @@ QList<int> QgsProcessingParameters::parameterAsEnums( const QgsProcessingParamet
}
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;
}
else
@@ -314,7 +315,8 @@ QList<int> QgsProcessingParameters::parameterAsEnums( const QgsProcessingParamet
}
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;
}
else
@@ -1283,7 +1285,8 @@ QVariantList QgsProcessingParameters::parameterAsMatrix( const QgsProcessingPara
}

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

return result;
@@ -659,7 +659,8 @@ QString QgsApplication::resolvePkgPath()
// check if QGIS is run from build directory (not the install directory)
QFile f;
// "/../../.." 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" );
if ( f.exists() )
@@ -951,7 +952,7 @@ QStringList QgsApplication::svgPaths()
if ( !paths.contains( path ) )
paths.append( path );
}
Q_FOREACH ( const QString &path, ABISYM( mDefaultSvgPaths ) )
for ( const QString &path : qgis::as_const( ABISYM( mDefaultSvgPaths ) ) )
{
if ( !paths.contains( path ) )
paths.append( path );
@@ -1512,14 +1513,16 @@ void QgsApplication::copyPath( const QString &src, const QString &dst )
if ( ! dir.exists() )
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;
dir.mkpath( 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 );
}
@@ -102,7 +102,8 @@ void QgsBrowserModel::addRootItems()
}

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

@@ -64,7 +64,8 @@ QgsColorRamp *QgsGradientColorRamp::create( const QgsStringMap &props )
QgsGradientStopsList 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( ';' );
if ( i == -1 )
@@ -789,7 +789,8 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
// also with parameters containing spaces (e.g. +nadgrids)
// make sure result is trimmed (#5598)
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() ) ) );
if ( param.startsWith( QLatin1String( "+datum=" ) ) )
@@ -819,7 +820,8 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
{
// Bugfix 8487 : test param lists are equal, except for +datum
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=" ) ) )
foundParams << param.trimmed();
@@ -1772,7 +1774,8 @@ bool QgsCoordinateReferenceSystem::loadIds( QHash<int, QString> &wkts )
{
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() );

@@ -87,7 +87,8 @@ void QgsDataDefinedSizeLegend::updateFromSymbolAndProperty( const QgsMarkerSymbo
if ( sizeTransformer && mSizeClasses.isEmpty() )
{
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 ) );
}
@@ -780,7 +780,8 @@ QList< QgsLayerTreeModelLegendNode * > QgsLinearlyInterpolatedDiagramRenderer::l
if ( ddSizeLegend.classes().isEmpty() )
{
// 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 );
sizeClasses << QgsDataDefinedSizeLegend::SizeClass( size, QString::number( v ) );
@@ -239,7 +239,7 @@ QgsExpressionContext::QgsExpressionContext( const QList<QgsExpressionContextScop

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 );
}
@@ -268,7 +268,7 @@ QgsExpressionContext &QgsExpressionContext::operator=( const QgsExpressionContex
{
qDeleteAll( mStack );
mStack.clear();
Q_FOREACH ( const QgsExpressionContextScope *scope, other.mStack )
for ( const QgsExpressionContextScope *scope : qgis::as_const( other.mStack ) )
{
mStack << new QgsExpressionContextScope( *scope );
}
@@ -382,7 +382,8 @@ QSet<QString> QgsFeatureFilterModel::requestedAttributes() const
if ( mDisplayExpression.isField() )
{
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() );
requestedAttrs += exp.referencedColumns();
@@ -165,7 +165,8 @@ bool QgsFontUtils::updateFontViaStyle( QFont &f, const QString &fontstyle, bool
testFont.setPointSize( defaultSize );

// 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 = styledfont.resolve( f );
@@ -179,7 +180,8 @@ bool QgsFontUtils::updateFontViaStyle( QFont &f, const QString &fontstyle, bool
// fallback to first style found that works
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 );
if ( QApplication::font() != styledfont )
@@ -385,7 +385,8 @@ void QgsLayerDefinition::DependencySorter::init( const QDomDocument &doc )
QDomNode node = it->second;
mHasCycle = 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 ) )
{
@@ -555,7 +555,7 @@ QSizeF QgsLegendRenderer::drawAtomInternal( const Atom &atom, QgsRenderContext *
{
bool first = true;
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 ) )
{
@@ -173,14 +173,16 @@ void QgsMapHitTest::runHitTestLayer( QgsVectorLayer *vl, SymbolSet &usedSymbols,

//make sure we store string representation of symbol, not pointer
//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 );
}

if ( moreSymbolsPerFeature )
{
Q_FOREACH ( QgsSymbol *s, r->originalSymbolsForFeature( f, context ) )
const auto constOriginalSymbolsForFeature = r->originalSymbolsForFeature( f, context );
for ( QgsSymbol *s : constOriginalSymbolsForFeature )
{
if ( s )
lUsedSymbols.insert( QgsSymbolLayerUtils::symbolProperties( s ) );
@@ -1848,7 +1848,8 @@ static bool _depHasCycleDFS( const QgsMapLayer *n, QHash<const QgsMapLayer *, in
if ( mark.value( n ) == 0 ) // not visited
{
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 ) )
return true;

0 comments on commit 8cdfaa3

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