Skip to content
Permalink
Browse files

Definitely no more Q_FOREACH

  • Loading branch information
nyalldawson committed Mar 21, 2021
1 parent 106c826 commit 25595557c14837b74a2c757756683ca9fab3b62c
Showing with 268 additions and 250 deletions.
  1. +1 −1 src/3d/chunks/qgschunkboundsentity_p.cpp
  2. +2 −2 src/3d/chunks/qgschunkedentity_p.cpp
  3. +6 −4 src/3d/qgs3dmapscene.cpp
  4. +8 −8 src/3d/qgs3dmapsettings.cpp
  5. +4 −3 src/3d/terrain/qgsterrainentity_p.cpp
  6. +1 −1 src/3d/terrain/qgsterraintexturegenerator_p.cpp
  7. +0 −3 src/core/qgstracer.cpp
  8. +0 −6 src/core/symbology/qgscptcityarchive.cpp
  9. +3 −3 src/crashhandler/qgscrashreport.cpp
  10. +0 −1 src/gui/ogr/qgsvectorlayersaveasdialog.cpp
  11. +0 −7 src/gui/symbology/qgssymbolslistwidget.cpp
  12. +1 −1 src/plugins/geometry_checker/qgsgeometrycheckerresulttab.cpp
  13. +2 −2 src/plugins/grass/qgsgrasseditrenderer.cpp
  14. +1 −1 src/plugins/grass/qgsgrassmodule.cpp
  15. +16 −16 src/plugins/grass/qgsgrassmoduleinput.cpp
  16. +7 −7 src/plugins/grass/qgsgrassmoduleoptions.cpp
  17. +9 −9 src/plugins/grass/qgsgrassmoduleparam.cpp
  18. +2 −2 src/plugins/grass/qgsgrassplugin.cpp
  19. +1 −1 src/plugins/grass/qgsgrasstools.cpp
  20. +7 −3 src/plugins/offline_editing/offline_editing_plugin_gui.cpp
  21. +10 −9 src/providers/db2/qgsdb2sourceselect.cpp
  22. +1 −1 src/providers/grass/qgsgrass.cpp
  23. +2 −2 src/providers/grass/qgsgrassimport.cpp
  24. +10 −9 src/providers/mssql/qgsmssqlsourceselect.cpp
  25. +2 −1 src/providers/oracle/qgsoracledataitems.cpp
  26. +2 −2 src/providers/oracle/qgsoraclefeatureiterator.cpp
  27. +10 −9 src/providers/oracle/qgsoraclesourceselect.cpp
  28. +4 −4 src/providers/oracle/qgsoracletablecache.cpp
  29. +4 −3 src/providers/ows/qgsowsdataitems.cpp
  30. +2 −1 src/providers/postgres/qgspostgresdataitems.cpp
  31. +2 −2 src/providers/postgres/qgspostgresfeatureiterator.cpp
  32. +2 −1 src/providers/spatialite/qgsspatialitedataitems.cpp
  33. +2 −1 src/providers/spatialite/qgsspatialitesourceselect.cpp
  34. +3 −2 src/providers/virtual/qgsvirtuallayersqlitemodule.cpp
  35. +8 −4 src/providers/wcs/qgswcscapabilities.cpp
  36. +6 −4 src/providers/wcs/qgswcsdataitems.cpp
  37. +2 −2 src/providers/wfs/qgswfscapabilities.cpp
  38. +2 −1 src/providers/wfs/qgswfsdataitems.cpp
  39. +1 −1 src/providers/wfs/qgswfsfeatureiterator.cpp
  40. +1 −1 src/providers/wfs/qgswfssourceselect.cpp
  41. +5 −5 src/providers/wfs/qgswfssubsetstringeditor.cpp
  42. +12 −4 src/python/qgspythonutilsimpl.cpp
  43. +3 −3 tests/bench/main.cpp
  44. +3 −0 tests/code_layout/test_banned_keywords.sh
  45. +15 −14 tests/src/analysis/testqgsprocessing.cpp
  46. +1 −1 tests/src/app/testqgisappclipboard.cpp
  47. +5 −5 tests/src/core/testqgsauthmanager.cpp
  48. +1 −1 tests/src/core/testqgsdataitem.cpp
  49. +1 −1 tests/src/core/testqgsexpression.cpp
  50. +3 −3 tests/src/core/testqgsfeature.cpp
  51. +2 −2 tests/src/core/testqgsfields.cpp
  52. +1 −1 tests/src/core/testqgsgeometry.cpp
  53. +5 −5 tests/src/core/testqgslayertree.cpp
  54. +2 −2 tests/src/core/testqgslegendrenderer.cpp
  55. +1 −1 tests/src/core/testqgsrasterfilewriter.cpp
  56. +1 −1 tests/src/core/testqgsrasterlayer.cpp
  57. +1 −1 tests/src/core/testqgsrastersublayer.cpp
  58. +2 −2 tests/src/core/testqgsrulebasedrenderer.cpp
  59. +2 −2 tests/src/core/testqgssnappingutils.cpp
  60. +2 −2 tests/src/core/testqgsspatialindex.cpp
  61. +2 −2 tests/src/core/testqgsstyle.cpp
  62. +3 −3 tests/src/core/testqgstracer.cpp
  63. +1 −1 tests/src/core/testqgsvectorlayercache.cpp
  64. +4 −4 tests/src/core/testqgsvectorlayerjoinbuffer.cpp
  65. +15 −15 tests/src/core/testziplayer.cpp
  66. +1 −1 tests/src/gui/testprocessinggui.cpp
  67. +1 −1 tests/src/gui/testprojectionissues.cpp
  68. +2 −2 tests/src/gui/testqgsmapcanvas.cpp
  69. +3 −3 tests/src/gui/testqgsrelationreferencewidget.cpp
  70. +2 −2 tests/src/providers/testqgswcsprovider.cpp
  71. +19 −19 tests/src/providers/testqgswcspublicservers.cpp
