Skip to content
Permalink
Browse files

Remove redundant qgis::as_const implementation, move to c++17 std::as…

…_const
  • Loading branch information
nyalldawson committed Mar 20, 2021
1 parent 98ebd40 commit 876ee57f513d833917aeceefe46fa2efde37cb80
Showing 320 changed files with 1,153 additions and 976 deletions.
@@ -250,7 +250,7 @@ int Qgs3DMapScene::terrainPendingJobsCount() const
int Qgs3DMapScene::totalPendingJobsCount() const
{
int count = 0;
for ( QgsChunkedEntity *entity : qgis::as_const( mChunkEntities ) )
for ( QgsChunkedEntity *entity : std::as_const( mChunkEntities ) )
count += entity->pendingJobsCount();
return count;
}
@@ -295,7 +295,7 @@ void Qgs3DMapScene::onLayerEntityPickedObject( Qt3DRender::QPickEvent *pickEvent
if ( !vlayer )
return;

for ( Qgs3DMapScenePickHandler *pickHandler : qgis::as_const( mPickHandlers ) )
for ( Qgs3DMapScenePickHandler *pickHandler : std::as_const( mPickHandlers ) )
{
pickHandler->handlePickOnVectorLayer( vlayer, fid, pickEvent->worldIntersection(), pickEvent );
}
@@ -383,7 +383,7 @@ void addQLayerComponentsToHierarchy( Qt3DCore::QEntity *entity, const QVector<Qt
void Qgs3DMapScene::updateScene()
{
QgsEventTracing::addEvent( QgsEventTracing::Instant, QStringLiteral( "3D" ), QStringLiteral( "Update Scene" ) );
for ( QgsChunkedEntity *entity : qgis::as_const( mChunkEntities ) )
for ( QgsChunkedEntity *entity : std::as_const( mChunkEntities ) )
{
if ( entity->isEnabled() )
entity->update( _sceneState( mCameraController ) );
@@ -447,7 +447,7 @@ bool Qgs3DMapScene::updateCameraNearFarPlanes()

// Also involve all the other chunked entities to make sure that they will not get
// clipped by the near or far plane
for ( QgsChunkedEntity *e : qgis::as_const( mChunkEntities ) )
for ( QgsChunkedEntity *e : std::as_const( mChunkEntities ) )
{
if ( e != mTerrain )
_updateNearFarPlane( e->activeNodes(), viewMatrix, fnear, ffar );
@@ -485,7 +485,7 @@ void Qgs3DMapScene::onFrameTriggered( float dt )
{
mCameraController->frameTriggered( dt );

for ( QgsChunkedEntity *entity : qgis::as_const( mChunkEntities ) )
for ( QgsChunkedEntity *entity : std::as_const( mChunkEntities ) )
{
if ( entity->isEnabled() && entity->needsUpdate() )
{
@@ -585,10 +585,10 @@ void Qgs3DMapScene::onBackgroundColorChanged()

void Qgs3DMapScene::updateLights()
{
for ( Qt3DCore::QEntity *entity : qgis::as_const( mLightEntities ) )
for ( Qt3DCore::QEntity *entity : std::as_const( mLightEntities ) )
entity->deleteLater();
mLightEntities.clear();
for ( Qt3DCore::QEntity *entity : qgis::as_const( mLightOriginEntities ) )
for ( Qt3DCore::QEntity *entity : std::as_const( mLightOriginEntities ) )
entity->deleteLater();
mLightOriginEntities.clear();

@@ -956,7 +956,7 @@ void Qgs3DMapScene::updateSceneState()
return;
}

for ( QgsChunkedEntity *entity : qgis::as_const( mChunkEntities ) )
for ( QgsChunkedEntity *entity : std::as_const( mChunkEntities ) )
{
if ( entity->isEnabled() && entity->pendingJobsCount() > 0 )
{
@@ -337,15 +337,15 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon
elemTerrain.setAttribute( QStringLiteral( "show-labels" ), mShowLabels ? 1 : 0 );

QDomElement elemPointLights = doc.createElement( QStringLiteral( "point-lights" ) );
for ( const QgsPointLightSettings &pointLight : qgis::as_const( mPointLights ) )
for ( const QgsPointLightSettings &pointLight : std::as_const( mPointLights ) )
{
QDomElement elemPointLight = pointLight.writeXml( doc );
elemPointLights.appendChild( elemPointLight );
}
elem.appendChild( elemPointLights );

QDomElement elemDirectionalLights = doc.createElement( QStringLiteral( "directional-lights" ) );
for ( const QgsDirectionalLightSettings &directionalLight : qgis::as_const( mDirectionalLights ) )
for ( const QgsDirectionalLightSettings &directionalLight : std::as_const( mDirectionalLights ) )
{
QDomElement elemDirectionalLight = directionalLight.writeXml( doc );
elemDirectionalLights.appendChild( elemDirectionalLight );
@@ -62,7 +62,7 @@ void QgsLayoutItem3DMap::assignFreeId()

int maxId = -1;
bool used = false;
for ( QgsLayoutItem3DMap *map : qgis::as_const( mapsList ) )
for ( QgsLayoutItem3DMap *map : std::as_const( mapsList ) )
{
if ( map == this )
continue;
@@ -107,7 +107,7 @@ void QgsRuleBased3DRenderer::Rule::initFilter()
void QgsRuleBased3DRenderer::Rule::updateElseRules()
{
mElseRules.clear();
for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
{
if ( rule->isElse() )
mElseRules << rule;
@@ -143,7 +143,7 @@ const QgsRuleBased3DRenderer::Rule *QgsRuleBased3DRenderer::Rule::findRuleByKey(
if ( key == mRuleKey )
return this;

for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
{
const Rule *r = rule->findRuleByKey( key );
if ( r )
@@ -157,7 +157,7 @@ QgsRuleBased3DRenderer::Rule *QgsRuleBased3DRenderer::Rule::findRuleByKey( const
if ( key == mRuleKey )
return this;

for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
{
Rule *r = rule->findRuleByKey( key );
if ( r )
@@ -172,7 +172,7 @@ QgsRuleBased3DRenderer::Rule *QgsRuleBased3DRenderer::Rule::clone() const
Rule *newrule = new Rule( symbol, mFilterExp, mDescription );
newrule->setActive( mIsActive );
// clone children
for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
newrule->appendChild( rule->clone() );
return newrule;
}
@@ -258,7 +258,7 @@ void QgsRuleBased3DRenderer::Rule::createHandlers( QgsVectorLayer *layer, QgsRul
}

// call recursively
for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
{
rule->createHandlers( layer, handlers );
}
@@ -284,7 +284,7 @@ void QgsRuleBased3DRenderer::Rule::prepare( const Qgs3DRenderContext &context, Q
}

// call recursively
for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
{
rule->prepare( context, attributeNames, handlers );
}
@@ -307,7 +307,7 @@ QgsRuleBased3DRenderer::Rule::RegisterResult QgsRuleBased3DRenderer::Rule::regis
bool willRegisterSomething = false;

// call recursively
for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
{
// Don't process else rules yet
if ( !rule->isElse() )
@@ -322,7 +322,7 @@ QgsRuleBased3DRenderer::Rule::RegisterResult QgsRuleBased3DRenderer::Rule::regis
// If none of the rules passed then we jump into the else rules and process them.
if ( !willRegisterSomething )
{
for ( Rule *rule : qgis::as_const( mElseRules ) )
for ( Rule *rule : std::as_const( mElseRules ) )
{
registered |= rule->registerFeature( feature, context, handlers ) != Filtered;
}
@@ -46,7 +46,7 @@ QByteArray QgsLineVertexData::createVertexBuffer()
vertexBufferData.resize( vertices.size() * 3 * sizeof( float ) );
float *rawVertexArray = reinterpret_cast<float *>( vertexBufferData.data() );
int idx = 0;
for ( const auto &v : qgis::as_const( vertices ) )
for ( const auto &v : std::as_const( vertices ) )
{
rawVertexArray[idx++] = v.x();
rawVertexArray[idx++] = v.y();
@@ -61,7 +61,7 @@ QByteArray QgsLineVertexData::createIndexBuffer()
indexBufferData.resize( indexes.size() * sizeof( int ) );
unsigned int *rawIndexArray = reinterpret_cast<unsigned int *>( indexBufferData.data() );
int idx = 0;
for ( unsigned int indexVal : qgis::as_const( indexes ) )
for ( unsigned int indexVal : std::as_const( indexes ) )
{
rawIndexArray[idx++] = indexVal;
}
@@ -34,7 +34,7 @@ int QgsIDWInterpolator::interpolatePoint( double x, double y, double &result, Qg
double sumCounter = 0;
double sumDenominator = 0;

for ( const QgsInterpolatorVertexData &vertex : qgis::as_const( mCachedBaseData ) )
for ( const QgsInterpolatorVertexData &vertex : std::as_const( mCachedBaseData ) )
{
double distance = std::sqrt( ( vertex.x - x ) * ( vertex.x - x ) + ( vertex.y - y ) * ( vertex.y - y ) );
if ( qgsDoubleNear( distance, 0.0 ) )
@@ -43,7 +43,7 @@ QgsInterpolator::Result QgsInterpolator::cacheBaseData( QgsFeedback *feedback )

double layerStep = !mLayerData.empty() ? 100.0 / mLayerData.count() : 1;
int layerCount = 0;
for ( const LayerData &layer : qgis::as_const( mLayerData ) )
for ( const LayerData &layer : std::as_const( mLayerData ) )
{
if ( feedback && feedback->isCanceled() )
return Canceled;
@@ -96,7 +96,7 @@ void QgsTinInterpolator::initialize()
int nProcessedFeatures = 0;
if ( mFeedback )
{
for ( const LayerData &layer : qgis::as_const( mLayerData ) )
for ( const LayerData &layer : std::as_const( mLayerData ) )
{
if ( layer.source )
{
@@ -108,7 +108,7 @@ void QgsTinInterpolator::initialize()
const QgsCoordinateReferenceSystem crs = !mLayerData.empty() ? mLayerData.at( 0 ).source->sourceCrs() : QgsCoordinateReferenceSystem();

QgsFeature f;
for ( const LayerData &layer : qgis::as_const( mLayerData ) )
for ( const LayerData &layer : std::as_const( mLayerData ) )
{
if ( layer.source )
{
@@ -216,7 +216,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
else if ( QgsWkbTypes::flatType( feature.geometry().wkbType() ) == QgsWkbTypes::LineString )
mpl.push_back( feature.geometry().asPolyline() );

for ( const QgsPolylineXY &line : qgis::as_const( mpl ) )
for ( const QgsPolylineXY &line : std::as_const( mpl ) )
{
QgsPointXY pt1, pt2;
bool isFirstPoint = true;
@@ -339,7 +339,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
else if ( QgsWkbTypes::flatType( feature.geometry().wkbType() ) == QgsWkbTypes::LineString )
mpl.push_back( feature.geometry().asPolyline() );

for ( const QgsPolylineXY &line : qgis::as_const( mpl ) )
for ( const QgsPolylineXY &line : std::as_const( mpl ) )
{
QgsPointXY pt1, pt2;

@@ -131,7 +131,7 @@ QgsFeatureList QgsAddIncrementalFieldAlgorithm::processFeature( const QgsFeature
{
if ( !mGroupedFieldNames.empty() && mGroupedFields.empty() )
{
for ( const QString &field : qgis::as_const( mGroupedFieldNames ) )
for ( const QString &field : std::as_const( mGroupedFieldNames ) )
{
int idx = mFields.lookupField( field );
if ( idx >= 0 )
@@ -150,7 +150,7 @@ QgsFeatureList QgsAddIncrementalFieldAlgorithm::processFeature( const QgsFeature
{
QgsAttributes groupAttributes;
groupAttributes.reserve( mGroupedFields.size() );
for ( int index : qgis::as_const( mGroupedFields ) )
for ( int index : std::as_const( mGroupedFields ) )
{
groupAttributes << f.attribute( index );
}
@@ -217,7 +217,7 @@ QVariantMap QgsCategorizeUsingStyleAlgorithm::processAlgorithm( const QVariantMa
QgsCategoryList cats;
cats.reserve( uniqueVals.count() );
std::unique_ptr< QgsSymbol > defaultSymbol( QgsSymbol::defaultSymbol( mLayerGeometryType ) );
for ( const QVariant &val : qgis::as_const( sortedUniqueVals ) )
for ( const QVariant &val : std::as_const( sortedUniqueVals ) )
{
cats.append( QgsRendererCategory( val, defaultSymbol->clone(), val.toString() ) );
}
@@ -245,7 +245,7 @@ QVariantMap QgsCategorizeUsingStyleAlgorithm::processAlgorithm( const QVariantMa
{
feedback->pushInfo( QObject::tr( "\n%1 categories could not be matched:" ).arg( unmatchedCategories.count() ) );
std::sort( unmatchedCategories.begin(), unmatchedCategories.end() );
for ( const QVariant &cat : qgis::as_const( unmatchedCategories ) )
for ( const QVariant &cat : std::as_const( unmatchedCategories ) )
{
feedback->pushInfo( QStringLiteral( "∙ “%1”" ).arg( cat.toString() ) );
if ( nonMatchingCategoriesSink )
@@ -261,7 +261,7 @@ QVariantMap QgsCategorizeUsingStyleAlgorithm::processAlgorithm( const QVariantMa
{
feedback->pushInfo( QObject::tr( "\n%1 symbols in style were not matched:" ).arg( unmatchedSymbols.count() ) );
std::sort( unmatchedSymbols.begin(), unmatchedSymbols.end() );
for ( const QString &name : qgis::as_const( unmatchedSymbols ) )
for ( const QString &name : std::as_const( unmatchedSymbols ) )
{
feedback->pushInfo( QStringLiteral( "∙ “%1”" ).arg( name ) );
if ( nonMatchingSymbolsSink )
@@ -104,7 +104,7 @@ bool QgsCellStatisticsAlgorithmBase::prepareAlgorithm( const QVariantMap &parame
//determine output raster data type
//initially raster data type to most primitive data type that is possible
mDataType = Qgis::Byte;
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : qgis::as_const( mInputs ) )
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : std::as_const( mInputs ) )
{
for ( int band : i.bands )
{
@@ -275,7 +275,7 @@ void QgsCellStatisticsAlgorithm::processRasterStack( QgsProcessingFeedback *feed
while ( outputIter.readNextRasterPart( 1, iterCols, iterRows, outputBlock, iterLeft, iterTop, &blockExtent ) )
{
std::vector< std::unique_ptr< QgsRasterBlock > > inputBlocks;
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : qgis::as_const( mInputs ) )
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : std::as_const( mInputs ) )
{
if ( feedback->isCanceled() )
break; //in case some slow data sources are loaded
@@ -452,7 +452,7 @@ void QgsCellStatisticsPercentileAlgorithm::processRasterStack( QgsProcessingFeed
while ( outputIter.readNextRasterPart( 1, iterCols, iterRows, outputBlock, iterLeft, iterTop, &blockExtent ) )
{
std::vector< std::unique_ptr< QgsRasterBlock > > inputBlocks;
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : qgis::as_const( mInputs ) )
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : std::as_const( mInputs ) )
{
if ( feedback->isCanceled() )
break; //in case some slow data sources are loaded
@@ -590,7 +590,7 @@ void QgsCellStatisticsPercentRankFromValueAlgorithm::processRasterStack( QgsProc
while ( outputIter.readNextRasterPart( 1, iterCols, iterRows, outputBlock, iterLeft, iterTop, &blockExtent ) )
{
std::vector< std::unique_ptr< QgsRasterBlock > > inputBlocks;
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : qgis::as_const( mInputs ) )
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : std::as_const( mInputs ) )
{
if ( feedback->isCanceled() )
break; //in case some slow data sources are loaded
@@ -735,7 +735,7 @@ void QgsCellStatisticsPercentRankFromRasterAlgorithm::processRasterStack( QgsPro
std::unique_ptr< QgsRasterBlock > valueBlock( mValueRasterInterface->block( mValueRasterBand, blockExtent, iterCols, iterRows ) );

std::vector< std::unique_ptr< QgsRasterBlock > > inputBlocks;
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : qgis::as_const( mInputs ) )
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : std::as_const( mInputs ) )
{
if ( feedback->isCanceled() )
break; //in case some slow data sources are loaded
@@ -87,7 +87,7 @@ QVariantMap QgsConditionalBranchAlgorithm::processAlgorithm( const QVariantMap &
QgsExpressionContext expressionContext = createExpressionContext( parameters, context );

QVariantMap results;
for ( Output *output : qgis::as_const( mOutputs ) )
for ( Output *output : std::as_const( mOutputs ) )
{
output->expression.prepare( &expressionContext );
const QVariant res = output->expression.evaluate( &expressionContext );
@@ -99,7 +99,7 @@ QgsFields QgsDropTableFieldsAlgorithm::outputFields( const QgsFields &inputField
std::sort( mFieldIndices.begin(), mFieldIndices.end(), std::greater< int >() );

// this second time we make a cleaned version of the fields
for ( const int index : qgis::as_const( mFieldIndices ) )
for ( const int index : std::as_const( mFieldIndices ) )
{
outFields.remove( index );
}
@@ -115,7 +115,7 @@ bool QgsDropTableFieldsAlgorithm::prepareAlgorithm( const QVariantMap &parameter
std::unique_ptr< QgsProcessingFeatureSource> source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
if ( source )
{
for ( const QString &field : qgis::as_const( mFieldsToDelete ) )
for ( const QString &field : std::as_const( mFieldsToDelete ) )
{
const int index = source->fields().lookupField( field );
if ( index < 0 )
@@ -232,7 +232,7 @@ QgsFields QgsRetainTableFieldsAlgorithm::outputFields( const QgsFields &inputFie

// this second time we make a cleaned version of the fields
QgsFields outFields;
for ( const int index : qgis::as_const( mFieldIndices ) )
for ( const int index : std::as_const( mFieldIndices ) )
{
outFields.append( inputFields.at( index ) );
}
@@ -248,7 +248,7 @@ bool QgsRetainTableFieldsAlgorithm::prepareAlgorithm( const QVariantMap &paramet
std::unique_ptr< QgsProcessingFeatureSource> source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
if ( source )
{
for ( const QString &field : qgis::as_const( mFieldsToRetain ) )
for ( const QString &field : std::as_const( mFieldsToRetain ) )
{
const int index = source->fields().lookupField( field );
if ( index < 0 )
@@ -140,7 +140,7 @@ QVariantMap QgsExplodeHstoreAlgorithm::processAlgorithm( const QVariantMap &para
QgsFeature outFeature;
step = !features.empty() ? 50.0 / features.count() : 1;
i = 0;
for ( const QgsFeature &feat : qgis::as_const( features ) )
for ( const QgsFeature &feat : std::as_const( features ) )
{
i++;
if ( feedback->isCanceled() )
@@ -279,7 +279,7 @@ void QgsLocationBasedAlgorithm::processByIteratingOverIntersectSource( const Qgs

bool isMatch = false;

for ( Predicate predicate : qgis::as_const( predicates ) )
for ( Predicate predicate : std::as_const( predicates ) )
{
switch ( predicate )
{
@@ -127,7 +127,7 @@ QgsFeatureList QgsExtractZMValuesAlgorithmBase::processFeature( const QgsFeature
}
stat.finalize();

for ( QgsStatisticalSummary::Statistic s : qgis::as_const( mSelectedStats ) )
for ( QgsStatisticalSummary::Statistic s : std::as_const( mSelectedStats ) )
attrs.append( stat.statistic( s ) );
}
f.setAttributes( attrs );

0 comments on commit 876ee57

Please sign in to comment.