Skip to content
Permalink
Browse files

Merge pull request #9738 from m-kuhn/kill_analysis_qforeach

Kill Q_FOREACH in analysis
  • Loading branch information
m-kuhn committed Apr 7, 2019
2 parents 736e8cb + 6a5d0c6 commit b618e8d9d01f884cdfa27d526abd7543aebe7a54
@@ -433,6 +433,7 @@ IF(HAVE_OPENCL)
TARGET_LINK_LIBRARIES(qgis_analysis ${OpenCL_LIBRARIES})
ENDIF(HAVE_OPENCL)

TARGET_COMPILE_DEFINITIONS(qgis_analysis PRIVATE "-DQT_NO_FOREACH")

# clang-tidy
IF(CLANG_TIDY_EXE)
@@ -144,7 +144,8 @@ QVariantMap QgsClipAlgorithm::processAlgorithm( const QVariantMap &parameters, Q
QgsFeatureIds testedFeatureIds;

int i = -1;
Q_FOREACH ( const QgsGeometry &clipGeom, clipGeoms )
const auto constClipGeoms = clipGeoms;
for ( const QgsGeometry &clipGeom : constClipGeoms )
{
i++;
if ( feedback->isCanceled() )
@@ -165,7 +166,8 @@ QVariantMap QgsClipAlgorithm::processAlgorithm( const QVariantMap &parameters, Q
step = 100.0 / inputFeatures.length();

int current = 0;
Q_FOREACH ( const QgsFeature &inputFeature, inputFeatures )
const auto constInputFeatures = inputFeatures;
for ( const QgsFeature &inputFeature : constInputFeatures )
{
if ( feedback->isCanceled() )
{
@@ -89,7 +89,8 @@ QVariantMap QgsCollectorAlgorithm::processCollection( const QVariantMap &paramet
else
{
QList< int > fieldIndexes;
Q_FOREACH ( const QString &field, fields )
const auto constFields = fields;
for ( const QString &field : constFields )
{
int index = source->fields().lookupField( field );
if ( index >= 0 )
@@ -107,7 +108,8 @@ QVariantMap QgsCollectorAlgorithm::processCollection( const QVariantMap &paramet
}

QVariantList indexAttributes;
Q_FOREACH ( int index, fieldIndexes )
const auto constFieldIndexes = fieldIndexes;
for ( int index : constFieldIndexes )
{
indexAttributes << f.attribute( index );
}
@@ -363,7 +363,8 @@ bool QgsAlignRaster::run()

//dump();

Q_FOREACH ( const Item &r, mRasters )
const auto constMRasters = mRasters;
for ( const Item &r : constMRasters )
{
if ( !createAndWarp( r ) )
return false;
@@ -398,7 +399,8 @@ int QgsAlignRaster::suggestedReferenceLayer() const
QgsCoordinateReferenceSystem destCRS( QStringLiteral( "EPSG:4326" ) );
QString destWkt = destCRS.toWkt();

Q_FOREACH ( const Item &raster, mRasters )
const auto constMRasters = mRasters;
for ( const Item &raster : constMRasters )
{
if ( !suggestedWarpOutput( RasterInfo( raster.inputFilename ), destWkt, &cs ) )
return false;
@@ -186,7 +186,8 @@ class Raytracer

QgsSnapIndex::GridRow::~GridRow()
{
Q_FOREACH ( const QgsSnapIndex::Cell &cell, mCells )
const auto constMCells = mCells;
for ( const QgsSnapIndex::Cell &cell : constMCells )
{
qDeleteAll( cell );
}
@@ -373,7 +374,7 @@ QgsPoint QgsSnapIndex::getClosestSnapToPoint( const QgsPoint &p, const QgsPoint
{
continue;
}
Q_FOREACH ( const SnapItem *item, *cell )
for ( const SnapItem *item : *cell )
{
if ( item->type == SnapSegment )
{
@@ -415,7 +416,8 @@ QgsSnapIndex::SnapItem *QgsSnapIndex::getSnapItem( const QgsPoint &pos, double t
QgsSnapIndex::SegmentSnapItem *snapSegment = nullptr;
QgsSnapIndex::PointSnapItem *snapPoint = nullptr;

Q_FOREACH ( QgsSnapIndex::SnapItem *item, items )
const auto constItems = items;
for ( QgsSnapIndex::SnapItem *item : constItems )
{
if ( ( ! endPointOnly && item->type == SnapPoint ) || item->type == SnapEndPoint )
{
@@ -510,7 +512,7 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry &geometry, doubl
QgsPoint( geometry.constGet()->boundingBox().center() );

QgsSnapIndex refSnapIndex( center, 10 * snapTolerance );
Q_FOREACH ( const QgsGeometry &geom, referenceGeometries )
for ( const QgsGeometry &geom : referenceGeometries )
{
refSnapIndex.addGeometry( geom.constGet() );
}
@@ -624,7 +626,7 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry &geometry, doubl
origSubjSnapIndex->addGeometry( origSubjGeom.get() );

// Pass 2: add missing vertices to subject geometry
Q_FOREACH ( const QgsGeometry &refGeom, referenceGeometries )
for ( const QgsGeometry &refGeom : referenceGeometries )
{
for ( int iPart = 0, nParts = refGeom.constGet()->partCount(); iPart < nParts; ++iPart )
{
@@ -760,7 +762,8 @@ QgsGeometry QgsInternalGeometrySnapper::snapFeature( const QgsFeature &feature )
if ( !refFeatureIds.isEmpty() )
{
QList< QgsGeometry > refGeometries;
Q_FOREACH ( QgsFeatureId id, refFeatureIds )
const auto constRefFeatureIds = refFeatureIds;
for ( QgsFeatureId id : constRefFeatureIds )
{
refGeometries << mProcessedGeometries.value( id );
}

0 comments on commit b618e8d

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