@@ -73,7 +73,7 @@ AABBMesh::AABBMesh( Qt3DCore::QNode *parent )
void AABBMesh::setBoxes( const QList<QgsAABB> &bboxes )
{
QList<QVector3D> vertices;
Q_FOREACH ( const QgsAABB &bbox, bboxes )
for ( const QgsAABB &bbox : bboxes )
vertices << bbox.verticesForLines();
mLineMeshGeo->setVertices( vertices );
setVertexCount( mLineMeshGeo->vertexCount() );
@@ -177,7 +177,7 @@ void QgsChunkedEntity::update( const SceneState &state )
if ( mBboxesEntity )
{
QList<QgsAABB> bboxes;
Q_FOREACH ( QgsChunkNode *n, mActiveNodes )
for ( QgsChunkNode *n : std::as_const( mActiveNodes ) )
bboxes << n->bbox();
mBboxesEntity->setBoxes( bboxes );
}
@@ -217,7 +217,7 @@ void QgsChunkedEntity::setShowBoundingBoxes( bool enabled )

void QgsChunkedEntity::updateNodes( const QList<QgsChunkNode *> &nodes, QgsChunkQueueJobFactory *updateJobFactory )
{
Q_FOREACH ( QgsChunkNode *node, nodes )
for ( QgsChunkNode *node : nodes )
{
if ( node->state() == QgsChunkNode::QueuedForUpdate )
{
@@ -561,7 +561,8 @@ void Qgs3DMapScene::createTerrainDeferred()
onCameraChanged(); // force update of the new terrain

// make sure that renderers for layers are re-created as well
Q_FOREACH ( QgsMapLayer *layer, mMap.layers() )
const QList<QgsMapLayer *> layers = mMap.layers();
for ( QgsMapLayer *layer : layers )
{
// remove old entity - if any
removeLayerEntity( layer );
@@ -704,7 +705,8 @@ void Qgs3DMapScene::onLayersChanged()
{
QSet<QgsMapLayer *> layersBefore = qgis::listToSet( mLayerEntities.keys() );
QList<QgsMapLayer *> layersAdded;
Q_FOREACH ( QgsMapLayer *layer, mMap.layers() )
const QList<QgsMapLayer *> layers = mMap.layers();
for ( QgsMapLayer *layer : layers )
{
if ( !layersBefore.contains( layer ) )
{
@@ -717,12 +719,12 @@ void Qgs3DMapScene::onLayersChanged()
}

// what is left in layersBefore are layers that have been removed
Q_FOREACH ( QgsMapLayer *layer, layersBefore )
for ( QgsMapLayer *layer : std::as_const( layersBefore ) )
{
removeLayerEntity( layer );
}

Q_FOREACH ( QgsMapLayer *layer, layersAdded )
for ( QgsMapLayer *layer : std::as_const( layersAdded ) )
{
addLayerEntity( layer );
}
@@ -78,7 +78,7 @@ Qgs3DMapSettings::Qgs3DMapSettings( const Qgs3DMapSettings &other )
, mDebugDepthMapCorner( other.mDebugDepthMapCorner )
, mDebugDepthMapSize( other.mDebugDepthMapSize )
{
Q_FOREACH ( QgsAbstract3DRenderer *renderer, other.mRenderers )
for ( QgsAbstract3DRenderer *renderer : std::as_const( other.mRenderers ) )
{
mRenderers << renderer->clone();
}
@@ -353,7 +353,7 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon
elem.appendChild( elemDirectionalLights );

QDomElement elemMapLayers = doc.createElement( QStringLiteral( "layers" ) );
Q_FOREACH ( const QgsMapLayerRef &layerRef, mLayers )
for ( const QgsMapLayerRef &layerRef : mLayers )
{
QDomElement elemMapLayer = doc.createElement( QStringLiteral( "layer" ) );
elemMapLayer.setAttribute( QStringLiteral( "id" ), layerRef.layerId );
@@ -362,7 +362,7 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon
elemTerrain.appendChild( elemMapLayers );

QDomElement elemTerrainMapLayers = doc.createElement( QStringLiteral( "terrainLayers" ) );
Q_FOREACH ( const QgsMapLayerRef &layerRef, mTerrainLayers )
for ( const QgsMapLayerRef &layerRef : mTerrainLayers )
{
QDomElement elemMapLayer = doc.createElement( QStringLiteral( "layer" ) );
elemMapLayer.setAttribute( QStringLiteral( "id" ), layerRef.layerId );
@@ -377,7 +377,7 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon
elem.appendChild( elemTerrain );

QDomElement elemRenderers = doc.createElement( QStringLiteral( "renderers" ) );
Q_FOREACH ( const QgsAbstract3DRenderer *renderer, mRenderers )
for ( const QgsAbstract3DRenderer *renderer : mRenderers )
{
QDomElement elemRenderer = doc.createElement( QStringLiteral( "renderer" ) );
elemRenderer.setAttribute( QStringLiteral( "type" ), renderer->type() );
@@ -519,7 +519,7 @@ void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
{
QList<QgsMapLayerRef> lst;
lst.reserve( layers.count() );
Q_FOREACH ( QgsMapLayer *layer, layers )
for ( QgsMapLayer *layer : layers )
{
lst.append( layer );
}
@@ -535,7 +535,7 @@ QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
{
QList<QgsMapLayer *> lst;
lst.reserve( mLayers.count() );
Q_FOREACH ( const QgsMapLayerRef &layerRef, mLayers )
for ( const QgsMapLayerRef &layerRef : mLayers )
{
if ( layerRef.layer )
lst.append( layerRef.layer );
@@ -547,7 +547,7 @@ void Qgs3DMapSettings::setTerrainLayers( const QList<QgsMapLayer *> &layers )
{
QList<QgsMapLayerRef> lst;
lst.reserve( layers.count() );
Q_FOREACH ( QgsMapLayer *layer, layers )
for ( QgsMapLayer *layer : layers )
{
lst.append( layer );
}
@@ -563,7 +563,7 @@ QList<QgsMapLayer *> Qgs3DMapSettings::terrainLayers() const
{
QList<QgsMapLayer *> lst;
lst.reserve( mTerrainLayers.count() );
Q_FOREACH ( const QgsMapLayerRef &layerRef, mTerrainLayers )
for ( const QgsMapLayerRef &layerRef : mTerrainLayers )
{
if ( layerRef.layer )
lst.append( layerRef.layer );
@@ -152,7 +152,8 @@ void QgsTerrainEntity::invalidateMapImages()
// handle inactive nodes afterwards

QList<QgsChunkNode *> inactiveNodes;
Q_FOREACH ( QgsChunkNode *node, mRootNode->descendants() )
const QList<QgsChunkNode *> descendants = mRootNode->descendants();
for ( QgsChunkNode *node : descendants )
{
if ( !node->entity() )
continue;
@@ -174,14 +175,14 @@ void QgsTerrainEntity::onLayersChanged()

void QgsTerrainEntity::connectToLayersRepaintRequest()
{
Q_FOREACH ( QgsMapLayer *layer, mLayers )
for ( QgsMapLayer *layer : std::as_const( mLayers ) )
{
disconnect( layer, &QgsMapLayer::repaintRequested, this, &QgsTerrainEntity::invalidateMapImages );
}

mLayers = mMap.terrainLayers();

Q_FOREACH ( QgsMapLayer *layer, mLayers )
for ( QgsMapLayer *layer : std::as_const( mLayers ) )
{
connect( layer, &QgsMapLayer::repaintRequested, this, &QgsTerrainEntity::invalidateMapImages );
}
@@ -59,7 +59,7 @@ int QgsTerrainTextureGenerator::render( const QgsRectangle &extent, QgsChunkNode

void QgsTerrainTextureGenerator::cancelJob( int jobId )
{
Q_FOREACH ( const JobData &jd, mJobs )
for ( const JobData &jd : std::as_const( mJobs ) )
{
if ( jd.jobId == jobId )
{
@@ -253,9 +253,6 @@ QVector<QgsPointXY> shortestPath( const QgsTracerGraph &g, int v1, int v2 )
}

std::reverse( path.begin(), path.end() );
//Q_FOREACH (int x, path)
// qDebug("e: %d", x);

std::reverse( points.begin(), points.end() );
return points;
}
@@ -1338,12 +1338,6 @@ void QgsCptCityBrowserModel::addRootItems()

void QgsCptCityBrowserModel::removeRootItems()
{
// don't remove root items, they belong to the QgsCptCityArchive
// Q_FOREACH ( QgsCptCityDataItem* item, mRootItems )
// {
// delete item;
// }

mRootItems.clear();
}

@@ -55,7 +55,7 @@ const QString QgsCrashReport::toHtml() const
else
{
reportData.append( QStringLiteral( "<pre>" ) );
Q_FOREACH ( const QgsStackTrace::StackLine &line, mStackTrace->lines )
for ( const QgsStackTrace::StackLine &line : mStackTrace->lines )
{
QFileInfo fileInfo( line.fileName );
QString filename( fileInfo.fileName() );
@@ -98,7 +98,7 @@ const QString QgsCrashReport::toHtml() const
}

QString report;
Q_FOREACH ( const QString &line, reportData )
for ( const QString &line : std::as_const( reportData ) )
{
report += line + "<br>";
}
@@ -115,7 +115,7 @@ const QString QgsCrashReport::crashID() const
QString data = QString();

// Hashes the full stack.
Q_FOREACH ( const QgsStackTrace::StackLine &line, mStackTrace->lines )
for ( const QgsStackTrace::StackLine &line : mStackTrace->lines )
{
#if 0
QFileInfo fileInfo( line.fileName );
@@ -582,7 +582,6 @@ void QgsVectorLayerSaveAsDialog::mFormatComboBox_currentIndexChanged( int idx )
delete item;
}

// workaround so the Q_FOREACH macro does not get confused by the ','
typedef QPair<QLabel *, QWidget *> LabelControlPair;

if ( QgsVectorFileWriter::driverMetadata( format(), driverMetaData ) )
@@ -240,13 +240,6 @@ void QgsSymbolsListWidget::setContext( const QgsSymbolWidgetContext &context )
{
unitWidget->setMapCanvas( mContext.mapCanvas() );
}
#if 0
Q_FOREACH ( QgsPropertyOverrideButton *ddButton, findChildren<QgsPropertyOverrideButton *>() )
{
if ( ddButton->assistant() )
ddButton->assistant()->setMapCanvas( mContext.mapCanvas() );
}
#endif
}

QgsSymbolWidgetContext QgsSymbolsListWidget::context() const
@@ -382,7 +382,7 @@ void QgsGeometryCheckerResultTab::highlightErrors( bool current )
{
double cx = 0., cy = 0.;
QgsRectangle pointExtent( errorPositions.first(), errorPositions.first() );
Q_FOREACH ( const QgsPointXY &p, errorPositions )
for ( const QgsPointXY &p : std::as_const( errorPositions ) )
{
cx += p.x();
cy += p.y();
@@ -64,7 +64,7 @@ QgsGrassEditRenderer::QgsGrassEditRenderer()
firstVertexMarkerLine->setPlacement( QgsTemplatedLineSymbolLayerBase::FirstVertex );
QgsMarkerLineSymbolLayer *lastVertexMarkerLine = static_cast<QgsMarkerLineSymbolLayer *>( firstVertexMarkerLine->clone() );
lastVertexMarkerLine->setPlacement( QgsTemplatedLineSymbolLayerBase::LastVertex );
Q_FOREACH ( int value, colors.keys() )
for ( int value : colors.keys() )
{
QgsSymbol *symbol = QgsSymbol::defaultSymbol( QgsWkbTypes::LineGeometry );
symbol->setColor( colors.value( value ) );
@@ -91,7 +91,7 @@ QgsGrassEditRenderer::QgsGrassEditRenderer()

categoryList.clear();

Q_FOREACH ( int value, colors.keys() )
for ( int value : colors.keys() )
{
QgsSymbol *symbol = QgsSymbol::defaultSymbol( QgsWkbTypes::PointGeometry );
symbol->setColor( colors.value( value ) );
@@ -620,7 +620,7 @@ void QgsGrassModule::run()

// Print some important variables
variables << QStringLiteral( "QGIS_PREFIX_PATH" ) << QStringLiteral( "QGIS_GRASS_CRS" ) << QStringLiteral( "GRASS_REGION" );
Q_FOREACH ( const QString &v, variables )
for ( const QString &v : variables )
{
mOutputTextBrowser->append( v + "=" + environment.value( v ) + "<BR>" );
}

0 comments on commit 2559555

Please sign in to comment.