From 9319176a7c2a97924eb7ee144dff49ad2874d2ee Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 19 Oct 2015 17:36:02 +1100 Subject: [PATCH] More clazy recommended optimisations: - Use constFind instead of find where applicable - Use midRef instead of mid - const ref when using Q_FOREACH - foreach->Q_FOREACH --- src/app/qgssettingstree.cpp | 4 +-- src/core/geometry/qgswkbtypes.cpp | 18 +++++------ src/core/qgsattributeaction.cpp | 6 ++-- src/core/qgsdataitem.cpp | 5 ++-- src/core/qgsexpression.cpp | 6 ++-- src/core/qgslabelingenginev2.cpp | 4 +-- src/core/qgsrelation.h | 4 +-- src/gui/auth/qgsauthsslimportdialog.cpp | 2 +- .../checks/qgsgeometryanglecheck.cpp | 2 +- .../checks/qgsgeometryareacheck.cpp | 4 +-- .../checks/qgsgeometrycheck.cpp | 2 +- .../checks/qgsgeometrycontainedcheck.cpp | 4 +-- .../qgsgeometrydegeneratepolygoncheck.cpp | 2 +- .../checks/qgsgeometryduplicatecheck.cpp | 6 ++-- .../checks/qgsgeometryduplicatecheck.h | 2 +- .../checks/qgsgeometryduplicatenodescheck.cpp | 2 +- .../checks/qgsgeometrygapcheck.cpp | 6 ++-- .../checks/qgsgeometryholecheck.cpp | 2 +- .../checks/qgsgeometrymultipartcheck.cpp | 2 +- .../checks/qgsgeometryoverlapcheck.cpp | 4 +-- .../checks/qgsgeometrysegmentlengthcheck.cpp | 2 +- .../qgsgeometryselfintersectioncheck.cpp | 6 ++-- .../checks/qgsgeometrytypecheck.cpp | 2 +- .../geometry_checker/qgsgeometrychecker.cpp | 20 ++++++------- .../ui/qgsgeometrycheckerfixsummarydialog.cpp | 10 +++---- .../ui/qgsgeometrycheckerresulttab.cpp | 18 +++++------ .../ui/qgsgeometrycheckersetuptab.cpp | 12 ++++---- .../ui/qgsgeometrycheckfixdialog.cpp | 2 +- .../geometry_snapper/qgsgeometrysnapper.cpp | 6 ++-- .../qgsgeometrysnapperdialog.cpp | 6 ++-- src/plugins/geometry_snapper/qgssnapindex.cpp | 6 ++-- src/plugins/grass/qgsgrasseditrenderer.cpp | 4 +-- src/plugins/grass/qgsgrassmodule.cpp | 8 ++--- src/plugins/grass/qgsgrassmoduleinput.cpp | 30 +++++++++---------- src/plugins/grass/qgsgrassmoduleoptions.cpp | 6 ++-- src/plugins/grass/qgsgrassmoduleparam.cpp | 4 +-- src/plugins/grass/qgsgrassplugin.cpp | 4 +-- src/plugins/grass/qgsgrasstools.cpp | 2 +- src/providers/grass/qgis.v.in.cpp | 22 +++++++------- src/providers/grass/qgsgrass.cpp | 4 +-- .../grass/qgsgrassfeatureiterator.cpp | 2 +- src/providers/grass/qgsgrassimport.cpp | 2 +- .../grass/qgsgrassprovidermodule.cpp | 20 ++++++------- .../grass/qgsgrassrasterprovider.cpp | 4 +-- src/providers/grass/qgsgrassvector.cpp | 16 +++++----- src/providers/grass/qgsgrassvectormap.cpp | 8 ++--- .../providers/grass/testqgsgrassprovider.cpp | 14 ++++----- 47 files changed, 164 insertions(+), 163 deletions(-) diff --git a/src/app/qgssettingstree.cpp b/src/app/qgssettingstree.cpp index 5d6f30dfdaff..20676cfe922b 100644 --- a/src/app/qgssettingstree.cpp +++ b/src/app/qgssettingstree.cpp @@ -185,7 +185,7 @@ void QgsSettingsTree::updateChildItems( QTreeWidgetItem *parent ) { int dividerIndex = 0; - foreach ( QString group, settings->childGroups() ) + Q_FOREACH ( const QString& group, settings->childGroups() ) { QTreeWidgetItem *child; int childIndex = findChild( parent, group, dividerIndex ); @@ -209,7 +209,7 @@ void QgsSettingsTree::updateChildItems( QTreeWidgetItem *parent ) settings->endGroup(); } - foreach ( QString key, settings->childKeys() ) + Q_FOREACH ( const QString& key, settings->childKeys() ) { QTreeWidgetItem *child; int childIndex = findChild( parent, key, 0 ); diff --git a/src/core/geometry/qgswkbtypes.cpp b/src/core/geometry/qgswkbtypes.cpp index 9a175deafcc9..0086d2c75d4e 100644 --- a/src/core/geometry/qgswkbtypes.cpp +++ b/src/core/geometry/qgswkbtypes.cpp @@ -25,7 +25,7 @@ QMap* QgsWKBTypes::entries() QgsWKBTypes::Type QgsWKBTypes::singleType( Type type ) { - QMap< Type, wkbEntry >::const_iterator it = entries()->find( type ); + QMap< Type, wkbEntry >::const_iterator it = entries()->constFind( type ); if ( it == entries()->constEnd() || it.key() == Unknown ) { return Unknown; @@ -35,7 +35,7 @@ QgsWKBTypes::Type QgsWKBTypes::singleType( Type type ) QgsWKBTypes::Type QgsWKBTypes::multiType( Type type ) { - QMap< Type, wkbEntry >::const_iterator it = entries()->find( type ); + QMap< Type, wkbEntry >::const_iterator it = entries()->constFind( type ); if ( it == entries()->constEnd() || it.key() == Unknown ) { return Unknown; @@ -45,7 +45,7 @@ QgsWKBTypes::Type QgsWKBTypes::multiType( Type type ) QgsWKBTypes::Type QgsWKBTypes::flatType( Type type ) { - QMap< Type, wkbEntry >::const_iterator it = entries()->find( type ); + QMap< Type, wkbEntry >::const_iterator it = entries()->constFind( type ); if ( it == entries()->constEnd() || it.key() == Unknown ) { return Unknown; @@ -58,7 +58,7 @@ QgsWKBTypes::Type QgsWKBTypes::parseType( const QString &wktStr ) QString typestr = wktStr.left( wktStr.indexOf( '(' ) ).simplified().replace( " ", "" ); Q_FOREACH ( const Type& type, entries()->keys() ) { - QMap< Type, wkbEntry >::const_iterator it = entries()->find( type ); + QMap< Type, wkbEntry >::const_iterator it = entries()->constFind( type ); if ( it != entries()->constEnd() && it.value().mName.compare( typestr, Qt::CaseInsensitive ) == 0 ) { return type; @@ -74,7 +74,7 @@ bool QgsWKBTypes::isSingleType( Type type ) bool QgsWKBTypes::isMultiType( Type type ) { - QMap< Type, wkbEntry >::const_iterator it = entries()->find( type ); + QMap< Type, wkbEntry >::const_iterator it = entries()->constFind( type ); if ( it == entries()->constEnd() ) { return Unknown; @@ -98,7 +98,7 @@ int QgsWKBTypes::wkbDimensions( Type type ) QgsWKBTypes::GeometryType QgsWKBTypes::geometryType( Type type ) { - QMap< Type, wkbEntry >::const_iterator it = entries()->find( type ); + QMap< Type, wkbEntry >::const_iterator it = entries()->constFind( type ); if ( it == entries()->constEnd() ) { return UnknownGeometry; @@ -108,7 +108,7 @@ QgsWKBTypes::GeometryType QgsWKBTypes::geometryType( Type type ) QString QgsWKBTypes::displayString( Type type ) { - QMap< Type, wkbEntry >::const_iterator it = entries()->find( type ); + QMap< Type, wkbEntry >::const_iterator it = entries()->constFind( type ); if ( it == entries()->constEnd() ) { return QString::null; @@ -118,7 +118,7 @@ QString QgsWKBTypes::displayString( Type type ) bool QgsWKBTypes::hasZ( Type type ) { - QMap< Type, wkbEntry >::const_iterator it = entries()->find( type ); + QMap< Type, wkbEntry >::const_iterator it = entries()->constFind( type ); if ( it == entries()->constEnd() ) { return false; @@ -128,7 +128,7 @@ bool QgsWKBTypes::hasZ( Type type ) bool QgsWKBTypes::hasM( Type type ) { - QMap< Type, wkbEntry >::const_iterator it = entries()->find( type ); + QMap< Type, wkbEntry >::const_iterator it = entries()->constFind( type ); if ( it == entries()->constEnd() ) { return false; diff --git a/src/core/qgsattributeaction.cpp b/src/core/qgsattributeaction.cpp index fbcd459f5b6c..a772564068de 100644 --- a/src/core/qgsattributeaction.cpp +++ b/src/core/qgsattributeaction.cpp @@ -224,7 +224,7 @@ QString QgsAttributeAction::expandAction( const QString& action, QgsFeature &fea if ( exp.hasParserError() ) { QgsDebugMsg( "Expression parser error: " + exp.parserErrorString() ); - expr_action += action.mid( start, index - start ); + expr_action += action.midRef( start, index - start ); continue; } @@ -235,7 +235,7 @@ QString QgsAttributeAction::expandAction( const QString& action, QgsFeature &fea if ( exp.hasEvalError() ) { QgsDebugMsg( "Expression parser eval error: " + exp.evalErrorString() ); - expr_action += action.mid( start, index - start ); + expr_action += action.midRef( start, index - start ); continue; } @@ -243,7 +243,7 @@ QString QgsAttributeAction::expandAction( const QString& action, QgsFeature &fea expr_action += action.mid( start, pos - start ) + result.toString(); } - expr_action += action.mid( index ); + expr_action += action.midRef( index ); return expr_action; } diff --git a/src/core/qgsdataitem.cpp b/src/core/qgsdataitem.cpp index 0782b2acf95b..6aea68160211 100644 --- a/src/core/qgsdataitem.cpp +++ b/src/core/qgsdataitem.cpp @@ -1420,10 +1420,11 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, const QString& fileP QString vsiPath = vsiPrefix + filePath; if ( zipItem ) { - if ( zipItem->children().size() == 1 ) + QVector children = zipItem->children(); + if ( children.size() == 1 ) { // take the name of the only child so we can get a normal data item from it - QgsLayerItem *layerItem = qobject_cast( zipItem->children().first() ); + QgsLayerItem *layerItem = qobject_cast( children.first() ); if ( layerItem ) vsiPath = layerItem->uri(); } diff --git a/src/core/qgsexpression.cpp b/src/core/qgsexpression.cpp index 70e009f89dc9..73c61d9f19e5 100644 --- a/src/core/qgsexpression.cpp +++ b/src/core/qgsexpression.cpp @@ -2680,7 +2680,7 @@ QString QgsExpression::replaceExpressionText( const QString &action, const QgsEx if ( exp.hasParserError() ) { QgsDebugMsg( "Expression parser error: " + exp.parserErrorString() ); - expr_action += action.mid( start, index - start ); + expr_action += action.midRef( start, index - start ); continue; } @@ -2695,7 +2695,7 @@ QString QgsExpression::replaceExpressionText( const QString &action, const QgsEx if ( exp.hasEvalError() ) { QgsDebugMsg( "Expression parser eval error: " + exp.evalErrorString() ); - expr_action += action.mid( start, index - start ); + expr_action += action.midRef( start, index - start ); continue; } @@ -2703,7 +2703,7 @@ QString QgsExpression::replaceExpressionText( const QString &action, const QgsEx expr_action += action.mid( start, pos - start ) + result.toString(); } - expr_action += action.mid( index ); + expr_action += action.midRef( index ); // restore overwritten local values Q_NOWARN_DEPRECATED_PUSH diff --git a/src/core/qgslabelingenginev2.cpp b/src/core/qgslabelingenginev2.cpp index eeecac142071..b57897624da7 100644 --- a/src/core/qgslabelingenginev2.cpp +++ b/src/core/qgslabelingenginev2.cpp @@ -132,7 +132,7 @@ void QgsLabelingEngineV2::processProvider( QgsAbstractLabelProvider* provider, Q QList features = provider->labelFeatures( context ); - foreach ( QgsLabelFeature* feature, features ) + Q_FOREACH ( QgsLabelFeature* feature, features ) { try { @@ -180,7 +180,7 @@ void QgsLabelingEngineV2::run( QgsRenderContext& context ) // for each provider: get labels and register them in PAL - foreach ( QgsAbstractLabelProvider* provider, mProviders ) + Q_FOREACH ( QgsAbstractLabelProvider* provider, mProviders ) { processProvider( provider, context, p ); } diff --git a/src/core/qgsrelation.h b/src/core/qgsrelation.h index 782bfc923dd6..4bd6eb95a164 100644 --- a/src/core/qgsrelation.h +++ b/src/core/qgsrelation.h @@ -47,9 +47,9 @@ class CORE_EXPORT QgsRelation : QPair< QString, QString >( referencingField, referencedField ) {} //! Get the name of the referencing field - const QString& referencingField() const { return first; } + QString referencingField() const { return first; } //! Get the name of the referenced field - const QString& referencedField() const { return second; } + QString referencedField() const { return second; } }; /** diff --git a/src/gui/auth/qgsauthsslimportdialog.cpp b/src/gui/auth/qgsauthsslimportdialog.cpp index e005913594bd..49f71d7ea778 100644 --- a/src/gui/auth/qgsauthsslimportdialog.cpp +++ b/src/gui/auth/qgsauthsslimportdialog.cpp @@ -319,7 +319,7 @@ void QgsAuthSslImportDialog::sslErrors( const QList &errors ) connect( ui.certificateChainButton, SIGNAL( clicked() ), this, SLOT( showCertificateInfo() ) ); - foreach ( const QSslError &error, errors ) + Q_FOREACH ( const QSslError &error, errors ) { ui.sslErrorList->addItem( error.errorString() ); } diff --git a/src/plugins/geometry_checker/checks/qgsgeometryanglecheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometryanglecheck.cpp index f422399cc454..efe0f5b5124c 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometryanglecheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometryanglecheck.cpp @@ -11,7 +11,7 @@ void QgsGeometryAngleCheck::collectErrors( QList& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const { const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& featureid, featureIds ) + Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) { if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); QgsFeature feature; diff --git a/src/plugins/geometry_checker/checks/qgsgeometryareacheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometryareacheck.cpp index 1640cef38551..730469b4e718 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometryareacheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometryareacheck.cpp @@ -13,7 +13,7 @@ void QgsGeometryAreaCheck::collectErrors( QList& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const { const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& featureid, featureIds ) + Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) { if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); QgsFeature feature; @@ -121,7 +121,7 @@ bool QgsGeometryAreaCheck::mergeWithNeighbor( QgsFeature& feature, int partIdx, QgsAbstractGeometryV2* geom = feature.geometry()->geometry(); // Search for touching neighboring geometries - foreach ( const QgsFeatureId& testId, mFeaturePool->getIntersects( feature.geometry()->boundingBox() ) ) + Q_FOREACH ( const QgsFeatureId& testId, mFeaturePool->getIntersects( feature.geometry()->boundingBox() ) ) { QgsFeature testFeature; if ( !mFeaturePool->get( testId, testFeature ) ) diff --git a/src/plugins/geometry_checker/checks/qgsgeometrycheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometrycheck.cpp index 3b1ff0b28f78..07497c944ed4 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometrycheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometrycheck.cpp @@ -81,7 +81,7 @@ bool QgsGeometryCheckError::handleChanges( const QgsGeometryCheck::Changes& chan return false; } - foreach ( const QgsGeometryCheck::Change& change, changes.value( featureId() ) ) + Q_FOREACH ( const QgsGeometryCheck::Change& change, changes.value( featureId() ) ) { if ( change.what == QgsGeometryCheck::ChangeFeature ) { diff --git a/src/plugins/geometry_checker/checks/qgsgeometrycontainedcheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometrycontainedcheck.cpp index 582b638b861d..3061d5a84f0c 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometrycontainedcheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometrycontainedcheck.cpp @@ -12,7 +12,7 @@ void QgsGeometryContainedCheck::collectErrors( QList& errors, QStringList &messages, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const { const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& featureid, featureIds ) + Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) { if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); QgsFeature feature; @@ -24,7 +24,7 @@ void QgsGeometryContainedCheck::collectErrors( QList& er QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() ); QgsFeatureIds ids = mFeaturePool->getIntersects( feature.geometry()->geometry()->boundingBox() ); - foreach ( const QgsFeatureId& otherid, ids ) + Q_FOREACH ( const QgsFeatureId& otherid, ids ) { if ( otherid == featureid ) { diff --git a/src/plugins/geometry_checker/checks/qgsgeometrydegeneratepolygoncheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometrydegeneratepolygoncheck.cpp index c523fee1497d..50f3a1228884 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometrydegeneratepolygoncheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometrydegeneratepolygoncheck.cpp @@ -11,7 +11,7 @@ void QgsGeometryDegeneratePolygonCheck::collectErrors( QList& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const { const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& featureid, featureIds ) + Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) { if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); QgsFeature feature; diff --git a/src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.cpp index a7e87aa87f0b..32e3e124b955 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.cpp @@ -14,7 +14,7 @@ void QgsGeometryDuplicateCheck::collectErrors( QList& errors, QStringList &messages, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const { const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& featureid, featureIds ) + Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) { if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); QgsFeature feature; @@ -26,7 +26,7 @@ void QgsGeometryDuplicateCheck::collectErrors( QList& er QList duplicates; QgsFeatureIds ids = mFeaturePool->getIntersects( feature.geometry()->geometry()->boundingBox() ); - foreach ( const QgsFeatureId& id, ids ) + Q_FOREACH ( const QgsFeatureId& id, ids ) { // > : only report overlaps once if ( id >= featureid ) @@ -77,7 +77,7 @@ void QgsGeometryDuplicateCheck::fixError( QgsGeometryCheckError* error, int meth QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() ); QgsGeometryDuplicateCheckError* duplicateError = static_cast( error ); - foreach ( const QgsFeatureId& id, duplicateError->duplicates() ) + Q_FOREACH ( const QgsFeatureId& id, duplicateError->duplicates() ) { QgsFeature testFeature; if ( !mFeaturePool->get( id, testFeature ) ) diff --git a/src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.h b/src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.h index 4a807a3d4b19..73c0b759e334 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.h +++ b/src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.h @@ -34,7 +34,7 @@ class QgsGeometryDuplicateCheckError : public QgsGeometryCheckError static inline QString duplicatesString( const QList& duplicates ) { QStringList str; - foreach ( QgsFeatureId id, duplicates ) + Q_FOREACH ( QgsFeatureId id, duplicates ) { str.append( QString::number( id ) ); } diff --git a/src/plugins/geometry_checker/checks/qgsgeometryduplicatenodescheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometryduplicatenodescheck.cpp index 0e3cfc718395..1b79f081e72d 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometryduplicatenodescheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometryduplicatenodescheck.cpp @@ -12,7 +12,7 @@ void QgsGeometryDuplicateNodesCheck::collectErrors( QList& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const { const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& featureid, featureIds ) + Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) { if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); QgsFeature feature; diff --git a/src/plugins/geometry_checker/checks/qgsgeometrygapcheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometrygapcheck.cpp index 6bd6015a48bd..b3d84ea33972 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometrygapcheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometrygapcheck.cpp @@ -19,7 +19,7 @@ void QgsGeometryGapCheck::collectErrors( QList& errors, // Collect geometries, build spatial index QList geomList; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& id, featureIds ) + Q_FOREACH ( const QgsFeatureId& id, featureIds ) { QgsFeature feature; if ( mFeaturePool->get( id, feature ) ) @@ -97,7 +97,7 @@ void QgsGeometryGapCheck::collectErrors( QList& errors, QgsRectangle gapAreaBBox = geom->boundingBox(); QgsFeatureIds intersectIds = mFeaturePool->getIntersects( geom->boundingBox() ); - foreach ( QgsFeatureId id, intersectIds ) + Q_FOREACH ( QgsFeatureId id, intersectIds ) { QgsFeature feature; if ( !mFeaturePool->get( id, feature ) ) @@ -159,7 +159,7 @@ bool QgsGeometryGapCheck::mergeWithNeighbor( QgsGeometryGapCheckError* err, Chan QgsAbstractGeometryV2* errGeometry = QgsGeomUtils::getGeomPart( err->geometry(), 0 ); // Search for touching neighboring geometries - foreach ( const QgsFeatureId& testId, err->neighbors() ) + Q_FOREACH ( const QgsFeatureId& testId, err->neighbors() ) { QgsFeature testFeature; if ( !mFeaturePool->get( testId, testFeature ) ) diff --git a/src/plugins/geometry_checker/checks/qgsgeometryholecheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometryholecheck.cpp index 00dcce943964..939151133e50 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometryholecheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometryholecheck.cpp @@ -11,7 +11,7 @@ void QgsGeometryHoleCheck::collectErrors( QList& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const { const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& featureid, featureIds ) + Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) { if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); QgsFeature feature; diff --git a/src/plugins/geometry_checker/checks/qgsgeometrymultipartcheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometrymultipartcheck.cpp index 5fcb7685c6c7..d1c2caeb8da7 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometrymultipartcheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometrymultipartcheck.cpp @@ -11,7 +11,7 @@ void QgsGeometryMultipartCheck::collectErrors( QList& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const { const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& featureid, featureIds ) + Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) { if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); QgsFeature feature; diff --git a/src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp index fc183a459cd5..0e3930571301 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp @@ -12,7 +12,7 @@ void QgsGeometryOverlapCheck::collectErrors( QList& errors, QStringList &messages, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const { const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& featureid, featureIds ) + Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) { if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); QgsFeature feature; @@ -24,7 +24,7 @@ void QgsGeometryOverlapCheck::collectErrors( QList& erro QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( geom, QgsGeometryCheckPrecision::tolerance() ); QgsFeatureIds ids = mFeaturePool->getIntersects( feature.geometry()->boundingBox() ); - foreach ( const QgsFeatureId& otherid, ids ) + Q_FOREACH ( const QgsFeatureId& otherid, ids ) { // >= : only report overlaps once if ( otherid >= featureid ) diff --git a/src/plugins/geometry_checker/checks/qgsgeometrysegmentlengthcheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometrysegmentlengthcheck.cpp index 1f5fd481188b..11769f789500 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometrysegmentlengthcheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometrysegmentlengthcheck.cpp @@ -14,7 +14,7 @@ void QgsGeometrySegmentLengthCheck::collectErrors( QList& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const { const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& featureid, featureIds ) + Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) { if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); QgsFeature feature; diff --git a/src/plugins/geometry_checker/checks/qgsgeometryselfintersectioncheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometryselfintersectioncheck.cpp index 6911106b19e6..f66745d80b06 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometryselfintersectioncheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometryselfintersectioncheck.cpp @@ -29,7 +29,7 @@ bool QgsGeometrySelfIntersectionCheckError::handleChanges( const QgsGeometryChec { return false; } - foreach ( const QgsGeometryCheck::Change& change, changes.value( featureId() ) ) + Q_FOREACH ( const QgsGeometryCheck::Change& change, changes.value( featureId() ) ) { if ( change.vidx.vertex == mInter.segment1 || change.vidx.vertex == mInter.segment1 + 1 || @@ -57,7 +57,7 @@ bool QgsGeometrySelfIntersectionCheckError::handleChanges( const QgsGeometryChec void QgsGeometrySelfIntersectionCheck::collectErrors( QList& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const { const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& featureid, featureIds ) + Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) { if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); QgsFeature feature; @@ -71,7 +71,7 @@ void QgsGeometrySelfIntersectionCheck::collectErrors( QListringCount( iPart ); iRing < nRings; ++iRing ) { - foreach ( const QgsGeometryUtils::SelfIntersection& inter, QgsGeometryUtils::getSelfIntersections( geom, iPart, iRing, QgsGeometryCheckPrecision::tolerance() ) ) + Q_FOREACH ( const QgsGeometryUtils::SelfIntersection& inter, QgsGeometryUtils::getSelfIntersections( geom, iPart, iRing, QgsGeometryCheckPrecision::tolerance() ) ) { errors.append( new QgsGeometrySelfIntersectionCheckError( this, featureid, inter.point, QgsVertexId( iPart, iRing ), inter ) ); } diff --git a/src/plugins/geometry_checker/checks/qgsgeometrytypecheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometrytypecheck.cpp index d29c46621322..892b7e93b1b1 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometrytypecheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometrytypecheck.cpp @@ -18,7 +18,7 @@ void QgsGeometryTypeCheck::collectErrors( QList& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const { const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; - foreach ( const QgsFeatureId& featureid, featureIds ) + Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) { if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); QgsFeature feature; diff --git a/src/plugins/geometry_checker/qgsgeometrychecker.cpp b/src/plugins/geometry_checker/qgsgeometrychecker.cpp index 5eb181521669..5da5bfc64e7d 100644 --- a/src/plugins/geometry_checker/qgsgeometrychecker.cpp +++ b/src/plugins/geometry_checker/qgsgeometrychecker.cpp @@ -41,7 +41,7 @@ QFuture QgsGeometryChecker::execute( int *totalSteps ) { *totalSteps = 0; int nCheckFeatures = mFeaturePool->getFeatureIds().size(); - foreach ( QgsGeometryCheck* check, mChecks ) + Q_FOREACH ( QgsGeometryCheck* check, mChecks ) { if ( check->getCheckType() <= QgsGeometryCheck::FeatureCheck ) { @@ -98,10 +98,10 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError* error, int method ) // Determine what to recheck // - Collect all features which were changed, get affected area QgsFeatureIds recheckFeatures; - foreach ( const QgsFeatureId& id, changes.keys() ) + Q_FOREACH ( const QgsFeatureId& id, changes.keys() ) { bool removed = false; - foreach ( const QgsGeometryCheck::Change& change, changes.value( id ) ) + Q_FOREACH ( const QgsGeometryCheck::Change& change, changes.value( id ) ) { if ( change.what == QgsGeometryCheck::ChangeFeature && change.type == QgsGeometryCheck::ChangeRemoved ) { @@ -120,7 +120,7 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError* error, int method ) } } // - Determine extent to recheck for gaps - foreach ( QgsGeometryCheckError* err, mCheckErrors ) + Q_FOREACH ( QgsGeometryCheckError* err, mCheckErrors ) { if ( err->check()->getCheckType() == QgsGeometryCheck::LayerCheck ) { @@ -141,7 +141,7 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError* error, int method ) // Recheck feature / changed area to detect new errors QList recheckErrors; - foreach ( const QgsGeometryCheck* check, mChecks ) + Q_FOREACH ( const QgsGeometryCheck* check, mChecks ) { if ( check->getCheckType() == QgsGeometryCheck::LayerCheck ) { @@ -154,7 +154,7 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError* error, int method ) } // Remove just-fixed error from newly-found errors (needed in case error was fixed with "no change") - foreach ( QgsGeometryCheckError* recheckErr, recheckErrors ) + Q_FOREACH ( QgsGeometryCheckError* recheckErr, recheckErrors ) { if ( recheckErr->isEqual( error ) ) { @@ -165,7 +165,7 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError* error, int method ) } // Go through error list, update other errors of the checked feature - foreach ( QgsGeometryCheckError* err, mCheckErrors ) + Q_FOREACH ( QgsGeometryCheckError* err, mCheckErrors ) { if ( err == error || err->status() == QgsGeometryCheckError::StatusObsolete ) { @@ -185,7 +185,7 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError* error, int method ) // Check if this error now matches one found when rechecking the feature/area QgsGeometryCheckError* matchErr = 0; int nMatch = 0; - foreach ( QgsGeometryCheckError* recheckErr, recheckErrors ) + Q_FOREACH ( QgsGeometryCheckError* recheckErr, recheckErrors ) { if ( recheckErr->isEqual( err ) ) { @@ -226,7 +226,7 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError* error, int method ) } // Add new errors - foreach ( QgsGeometryCheckError* recheckErr, recheckErrors ) + Q_FOREACH ( QgsGeometryCheckError* recheckErr, recheckErrors ) { emit errorAdded( recheckErr ); mCheckErrors.append( recheckErr ); @@ -245,7 +245,7 @@ void QgsGeometryChecker::runCheck( const QgsGeometryCheck* check ) mCheckErrors.append( errors ); mMessages.append( messages ); mErrorListMutex.unlock(); - foreach ( QgsGeometryCheckError* error, errors ) + Q_FOREACH ( QgsGeometryCheckError* error, errors ) { emit errorAdded( error ); } diff --git a/src/plugins/geometry_checker/ui/qgsgeometrycheckerfixsummarydialog.cpp b/src/plugins/geometry_checker/ui/qgsgeometrycheckerfixsummarydialog.cpp index efe72b8fece6..55d15255a7c8 100644 --- a/src/plugins/geometry_checker/ui/qgsgeometrycheckerfixsummarydialog.cpp +++ b/src/plugins/geometry_checker/ui/qgsgeometrycheckerfixsummarydialog.cpp @@ -29,19 +29,19 @@ QgsGeometryCheckerFixSummaryDialog::QgsGeometryCheckerFixSummaryDialog( QgisInte ui.groupBoxNotFixed->setTitle( tr( "%1 errors were not fixed" ).arg( stats.failedErrors.count() ) ); ui.groupBoxObsoleteErrors->setTitle( tr( "%1 errors are obsolete" ).arg( stats.obsoleteErrors.count() ) ); - foreach ( QgsGeometryCheckError* error, stats.fixedErrors ) + Q_FOREACH ( QgsGeometryCheckError* error, stats.fixedErrors ) { addError( ui.tableWidgetFixedErrors, error ); } - foreach ( QgsGeometryCheckError* error, stats.newErrors ) + Q_FOREACH ( QgsGeometryCheckError* error, stats.newErrors ) { addError( ui.tableWidgetNewErrors, error ); } - foreach ( QgsGeometryCheckError* error, stats.failedErrors ) + Q_FOREACH ( QgsGeometryCheckError* error, stats.failedErrors ) { addError( ui.tableWidgetNotFixed, error ); } - foreach ( QgsGeometryCheckError* error, stats.obsoleteErrors ) + Q_FOREACH ( QgsGeometryCheckError* error, stats.obsoleteErrors ) { addError( ui.tableWidgetObsoleteErrors, error ); } @@ -114,7 +114,7 @@ void QgsGeometryCheckerFixSummaryDialog::onTableSelectionChanged( const QItemSel { const QAbstractItemModel* model = qobject_cast( QObject::sender() )->model(); - foreach ( QTableWidget* table, QList() << ui.tableWidgetFixedErrors << ui.tableWidgetNewErrors << ui.tableWidgetNotFixed << ui.tableWidgetObsoleteErrors ) + Q_FOREACH ( QTableWidget* table, QList() << ui.tableWidgetFixedErrors << ui.tableWidgetNewErrors << ui.tableWidgetNotFixed << ui.tableWidgetObsoleteErrors ) if ( table->model() != model ) { table->selectionModel()->blockSignals( true ); diff --git a/src/plugins/geometry_checker/ui/qgsgeometrycheckerresulttab.cpp b/src/plugins/geometry_checker/ui/qgsgeometrycheckerresulttab.cpp index 96ea2b1634db..aef9bf1c448a 100644 --- a/src/plugins/geometry_checker/ui/qgsgeometrycheckerresulttab.cpp +++ b/src/plugins/geometry_checker/ui/qgsgeometrycheckerresulttab.cpp @@ -270,7 +270,7 @@ bool QgsGeometryCheckerResultTab::exportErrorsDo( const QString& file ) // Remove existing layer with same uri QStringList toRemove; - foreach ( QgsMapLayer* maplayer, QgsMapLayerRegistry::instance()->mapLayers() ) + Q_FOREACH ( QgsMapLayer* maplayer, QgsMapLayerRegistry::instance()->mapLayers() ) { if ( dynamic_cast( maplayer ) && static_cast( maplayer )->dataProvider()->dataSourceUri() == layer->dataProvider()->dataSourceUri() ) @@ -315,7 +315,7 @@ void QgsGeometryCheckerResultTab::highlightErrors( bool current ) { items.append( ui.tableWidgetErrors->selectedItems() ); } - foreach ( QTableWidgetItem* item, items ) + Q_FOREACH ( QTableWidgetItem* item, items ) { QgsGeometryCheckError* error = ui.tableWidgetErrors->item( item->row(), 0 )->data( Qt::UserRole ).value(); @@ -366,7 +366,7 @@ void QgsGeometryCheckerResultTab::highlightErrors( bool current ) { double cx = 0., cy = 0.; QgsRectangle pointExtent( errorPositions.first(), errorPositions.first() ); - foreach ( const QgsPoint& p, errorPositions ) + Q_FOREACH ( const QgsPoint& p, errorPositions ) { cx += p.x(); cy += p.y(); @@ -407,7 +407,7 @@ void QgsGeometryCheckerResultTab::onSelectionChanged( const QItemSelection &newS void QgsGeometryCheckerResultTab::openAttributeTable() { QSet ids; - foreach ( QModelIndex idx, ui.tableWidgetErrors->selectionModel()->selectedRows() ) + Q_FOREACH ( QModelIndex idx, ui.tableWidgetErrors->selectionModel()->selectedRows() ) { QgsFeatureId id = ui.tableWidgetErrors->item( idx.row(), 0 )->data( Qt::UserRole ).value()->featureId(); if ( id >= 0 ) @@ -420,7 +420,7 @@ void QgsGeometryCheckerResultTab::openAttributeTable() return; } QStringList expr; - foreach ( int id, ids ) + Q_FOREACH ( int id, ids ) { expr.append( QString( "$id = %1 " ).arg( id ) ); } @@ -444,7 +444,7 @@ void QgsGeometryCheckerResultTab::fixErrors( bool prompt ) rows = ui.tableWidgetErrors->selectionModel()->selectedRows(); } QList errors; - foreach ( const QModelIndex& index, rows ) + Q_FOREACH ( const QModelIndex& index, rows ) { QgsGeometryCheckError* error = ui.tableWidgetErrors->item( index.row(), 0 )->data( Qt::UserRole ).value(); if ( error->status() < QgsGeometryCheckError::StatusFixed ) @@ -486,7 +486,7 @@ void QgsGeometryCheckerResultTab::fixErrors( bool prompt ) ui.progressBarFixErrors->setVisible( true ); ui.progressBarFixErrors->setRange( 0, errors.size() ); - foreach ( QgsGeometryCheckError* error, errors ) + Q_FOREACH ( QgsGeometryCheckError* error, errors ) { int fixMethod = QSettings().value( sSettingsGroup + error->check()->errorName(), QVariant::fromValue( 0 ) ).toInt(); mChecker->fixError( error, fixMethod ); @@ -544,7 +544,7 @@ void QgsGeometryCheckerResultTab::setDefaultResolutionMethods() QWidget* scrollAreaContents = new QWidget( scrollArea ); QVBoxLayout* scrollAreaLayout = new QVBoxLayout( scrollAreaContents ); - foreach ( const QgsGeometryCheck* check, mChecker->getChecks() ) + Q_FOREACH ( const QgsGeometryCheck* check, mChecker->getChecks() ) { QGroupBox* groupBox = new QGroupBox( scrollAreaContents ); groupBox->setTitle( check->errorDescription() ); @@ -556,7 +556,7 @@ void QgsGeometryCheckerResultTab::setDefaultResolutionMethods() radioGroup->setProperty( "errorType", check->errorName() ); int id = 0; int checkedId = QSettings().value( sSettingsGroup + check->errorName(), QVariant::fromValue( 0 ) ).toInt(); - foreach ( const QString& method, check->getResolutionMethods() ) + Q_FOREACH ( const QString& method, check->getResolutionMethods() ) { QRadioButton* radio = new QRadioButton( method, groupBox ); radio->setChecked( id == checkedId ); diff --git a/src/plugins/geometry_checker/ui/qgsgeometrycheckersetuptab.cpp b/src/plugins/geometry_checker/ui/qgsgeometrycheckersetuptab.cpp index b94ac6d6c457..dcf50fd2f064 100644 --- a/src/plugins/geometry_checker/ui/qgsgeometrycheckersetuptab.cpp +++ b/src/plugins/geometry_checker/ui/qgsgeometrycheckersetuptab.cpp @@ -64,7 +64,7 @@ QgsGeometryCheckerSetupTab::QgsGeometryCheckerSetupTab( QgisInterface* iface , Q updateLayers(); - foreach ( const QgsGeometryCheckFactory* factory, QgsGeometryCheckFactoryRegistry::getCheckFactories() ) + Q_FOREACH ( const QgsGeometryCheckFactory* factory, QgsGeometryCheckFactoryRegistry::getCheckFactories() ) { factory->restorePrevious( ui ); } @@ -83,7 +83,7 @@ void QgsGeometryCheckerSetupTab::updateLayers() // Collect layers QgsMapLayer* currentLayer = mIface->mapCanvas()->currentLayer(); int currIdx = -1; - foreach ( QgsMapLayer* layer, QgsMapLayerRegistry::instance()->mapLayers() ) + Q_FOREACH ( QgsMapLayer* layer, QgsMapLayerRegistry::instance()->mapLayers() ) { if ( qobject_cast( layer ) ) { @@ -118,7 +118,7 @@ void QgsGeometryCheckerSetupTab::validateInput() int nApplicable = 0; if ( layer != 0 ) { - foreach ( const QgsGeometryCheckFactory* factory, QgsGeometryCheckFactoryRegistry::getCheckFactories() ) + Q_FOREACH ( const QgsGeometryCheckFactory* factory, QgsGeometryCheckFactoryRegistry::getCheckFactories() ) { nApplicable += factory->checkApplicability( ui, layer->geometryType() ); } @@ -131,7 +131,7 @@ void QgsGeometryCheckerSetupTab::selectOutputFile() { QString filterString = QgsVectorFileWriter::filterForDriver( "ESRI Shapefile" ); QMap filterFormatMap = QgsVectorFileWriter::supportedFiltersAndFormats(); - foreach ( const QString& filter, filterFormatMap.keys() ) + Q_FOREACH ( const QString& filter, filterFormatMap.keys() ) { QString driverName = filterFormatMap.value( filter ); if ( driverName != "ESRI Shapefile" ) // Default entry, first in list (see above) @@ -197,7 +197,7 @@ void QgsGeometryCheckerSetupTab::runChecks() // Remove existing layer with same uri QStringList toRemove; - foreach ( QgsMapLayer* maplayer, QgsMapLayerRegistry::instance()->mapLayers() ) + Q_FOREACH ( QgsMapLayer* maplayer, QgsMapLayerRegistry::instance()->mapLayers() ) { if ( dynamic_cast( maplayer ) && static_cast( maplayer )->dataProvider()->dataSourceUri().startsWith( filename ) ) @@ -272,7 +272,7 @@ void QgsGeometryCheckerSetupTab::runChecks() QList checks; double mapToLayer = 1. / mIface->mapCanvas()->mapSettings().layerToMapUnits( layer ); - foreach ( const QgsGeometryCheckFactory* factory, QgsGeometryCheckFactoryRegistry::getCheckFactories() ) + Q_FOREACH ( const QgsGeometryCheckFactory* factory, QgsGeometryCheckFactoryRegistry::getCheckFactories() ) { QgsGeometryCheck* check = factory->createInstance( featurePool, ui, mapToLayer ); if ( check ) diff --git a/src/plugins/geometry_checker/ui/qgsgeometrycheckfixdialog.cpp b/src/plugins/geometry_checker/ui/qgsgeometrycheckfixdialog.cpp index 414c82f969d4..4ffb25295251 100644 --- a/src/plugins/geometry_checker/ui/qgsgeometrycheckfixdialog.cpp +++ b/src/plugins/geometry_checker/ui/qgsgeometrycheckfixdialog.cpp @@ -102,7 +102,7 @@ void QgsGeometryCheckerFixDialog::setupNextError() int id = 0; int checkedid = QSettings().value( QgsGeometryCheckerResultTab::sSettingsGroup + error->check()->errorName(), QVariant::fromValue( 0 ) ).toInt(); - foreach ( const QString& method, error->check()->getResolutionMethods() ) + Q_FOREACH ( const QString& method, error->check()->getResolutionMethods() ) { QRadioButton* radio = new QRadioButton( method ); radio->setChecked( checkedid == id ); diff --git a/src/plugins/geometry_snapper/qgsgeometrysnapper.cpp b/src/plugins/geometry_snapper/qgsgeometrysnapper.cpp index 6675fcc669e2..e841d6e19539 100644 --- a/src/plugins/geometry_snapper/qgsgeometrysnapper.cpp +++ b/src/plugins/geometry_snapper/qgsgeometrysnapper.cpp @@ -75,7 +75,7 @@ void QgsGeometrySnapper::processFeature( const QgsFeatureId &id ) mIndexMutex.lock(); QList refFeatureIds = mIndex.intersects( feature.geometry()->boundingBox() ); mIndexMutex.unlock(); - foreach ( const QgsFeatureId& refId, refFeatureIds ) + Q_FOREACH ( const QgsFeatureId& refId, refFeatureIds ) { QgsFeature refFeature; if ( getFeature( mReferenceLayer, mReferenceLayerMutex, refId, refFeature ) ) @@ -90,7 +90,7 @@ void QgsGeometrySnapper::processFeature( const QgsFeatureId &id ) } } QgsSnapIndex refSnapIndex( center, 10 * snapTolerance ); - foreach ( const QgsAbstractGeometryV2* geom, refGeometries ) + Q_FOREACH ( const QgsAbstractGeometryV2* geom, refGeometries ) { refSnapIndex.addGeometry( geom ); } @@ -146,7 +146,7 @@ void QgsGeometrySnapper::processFeature( const QgsFeatureId &id ) origSubjSnapIndex->addGeometry( origSubjGeom ); // Pass 2: add missing vertices to subject geometry - foreach ( const QgsAbstractGeometryV2* refGeom, refGeometries ) + Q_FOREACH ( const QgsAbstractGeometryV2* refGeom, refGeometries ) { for ( int iPart = 0, nParts = refGeom->partCount(); iPart < nParts; ++iPart ) { diff --git a/src/plugins/geometry_snapper/qgsgeometrysnapperdialog.cpp b/src/plugins/geometry_snapper/qgsgeometrysnapperdialog.cpp index a7f1267e7116..655672720d75 100644 --- a/src/plugins/geometry_snapper/qgsgeometrysnapperdialog.cpp +++ b/src/plugins/geometry_snapper/qgsgeometrysnapperdialog.cpp @@ -72,7 +72,7 @@ void QgsGeometrySnapperDialog::updateLayers() QgsMapLayer* currentLayer = mIface->mapCanvas()->currentLayer(); int curInputIdx = -1; int curReferenceIdx = -1; - foreach ( QgsMapLayer* layer, QgsMapLayerRegistry::instance()->mapLayers() ) + Q_FOREACH ( QgsMapLayer* layer, QgsMapLayerRegistry::instance()->mapLayers() ) { if ( qobject_cast( layer ) ) { @@ -144,7 +144,7 @@ void QgsGeometrySnapperDialog::selectOutputFile() { QString filterString = QgsVectorFileWriter::filterForDriver( "ESRI Shapefile" ); QMap filterFormatMap = QgsVectorFileWriter::supportedFiltersAndFormats(); - foreach ( const QString& filter, filterFormatMap.keys() ) + Q_FOREACH ( const QString& filter, filterFormatMap.keys() ) { QString driverName = filterFormatMap.value( filter ); if ( driverName != "ESRI Shapefile" ) // Default entry, first in list (see above) @@ -198,7 +198,7 @@ void QgsGeometrySnapperDialog::run() // Remove existing layer with same uri QStringList toRemove; - foreach ( QgsMapLayer* maplayer, QgsMapLayerRegistry::instance()->mapLayers() ) + Q_FOREACH ( QgsMapLayer* maplayer, QgsMapLayerRegistry::instance()->mapLayers() ) { if ( dynamic_cast( maplayer ) && static_cast( maplayer )->dataProvider()->dataSourceUri().startsWith( filename ) ) diff --git a/src/plugins/geometry_snapper/qgssnapindex.cpp b/src/plugins/geometry_snapper/qgssnapindex.cpp index 5e75948e2a83..4066666ddc36 100644 --- a/src/plugins/geometry_snapper/qgssnapindex.cpp +++ b/src/plugins/geometry_snapper/qgssnapindex.cpp @@ -173,7 +173,7 @@ class Raytracer QgsSnapIndex::GridRow::~GridRow() { - foreach ( const QgsSnapIndex::Cell& cell, mCells ) + Q_FOREACH ( const QgsSnapIndex::Cell& cell, mCells ) { qDeleteAll( cell ); } @@ -347,7 +347,7 @@ QgsPointV2 QgsSnapIndex::getClosestSnapToPoint( const QgsPointV2& p, const QgsPo { continue; } - foreach ( const SnapItem* item, *cell ) + Q_FOREACH ( const SnapItem* item, *cell ) { if ( item->type == SnapSegment ) { @@ -389,7 +389,7 @@ QgsSnapIndex::SnapItem* QgsSnapIndex::getSnapItem( const QgsPointV2& pos, double QgsSnapIndex::SegmentSnapItem* snapSegment = 0; QgsSnapIndex::PointSnapItem* snapPoint = 0; - foreach ( QgsSnapIndex::SnapItem* item, items ) + Q_FOREACH ( QgsSnapIndex::SnapItem* item, items ) { if ( item->type == SnapPoint ) { diff --git a/src/plugins/grass/qgsgrasseditrenderer.cpp b/src/plugins/grass/qgsgrasseditrenderer.cpp index cb83bd7aa5b2..3638b16b3bf4 100644 --- a/src/plugins/grass/qgsgrasseditrenderer.cpp +++ b/src/plugins/grass/qgsgrasseditrenderer.cpp @@ -64,7 +64,7 @@ QgsGrassEditRenderer::QgsGrassEditRenderer() firstVertexMarkerLine->setPlacement( QgsMarkerLineSymbolLayerV2::FirstVertex ); QgsMarkerLineSymbolLayerV2 * lastVertexMarkerLine = static_cast( firstVertexMarkerLine->clone() ); lastVertexMarkerLine->setPlacement( QgsMarkerLineSymbolLayerV2::LastVertex ); - foreach ( int value, colors.keys() ) + Q_FOREACH ( int value, colors.keys() ) { QgsSymbolV2 * symbol = QgsSymbolV2::defaultSymbol( QGis::Line ); symbol->setColor( colors.value( value ) ); @@ -91,7 +91,7 @@ QgsGrassEditRenderer::QgsGrassEditRenderer() categoryList.clear(); - foreach ( int value, colors.keys() ) + Q_FOREACH ( int value, colors.keys() ) { QgsSymbolV2 * symbol = QgsSymbolV2::defaultSymbol( QGis::Point ); symbol->setColor( colors.value( value ) ); diff --git a/src/plugins/grass/qgsgrassmodule.cpp b/src/plugins/grass/qgsgrassmodule.cpp index f6983624d7a7..0dedb5ba705f 100644 --- a/src/plugins/grass/qgsgrassmodule.cpp +++ b/src/plugins/grass/qgsgrassmodule.cpp @@ -82,7 +82,7 @@ QString QgsGrassModule::findExec( QString file ) #ifdef Q_OS_WIN // On windows try .bat first - foreach ( QString path, QgsGrass::grassModulesPaths() ) + Q_FOREACH ( const QString& path, QgsGrass::grassModulesPaths() ) { QString full = path + "/" + file + ".bat"; if ( QFile::exists( full ) ) @@ -92,7 +92,7 @@ QString QgsGrassModule::findExec( QString file ) } // .exe next - foreach ( QString path, QgsGrass::grassModulesPaths() ) + Q_FOREACH ( const QString& path, QgsGrass::grassModulesPaths() ) { QString full = path + "/" + file + ".exe"; if ( QFile::exists( full ) ) @@ -105,7 +105,7 @@ QString QgsGrassModule::findExec( QString file ) #endif // Search for module - foreach ( const QString& path, QgsGrass::grassModulesPaths() ) + Q_FOREACH ( const QString& path, QgsGrass::grassModulesPaths() ) { QString full = path + "/" + file; if ( QFile::exists( full ) ) @@ -712,7 +712,7 @@ void QgsGrassModule::run() // Print some important variables variables << "QGIS_PREFIX_PATH" << "QGIS_GRASS_CRS" << "GRASS_REGION"; - foreach ( const QString& v, variables ) + Q_FOREACH ( const QString& v, variables ) { mOutputTextBrowser->append( v + "=" + environment.value( v ) + "
" ); } diff --git a/src/plugins/grass/qgsgrassmoduleinput.cpp b/src/plugins/grass/qgsgrassmoduleinput.cpp index c08bfdfd3c13..e82b9d6ad904 100644 --- a/src/plugins/grass/qgsgrassmoduleinput.cpp +++ b/src/plugins/grass/qgsgrassmoduleinput.cpp @@ -98,7 +98,7 @@ void QgsGrassModuleInputModel::onDirectoryChanged( const QString & path ) } } - foreach ( const QString& dirName, dirNames ) + Q_FOREACH ( const QString& dirName, dirNames ) { // Add to watcher in any case, either for WIND, cellhd or vector QString dirPath = locationPath + "/" + dirName; @@ -114,7 +114,7 @@ void QgsGrassModuleInputModel::onDirectoryChanged( const QString & path ) QgsDebugMsg( "mapset = " + path ); QDir dir( path ); mapset = dir.dirName(); - foreach ( QString watchedDir, watchedDirs() ) + Q_FOREACH ( const QString& watchedDir, watchedDirs() ) { watch( path + "/" + watchedDir ); } @@ -211,12 +211,12 @@ void QgsGrassModuleInputModel::refreshMapset( QStandardItem *mapsetItem, const Q types << QgsGrassObject::Raster << QgsGrassObject::Vector; types << QgsGrassObject::Strds << QgsGrassObject::Stvds << QgsGrassObject::Str3ds; } - foreach ( QgsGrassObject::Type type, types ) + Q_FOREACH ( QgsGrassObject::Type type, types ) { QgsGrassObject mapsetObject( QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation(), mapset, "", QgsGrassObject::Mapset ); QStringList maps = QgsGrass::grassObjects( mapsetObject, type ); QStringList mapNames; - foreach ( const QString& map, maps ) + Q_FOREACH ( const QString& map, maps ) { if ( map.startsWith( "qgis_import_tmp_" ) ) { @@ -285,7 +285,7 @@ void QgsGrassModuleInputModel::reload() mLocationPath = QgsGrass::getDefaultLocationPath(); QStringList mapsets = QgsGrass::mapsets( QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation() ); - foreach ( const QString& mapset, mapsets ) + Q_FOREACH ( const QString& mapset, mapsets ) { addMapset( mapset ); } @@ -294,13 +294,13 @@ void QgsGrassModuleInputModel::reload() // Watching all dirs in location because a dir may become a mapset later, when WIND is created QStringList dirNames = locationDirNames(); - foreach ( const QString& dirName, dirNames ) + Q_FOREACH ( const QString& dirName, dirNames ) { QString dirPath = mLocationPath + "/" + dirName; // Watch the dir in any case, WIND mabe created later mWatcher->addPath( dirPath ); - foreach ( QString watchedDir, watchedDirs() ) + Q_FOREACH ( const QString& watchedDir, watchedDirs() ) { watch( dirPath + "/" + watchedDir ); } @@ -839,7 +839,7 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module, { int mask = 0; - foreach ( const QString& typeName, opt.split( "," ) ) + Q_FOREACH ( const QString& typeName, opt.split( "," ) ) { mask |= QgsGrass::vectorType( typeName ); } @@ -952,7 +952,7 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module, QList types; types << GV_POINT << GV_LINE << GV_BOUNDARY << GV_CENTROID << GV_AREA; - foreach ( int type, types ) + Q_FOREACH ( int type, types ) { if ( !( type & mGeometryTypeMask ) ) { @@ -1088,7 +1088,7 @@ QgsGrassVectorLayer * QgsGrassModuleInput::currentLayer() QStringList QgsGrassModuleInput::currentGeometryTypeNames() { QStringList typeNames; - foreach ( int checkBoxType, mTypeCheckBoxes.keys() ) + Q_FOREACH ( int checkBoxType, mTypeCheckBoxes.keys() ) { QCheckBox *checkBox = mTypeCheckBoxes.value( checkBoxType ); if ( checkBox->isChecked() ) @@ -1145,7 +1145,7 @@ void QgsGrassModuleInput::onChanged( const QString & text ) else { // Find layers matching type mask - foreach ( QgsGrassVectorLayer *layer, mVector->layers() ) + Q_FOREACH ( QgsGrassVectorLayer *layer, mVector->layers() ) { QgsDebugMsg( QString( "layer->number() = %1 layer.type() = %2 mGeometryTypeMask = %3" ).arg( layer->number() ).arg( layer->type() ).arg( mGeometryTypeMask ) ); // TODO: does it make sense to add layer 0, i.e. no layer? @@ -1158,7 +1158,7 @@ void QgsGrassModuleInput::onChanged( const QString & text ) QgsDebugMsg( QString( "mLayers.size() = %1" ).arg( mLayers.size() ) ); // Combo is used to get layer even if just one - foreach ( QgsGrassVectorLayer * layer, mLayers ) + Q_FOREACH ( QgsGrassVectorLayer * layer, mLayers ) { mLayerComboBox->addItem( QString::number( layer->number() ), layer->number() ); } @@ -1185,7 +1185,7 @@ void QgsGrassModuleInput::onLayerChanged() { return; } - foreach ( int checkBoxType, mTypeCheckBoxes.keys() ) + Q_FOREACH ( int checkBoxType, mTypeCheckBoxes.keys() ) { QCheckBox *checkBox = mTypeCheckBoxes.value( checkBoxType ); checkBox->setChecked( false ); @@ -1197,7 +1197,7 @@ void QgsGrassModuleInput::onLayerChanged() { // number of types in the layer matching mGeometryTypeMask int typeCount = 0; - foreach ( int type, layer->types() ) + Q_FOREACH ( int type, layer->types() ) { if ( type & mGeometryTypeMask ) { @@ -1207,7 +1207,7 @@ void QgsGrassModuleInput::onLayerChanged() QgsDebugMsg( QString( "typeCount = %1" ).arg( typeCount ) ); int layerType = layer->type(); // may be multiple - foreach ( int checkBoxType, mTypeCheckBoxes.keys() ) + Q_FOREACH ( int checkBoxType, mTypeCheckBoxes.keys() ) { QCheckBox *checkBox = mTypeCheckBoxes.value( checkBoxType ); checkBox->hide(); diff --git a/src/plugins/grass/qgsgrassmoduleoptions.cpp b/src/plugins/grass/qgsgrassmoduleoptions.cpp index 484b5c0e2bcb..36df81a87c4a 100644 --- a/src/plugins/grass/qgsgrassmoduleoptions.cpp +++ b/src/plugins/grass/qgsgrassmoduleoptions.cpp @@ -339,7 +339,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions( // (guidependency missing in GRASS 6) // Add default inter param relations QListvectorInputs; - foreach ( QgsGrassModuleParam *param, mParams ) + Q_FOREACH ( QgsGrassModuleParam *param, mParams ) { QgsGrassModuleInput *vectorInput = dynamic_cast( param ); if ( vectorInput ) @@ -351,7 +351,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions( { QgsDebugMsg( "One input found, try to connect with column options" ); QgsGrassModuleInput *vectorInput = vectorInputs[0]; - foreach ( QgsGrassModuleParam *param, mParams ) + Q_FOREACH ( QgsGrassModuleParam *param, mParams ) { QgsGrassModuleField *moduleField = dynamic_cast( param ); if ( moduleField ) @@ -376,7 +376,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions( layout->addStretch(); } - foreach ( QgsGrassModuleParam* item, mParams ) + Q_FOREACH ( QgsGrassModuleParam* item, mParams ) { mErrors << item->errors(); } diff --git a/src/plugins/grass/qgsgrassmoduleparam.cpp b/src/plugins/grass/qgsgrassmoduleparam.cpp index 95e95a13e60e..406cfcdf1b06 100644 --- a/src/plugins/grass/qgsgrassmoduleparam.cpp +++ b/src/plugins/grass/qgsgrassmoduleparam.cpp @@ -888,7 +888,7 @@ void QgsGrassModuleGdalInput::updateQgisLayers() mLayerComboBox->addItem( tr( "Select a layer" ), QVariant() ); } - foreach ( QgsMapLayer *layer, QgsMapLayerRegistry::instance()->mapLayers().values() ) + Q_FOREACH ( QgsMapLayer *layer, QgsMapLayerRegistry::instance()->mapLayers().values() ) { if ( !layer ) continue; @@ -1078,7 +1078,7 @@ QgsGrassModuleField::QgsGrassModuleField( QgsGrassModule *module, QString key, // Validator is disabled to allow to enter also expressions #if 0 QRegExp rx( "^[a-zA-Z_][a-zA-Z0-9_]*$" ); - foreach ( QLineEdit *lineEdit, mLineEdits ) + Q_FOREACH ( QLineEdit *lineEdit, mLineEdits ) { lineEdit->setValidator( new QRegExpValidator( rx, this ) ); } diff --git a/src/plugins/grass/qgsgrassplugin.cpp b/src/plugins/grass/qgsgrassplugin.cpp index 86fd31522407..cf666c9b425c 100644 --- a/src/plugins/grass/qgsgrassplugin.cpp +++ b/src/plugins/grass/qgsgrassplugin.cpp @@ -460,7 +460,7 @@ void QgsGrassPlugin::onFieldsChanged() QString uri = grassProvider->dataSourceUri(); uri.remove( QRegExp( "[^_]*$" ) ); QgsDebugMsg( "uri = " + uri ); - foreach ( QgsMapLayer *layer, QgsMapLayerRegistry::instance()->mapLayers().values() ) + Q_FOREACH ( QgsMapLayer *layer, QgsMapLayerRegistry::instance()->mapLayers().values() ) { if ( !layer || layer->type() != QgsMapLayer::VectorLayer ) { @@ -826,7 +826,7 @@ void QgsGrassPlugin::unload() disconnect( qGisInterface->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( onCurrentLayerChanged( QgsMapLayer* ) ) ); - foreach ( QgsMapLayer *layer, QgsMapLayerRegistry::instance()->mapLayers().values() ) + Q_FOREACH ( QgsMapLayer *layer, QgsMapLayerRegistry::instance()->mapLayers().values() ) { if ( !layer || layer->type() != QgsMapLayer::VectorLayer ) { diff --git a/src/plugins/grass/qgsgrasstools.cpp b/src/plugins/grass/qgsgrasstools.cpp index 8d7a9352367e..965a70f43561 100644 --- a/src/plugins/grass/qgsgrasstools.cpp +++ b/src/plugins/grass/qgsgrasstools.cpp @@ -730,7 +730,7 @@ int QgsGrassTools::debug( QStandardItem *item ) } QgsGrassModule *module = new QgsGrassModule( this, name, mIface, false ); QgsDebugMsg( QString( "module: %1 errors: %2" ).arg( name ).arg( module->errors().size() ) ); - foreach ( QString error, module->errors() ) + Q_FOREACH ( QString error, module->errors() ) { // each error may have multiple rows and may be html formated (
) label += "\n ERROR:\t" + error.replace( "
", "\n" ).replace( "\n", "\n\t" ); diff --git a/src/providers/grass/qgis.v.in.cpp b/src/providers/grass/qgis.v.in.cpp index 5dbb54a02f3e..a5972d1838c5 100644 --- a/src/providers/grass/qgis.v.in.cpp +++ b/src/providers/grass/qgis.v.in.cpp @@ -50,17 +50,17 @@ extern "C" static struct line_pnts *line = Vect_new_line_struct(); -void writePoint( struct Map_info* map, int type, QgsPoint point, struct line_cats *cats ) +void writePoint( struct Map_info* map, int type, const QgsPoint& point, struct line_cats *cats ) { Vect_reset_line( line ); Vect_append_point( line, point.x(), point.y(), 0 ); Vect_write_line( map, type, line, cats ); } -void writePolyline( struct Map_info* map, int type, QgsPolyline polyline, struct line_cats *cats ) +void writePolyline( struct Map_info* map, int type, const QgsPolyline& polyline, struct line_cats *cats ) { Vect_reset_line( line ); - foreach ( QgsPoint point, polyline ) + Q_FOREACH ( const QgsPoint& point, polyline ) { Vect_append_point( line, point.x(), point.y(), 0 ); } @@ -264,7 +264,7 @@ int main( int argc, char **argv ) else if ( geometryType == QGis::WKBMultiPoint ) { QgsMultiPoint multiPoint = geometry->asMultiPoint(); - foreach ( QgsPoint point, multiPoint ) + Q_FOREACH ( const QgsPoint& point, multiPoint ) { writePoint( map, GV_POINT, point, cats ); } @@ -277,7 +277,7 @@ int main( int argc, char **argv ) else if ( geometryType == QGis::WKBMultiLineString ) { QgsMultiPolyline multiPolyline = geometry->asMultiPolyline(); - foreach ( QgsPolyline polyline, multiPolyline ) + Q_FOREACH ( const QgsPolyline& polyline, multiPolyline ) { writePolyline( map, GV_LINE, polyline, cats ); } @@ -285,7 +285,7 @@ int main( int argc, char **argv ) else if ( geometryType == QGis::WKBPolygon ) { QgsPolygon polygon = geometry->asPolygon(); - foreach ( QgsPolyline polyline, polygon ) + Q_FOREACH ( const QgsPolyline& polyline, polygon ) { writePolyline( map, GV_BOUNDARY, polyline, cats ); } @@ -293,9 +293,9 @@ int main( int argc, char **argv ) else if ( geometryType == QGis::WKBMultiPolygon ) { QgsMultiPolygon multiPolygon = geometry->asMultiPolygon(); - foreach ( QgsPolygon polygon, multiPolygon ) + Q_FOREACH ( const QgsPolygon& polygon, multiPolygon ) { - foreach ( QgsPolyline polyline, polygon ) + Q_FOREACH ( const QgsPolyline& polyline, polygon ) { writePolyline( map, GV_BOUNDARY, polyline, cats ); } @@ -429,7 +429,7 @@ int main( int argc, char **argv ) } QList idList = spatialIndex.intersects( feature.geometry()->boundingBox() ); - foreach ( QgsFeatureId id, idList ) + Q_FOREACH ( QgsFeatureId id, idList ) { QgsFeature& centroid = centroids[id]; if ( feature.geometry()->contains( centroid.geometry() ) ) @@ -450,14 +450,14 @@ int main( int argc, char **argv ) int centroidsCount = centroids.size(); count = 0; - foreach ( QgsFeature centroid, centroids.values() ) + Q_FOREACH ( QgsFeature centroid, centroids.values() ) { QgsPoint point = centroid.geometry()->asPoint(); if ( centroid.attributes().size() > 0 ) { Vect_reset_cats( cats ); - foreach ( QVariant attribute, centroid.attributes() ) + Q_FOREACH ( const QVariant& attribute, centroid.attributes() ) { Vect_cat_set( cats, 1, attribute.toInt() ); } diff --git a/src/providers/grass/qgsgrass.cpp b/src/providers/grass/qgsgrass.cpp index 54ddc3c1309d..ae333b6170d7 100644 --- a/src/providers/grass/qgsgrass.cpp +++ b/src/providers/grass/qgsgrass.cpp @@ -1293,7 +1293,7 @@ QStringList QgsGrass::vectorLayers( const QString& gisdbase, const QString& loca QgsDebugMsg( "GRASS vector successfully opened" ); // Get layers - foreach ( QgsGrassVectorLayer * layer, vector.layers() ) + Q_FOREACH ( QgsGrassVectorLayer * layer, vector.layers() ) { QString fs = QString::number( layer->number() ); QgsDebugMsg( "layer number = " + fs ); @@ -2420,7 +2420,7 @@ void QgsGrass::insertRow( dbDriver *driver, const QString tableName, } QStringList valuesStringList; - foreach ( const QVariant& attribute, attributes ) + Q_FOREACH ( const QVariant& attribute, attributes ) { QString valueString; diff --git a/src/providers/grass/qgsgrassfeatureiterator.cpp b/src/providers/grass/qgsgrassfeatureiterator.cpp index 577fc9cb838d..bc5320a764ba 100644 --- a/src/providers/grass/qgsgrassfeatureiterator.cpp +++ b/src/providers/grass/qgsgrassfeatureiterator.cpp @@ -255,7 +255,7 @@ bool QgsGrassFeatureIterator::fetchFeature( QgsFeature& feature ) if ( mSource->mEditing ) { QgsDebugMsgLevel( "newLids:", 3 ); - foreach ( int oldLid, mSource->mLayer->map()->newLids().keys() ) + Q_FOREACH ( int oldLid, mSource->mLayer->map()->newLids().keys() ) { QgsDebugMsgLevel( QString( "%1 -> %2" ).arg( oldLid ).arg( mSource->mLayer->map()->newLids().value( oldLid ) ), 3 ); } diff --git a/src/providers/grass/qgsgrassimport.cpp b/src/providers/grass/qgsgrassimport.cpp index bdf2137e0498..d0f25a49a81f 100644 --- a/src/providers/grass/qgsgrassimport.cpp +++ b/src/providers/grass/qgsgrassimport.cpp @@ -515,7 +515,7 @@ QStringList QgsGrassRasterImport::names() const QStringList list; if ( mPipe && mPipe->provider() ) { - foreach ( const QString& ext, extensions( mPipe->provider() ) ) + Q_FOREACH ( const QString& ext, extensions( mPipe->provider() ) ) { list << mGrassObject.name() + ext; } diff --git a/src/providers/grass/qgsgrassprovidermodule.cpp b/src/providers/grass/qgsgrassprovidermodule.cpp index 31eb330a2109..344b49967158 100644 --- a/src/providers/grass/qgsgrassprovidermodule.cpp +++ b/src/providers/grass/qgsgrassprovidermodule.cpp @@ -319,7 +319,7 @@ QVectorQgsGrassLocationItem::createChildren() QDir dir( mDirPath ); QStringList entries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name ); - foreach ( const QString& name, entries ) + Q_FOREACH ( const QString& name, entries ) { QString path = dir.absoluteFilePath( name ); @@ -385,7 +385,7 @@ void QgsGrassMapsetItem::setState( State state ) bool QgsGrassMapsetItem::objectInImports( QgsGrassObject grassObject ) { - foreach ( QgsGrassImport* import, mImports ) + Q_FOREACH ( QgsGrassImport* import, mImports ) { if ( !import ) { @@ -500,7 +500,7 @@ QVector QgsGrassMapsetItem::createChildren() //map->setCapabilities( QgsDataItem::NoCapabilities ); // disable fertility map = new QgsGrassVectorItem( this, vectorObject, mapPath ); } - foreach ( const QString& layerName, layerNames ) + Q_FOREACH ( const QString& layerName, layerNames ) { // don't use QDir::separator(), windows work with '/' and backslash may be lost if // somewhere not properly escaped (there was bug in QgsMimeDataUtils for example) @@ -539,7 +539,7 @@ QVector QgsGrassMapsetItem::createChildren() QStringList rasterNames = QgsGrass::rasters( mDirPath ); - foreach ( const QString& name, rasterNames ) + Q_FOREACH ( const QString& name, rasterNames ) { if ( mRefreshLater ) { @@ -562,7 +562,7 @@ QVector QgsGrassMapsetItem::createChildren() } QStringList groupNames = QgsGrass::groups( mDirPath ); - foreach ( const QString& name, groupNames ) + Q_FOREACH ( const QString& name, groupNames ) { if ( mRefreshLater ) { @@ -578,7 +578,7 @@ QVector QgsGrassMapsetItem::createChildren() items.append( layer ); } - foreach ( QgsGrassImport* import, mImports ) + Q_FOREACH ( QgsGrassImport* import, mImports ) { if ( mRefreshLater ) { @@ -593,7 +593,7 @@ QVector QgsGrassMapsetItem::createChildren() { continue; } - foreach ( QString name, import->names() ) + Q_FOREACH ( const QString& name, import->names() ) { QString path = mPath + "/" + import->grassObject().elementName() + "/" + name; items.append( new QgsGrassImportItem( this, name, path, import ) ); @@ -615,7 +615,7 @@ bool QgsGrassMapsetItem::handleDrop( const QMimeData * data, Qt::DropAction ) QStringList existingRasters = QgsGrass::rasters( mGrassObject.mapsetPath() ); QStringList existingVectors = QgsGrass::vectors( mGrassObject.mapsetPath() ); // add currently being imported - foreach ( QgsGrassImport* import, mImports ) + Q_FOREACH ( QgsGrassImport* import, mImports ) { if ( import && import->grassObject().type() == QgsGrassObject::Raster ) { @@ -631,7 +631,7 @@ bool QgsGrassMapsetItem::handleDrop( const QMimeData * data, Qt::DropAction ) QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( data ); Qt::CaseSensitivity caseSensitivity = QgsGrass::caseSensitivity(); - foreach ( const QgsMimeDataUtils::Uri& u, lst ) + Q_FOREACH ( const QgsMimeDataUtils::Uri& u, lst ) { if ( u.layerType != "raster" && u.layerType != "vector" ) { @@ -809,7 +809,7 @@ bool QgsGrassMapsetItem::handleDrop( const QMimeData * data, Qt::DropAction ) // delete existing files (confirmed before in dialog) bool deleteOk = true; - foreach ( const QString& name, import->names() ) + Q_FOREACH ( const QString& name, import->names() ) { QgsGrassObject obj( import->grassObject() ); obj.setName( name ); diff --git a/src/providers/grass/qgsgrassrasterprovider.cpp b/src/providers/grass/qgsgrassrasterprovider.cpp index 99efdbaaccef..61161f0490d7 100644 --- a/src/providers/grass/qgsgrassrasterprovider.cpp +++ b/src/providers/grass/qgsgrassrasterprovider.cpp @@ -335,7 +335,7 @@ QgsRasterBandStats QgsGrassRasterProvider::bandStatistics( int theBandNo, int th QgsRasterBandStats myRasterBandStats; initStatistics( myRasterBandStats, theBandNo, theStats, theExtent, theSampleSize ); - foreach ( QgsRasterBandStats stats, mStatistics ) + Q_FOREACH ( const QgsRasterBandStats& stats, mStatistics ) { if ( stats.contains( myRasterBandStats ) ) { @@ -627,7 +627,7 @@ QDateTime QgsGrassRasterProvider::dataTimestamp() const QString mapset = mGisdbase + "/" + mLocation + "/" + mMapset; QStringList dirs; dirs << "cell" << "colr"; - foreach ( const QString& dir, dirs ) + Q_FOREACH ( const QString& dir, dirs ) { QString path = mapset + "/" + dir + "/" + mMapName; QFileInfo fi( path ); diff --git a/src/providers/grass/qgsgrassvector.cpp b/src/providers/grass/qgsgrassvector.cpp index f2430c3fbf59..e3a4573aabeb 100644 --- a/src/providers/grass/qgsgrassvector.cpp +++ b/src/providers/grass/qgsgrassvector.cpp @@ -66,7 +66,7 @@ QgsGrassVectorLayer::~QgsGrassVectorLayer() int QgsGrassVectorLayer::typeCount( int type ) const { int count = 0; - foreach ( int t, mTypeCounts.keys() ) + Q_FOREACH ( int t, mTypeCounts.keys() ) { if ( t & type ) { @@ -79,7 +79,7 @@ int QgsGrassVectorLayer::typeCount( int type ) const int QgsGrassVectorLayer::type() const { int type = 0; - foreach ( int t, mTypeCounts.keys() ) + Q_FOREACH ( int t, mTypeCounts.keys() ) { if ( mTypeCounts.value( t ) > 0 ) { @@ -92,7 +92,7 @@ int QgsGrassVectorLayer::type() const QList QgsGrassVectorLayer::types() const { QList types; - foreach ( int t, mTypeCounts.keys() ) + Q_FOREACH ( int t, mTypeCounts.keys() ) { if ( mTypeCounts.value( t ) > 0 ) { @@ -206,7 +206,7 @@ QgsGrassVector::QgsGrassVector( const QgsGrassObject& grassObject, QObject *pare bool QgsGrassVector::openHead() { - foreach ( QgsGrassVectorLayer *layer, mLayers ) + Q_FOREACH ( QgsGrassVectorLayer *layer, mLayers ) { layer->deleteLater(); } @@ -291,7 +291,7 @@ bool QgsGrassVector::openHead() struct field_info *fieldInfo = Vect_get_field( map, field ); // should work also with field = 0 QgsGrassVectorLayer *layer = new QgsGrassVectorLayer( mGrassObject, field, fieldInfo, this ); - foreach ( int type, QgsGrass::vectorTypeMap().keys() ) + Q_FOREACH ( int type, QgsGrass::vectorTypeMap().keys() ) { int count = Vect_cidx_get_type_count( map, field, type ); if ( count > 0 ) @@ -305,7 +305,7 @@ bool QgsGrassVector::openHead() QgsDebugMsg( "standard layers listed: " + list.join( "," ) ); // Get primitives - foreach ( int type, QgsGrass::vectorTypeMap().keys() ) + Q_FOREACH ( int type, QgsGrass::vectorTypeMap().keys() ) { if ( type == GV_AREA ) { @@ -339,7 +339,7 @@ bool QgsGrassVector::openHead() int QgsGrassVector::typeCount( int type ) const { int count = 0; - foreach ( int t, mTypeCounts.keys() ) + Q_FOREACH ( int t, mTypeCounts.keys() ) { if ( t & type ) { @@ -352,7 +352,7 @@ int QgsGrassVector::typeCount( int type ) const int QgsGrassVector::maxLayerNumber() const { int max = 0; - foreach ( QgsGrassVectorLayer *layer, mLayers ) + Q_FOREACH ( QgsGrassVectorLayer *layer, mLayers ) { max = qMax( max, layer->number() ); } diff --git a/src/providers/grass/qgsgrassvectormap.cpp b/src/providers/grass/qgsgrassvectormap.cpp index 3cb3ae48efa9..7e2a7eb5e346 100644 --- a/src/providers/grass/qgsgrassvectormap.cpp +++ b/src/providers/grass/qgsgrassvectormap.cpp @@ -68,7 +68,7 @@ QgsGrassVectorMap::~QgsGrassVectorMap() int QgsGrassVectorMap::userCount() const { int count = 0; - foreach ( QgsGrassVectorMapLayer *layer, mLayers ) + Q_FOREACH ( QgsGrassVectorMapLayer *layer, mLayers ) { count += layer->userCount(); } @@ -369,7 +369,7 @@ QgsGrassVectorMapLayer * QgsGrassVectorMap::openLayer( int field ) lockOpenClose(); QgsGrassVectorMapLayer *layer = 0; // Check if this layer is already open - foreach ( QgsGrassVectorMapLayer *l, mLayers ) + Q_FOREACH ( QgsGrassVectorMapLayer *l, mLayers ) { if ( l->field() == field ) { @@ -398,7 +398,7 @@ QgsGrassVectorMapLayer * QgsGrassVectorMap::openLayer( int field ) void QgsGrassVectorMap::reloadLayers() { QgsDebugMsg( "entered" ); - foreach ( QgsGrassVectorMapLayer *l, mLayers ) + Q_FOREACH ( QgsGrassVectorMapLayer *l, mLayers ) { l->load(); } @@ -734,7 +734,7 @@ QgsGrassVectorMap * QgsGrassVectorMapStore::openMap( const QgsGrassObject & gras QgsGrassVectorMap *map = 0; // Check if this map is already open - foreach ( QgsGrassVectorMap *m, mMaps ) + Q_FOREACH ( QgsGrassVectorMap *m, mMaps ) { if ( m->grassObject() == grassObject ) { diff --git a/tests/src/providers/grass/testqgsgrassprovider.cpp b/tests/src/providers/grass/testqgsgrassprovider.cpp index 76325e719910..b53761f22128 100644 --- a/tests/src/providers/grass/testqgsgrassprovider.cpp +++ b/tests/src/providers/grass/testqgsgrassprovider.cpp @@ -352,7 +352,7 @@ void TestQgsGrassProvider::mapsets() QgsGrass::setLocation( tmpGisdbase, mLocation ); // for G_is_mapset_in_search_path // Disabled because adding of all mapsets to search path was disabled in setLocation() #if 0 - foreach ( QString expectedMapset, expectedMapsets ) + Q_FOREACH ( QString expectedMapset, expectedMapsets ) { if ( G_is_mapset_in_search_path( expectedMapset.toAscii().data() ) != 1 ) { @@ -517,7 +517,7 @@ void TestQgsGrassProvider::info() es.minimumValue = -20.25; es.maximumValue = 20.25; expectedStats.insert( "fcell", es ); - foreach ( QString map, expectedStats.keys() ) + Q_FOREACH ( const QString& map, expectedStats.keys() ) { es = expectedStats.value( map ); // TODO: QgsGrass::info() may open dialog window on error which blocks tests @@ -607,7 +607,7 @@ bool TestQgsGrassProvider::copyRecursively( const QString &srcFilePath, const QS } QDir sourceDir( srcFilePath ); QStringList fileNames = sourceDir.entryList( QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System ); - foreach ( const QString &fileName, fileNames ) + Q_FOREACH ( const QString &fileName, fileNames ) { const QString newSrcFilePath = srcFilePath + QLatin1Char( '/' ) + fileName; @@ -645,7 +645,7 @@ bool TestQgsGrassProvider::removeRecursively( const QString &filePath, QString * QDir dir( filePath ); QStringList fileNames = dir.entryList( QDir::Files | QDir::Hidden | QDir::System | QDir::Dirs | QDir::NoDotAndDotDot ); - foreach ( const QString &fileName, fileNames ) + Q_FOREACH ( const QString &fileName, fileNames ) { if ( !removeRecursively( filePath + QLatin1Char( '/' ) + fileName, error ) ) return false; @@ -720,7 +720,7 @@ bool TestQgsGrassProvider::createTmpLocation( QString& tmpGisdbase, QString& tmp QStringList cpFiles; cpFiles << "DEFAULT_WIND" << "WIND" << "PROJ_INFO" << "PROJ_UNITS"; QString templateMapsetPath = mGisdbase + "/" + mLocation + "/PERMANENT"; - foreach ( QString cpFile, cpFiles ) + Q_FOREACH ( const QString& cpFile, cpFiles ) { if ( !QFile::copy( templateMapsetPath + "/" + cpFile, tmpMapsetPath + "/" + cpFile ) ) { @@ -752,7 +752,7 @@ void TestQgsGrassProvider::rasterImport() rasterFiles << "raster/band1_float32_noct_epsg4326.tif" << "raster/band3_int16_noct_epsg4326.tif"; QgsCoordinateReferenceSystem mapsetCrs = QgsGrass::crsDirect( mGisdbase, mLocation ); - foreach ( QString rasterFile, rasterFiles ) + Q_FOREACH ( const QString& rasterFile, rasterFiles ) { QString uri = QString( TEST_DATA_DIR ) + "/" + rasterFile; QString name = QFileInfo( uri ).baseName(); @@ -824,7 +824,7 @@ void TestQgsGrassProvider::vectorImport() files << "polys_overlapping.shp" << "bug5598.shp"; QgsCoordinateReferenceSystem mapsetCrs = QgsGrass::crsDirect( mGisdbase, mLocation ); - foreach ( QString file, files ) + Q_FOREACH ( const QString& file, files ) { QString uri = QString( TEST_DATA_DIR ) + "/" + file; QString name = QFileInfo( uri ).baseName();