diff --git a/src/app/composer/qgscomposerlegendwidget.cpp b/src/app/composer/qgscomposerlegendwidget.cpp index de62a7e7487..0f61208dc69 100644 --- a/src/app/composer/qgscomposerlegendwidget.cpp +++ b/src/app/composer/qgscomposerlegendwidget.cpp @@ -795,7 +795,7 @@ void QgsComposerLegendWidget::resetLayerNodeToDefaults() mLegend->beginCommand( tr( "Legend updated" ) ); - foreach ( QString key, nodeLayer->customProperties() ) + foreach ( const QString& key, nodeLayer->customProperties() ) { if ( key.startsWith( "legend/" ) ) nodeLayer->removeCustomProperty( key ); diff --git a/src/app/composer/qgscomposermapwidget.cpp b/src/app/composer/qgscomposermapwidget.cpp index e936ba5fa82..8e0d2703104 100644 --- a/src/app/composer/qgscomposermapwidget.cpp +++ b/src/app/composer/qgscomposermapwidget.cpp @@ -298,7 +298,7 @@ void QgsComposerMapWidget::aboutToShowVisibilityPresetsMenu() return; menu->clear(); - foreach ( QString presetName, QgsProject::instance()->visibilityPresetCollection()->presets() ) + foreach ( const QString& presetName, QgsProject::instance()->visibilityPresetCollection()->presets() ) { QAction* a = menu->addAction( presetName, this, SLOT( visibilityPresetSelected() ) ); a->setCheckable( true ); diff --git a/src/app/main.cpp b/src/app/main.cpp index 1e6cfb6de07..c0d5d141e54 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -1141,7 +1141,7 @@ APP_EXPORT int main( int argc, char *argv[] ) QList< QPair > layers; if ( !dxfPreset.isEmpty() ) { - foreach ( QString layer, QgsProject::instance()->visibilityPresetCollection()->presetVisibleLayers( dxfPreset ) ) + foreach ( const QString& layer, QgsProject::instance()->visibilityPresetCollection()->presetVisibleLayers( dxfPreset ) ) { QgsVectorLayer *vl = qobject_cast( QgsMapLayerRegistry::instance()->mapLayer( layer ) ); if ( !vl ) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 231aad83cf2..21369afb2a5 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -2870,7 +2870,7 @@ void QgisApp::updateProjectFromTemplates() mProjectFromTemplateMenu->clear(); // Add entries - foreach ( QString templateFile, templateFiles ) + foreach ( const QString& templateFile, templateFiles ) { mProjectFromTemplateMenu->addAction( templateFile ); } @@ -3003,7 +3003,7 @@ QString QgisApp::crsAndFormatAdjustedLayerUri( const QString &uri, const QString // Adjust layer CRS to project CRS QgsCoordinateReferenceSystem testCrs; - foreach ( QString c, supportedCrs ) + foreach ( const QString& c, supportedCrs ) { testCrs.createFromOgcWmsCrs( c ); if ( testCrs == mMapCanvas->mapSettings().destinationCrs() ) @@ -3016,7 +3016,7 @@ QString QgisApp::crsAndFormatAdjustedLayerUri( const QString &uri, const QString // Use the last used image format QString lastImageEncoding = QSettings().value( "/qgis/lastWmsImageEncoding", "image/png" ).toString(); - foreach ( QString fmt, supportedFormats ) + foreach ( const QString& fmt, supportedFormats ) { if ( fmt == lastImageEncoding ) { @@ -3561,7 +3561,7 @@ void QgisApp::addDatabaseLayers( QStringList const & layerPathList, QString cons QApplication::setOverrideCursor( Qt::WaitCursor ); - foreach ( QString layerPath, layerPathList ) + foreach ( const QString& layerPath, layerPathList ) { // create the layer QgsDataSourceURI uri( layerPath ); diff --git a/src/app/qgsbookmarks.cpp b/src/app/qgsbookmarks.cpp index a55aa3f7b6c..84e059d0c0c 100644 --- a/src/app/qgsbookmarks.cpp +++ b/src/app/qgsbookmarks.cpp @@ -293,7 +293,7 @@ void QgsBookmarks::importFromXML() QStringList queriesList = queries.split( ";" ); QSqlQuery query( model->database() ); - foreach ( QString queryTxt, queriesList ) + foreach ( const QString& queryTxt, queriesList ) { if ( queryTxt.trimmed().isEmpty() ) { diff --git a/src/app/qgsbrowserdockwidget.cpp b/src/app/qgsbrowserdockwidget.cpp index 202b73bd37e..37da56792cf 100644 --- a/src/app/qgsbrowserdockwidget.cpp +++ b/src/app/qgsbrowserdockwidget.cpp @@ -135,7 +135,7 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel mREList.clear(); if ( mPatternSyntax == "normal" ) { - foreach ( QString f, mFilter.split( "|" ) ) + foreach ( const QString& f, mFilter.split( "|" ) ) { QRegExp rx( QString( "*%1*" ).arg( f.trimmed() ) ); rx.setPatternSyntax( QRegExp::Wildcard ); @@ -145,7 +145,7 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel } else if ( mPatternSyntax == "wildcard" ) { - foreach ( QString f, mFilter.split( "|" ) ) + foreach ( const QString& f, mFilter.split( "|" ) ) { QRegExp rx( f.trimmed() ); rx.setPatternSyntax( QRegExp::Wildcard ); @@ -175,7 +175,7 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel { if ( mPatternSyntax == "normal" || mPatternSyntax == "wildcard" ) { - foreach ( QRegExp rx, mREList ) + foreach ( const QRegExp& rx, mREList ) { QgsDebugMsg( QString( "value: [%1] rx: [%2] match: %3" ).arg( value ).arg( rx.pattern() ).arg( rx.exactMatch( value ) ) ); if ( rx.exactMatch( value ) ) @@ -184,7 +184,7 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel } else { - foreach ( QRegExp rx, mREList ) + foreach ( const QRegExp& rx, mREList ) { QgsDebugMsg( QString( "value: [%1] rx: [%2] match: %3" ).arg( value ).arg( rx.pattern() ).arg( rx.indexIn( value ) ) ); if ( rx.indexIn( value ) != -1 ) diff --git a/src/app/qgsclipboard.cpp b/src/app/qgsclipboard.cpp index f0d16f0aa03..f59faefd571 100644 --- a/src/app/qgsclipboard.cpp +++ b/src/app/qgsclipboard.cpp @@ -162,7 +162,7 @@ QgsFeatureList QgsClipboard::copyOf( const QgsFields &fields ) return mFeatureClipboard; QgsFeatureList features; - foreach ( QString row, values ) + foreach ( const QString& row, values ) { // Assume that it's just WKT for now. QgsGeometry* geometry = QgsGeometry::fromWkt( row ); diff --git a/src/app/qgsmaptoolfeatureaction.cpp b/src/app/qgsmaptoolfeatureaction.cpp index dfef6408561..baf0cab9555 100644 --- a/src/app/qgsmaptoolfeatureaction.cpp +++ b/src/app/qgsmaptoolfeatureaction.cpp @@ -131,7 +131,7 @@ bool QgsMapToolFeatureAction::doAction( QgsVectorLayer *layer, int x, int y ) if ( featList.size() == 0 ) return false; - foreach ( QgsFeature feat, featList ) + foreach ( const QgsFeature& feat, featList ) { if ( layer->actions()->defaultAction() >= 0 ) { diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp index 9ecfe7b24c3..340e29d2671 100644 --- a/src/app/qgsoptions.cpp +++ b/src/app/qgsoptions.cpp @@ -750,7 +750,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) : lblSystemLocale->setText( tr( "Detected active locale on your system: %1" ).arg( mySystemLocale ) ); QString myUserLocale = settings.value( "locale/userLocale", "" ).toString(); QStringList myI18nList = i18nList(); - foreach ( QString l, myI18nList ) + foreach ( const QString& l, myI18nList ) { cboLocale->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( l ) ), QLocale( l ).nativeLanguageName(), l ); } @@ -1762,11 +1762,11 @@ void QgsOptions::loadGdalDriverList() // myDrivers.sort(); // sort list case insensitive - no existing function for this! QMap strMap; - foreach ( QString str, myDrivers ) + foreach ( const QString& str, myDrivers ) strMap.insert( str.toLower(), str ); myDrivers = strMap.values(); - foreach ( QString myName, myDrivers ) + foreach ( const QString& myName, myDrivers ) { QTreeWidgetItem * mypItem = new QTreeWidgetItem( QStringList( myName ) ); if ( mySkippedDrivers.contains( myName ) ) @@ -1794,13 +1794,13 @@ void QgsOptions::loadGdalDriverList() // populate cmbEditCreateOptions with gdal write drivers - sorted, GTiff first strMap.clear(); - foreach ( QString str, myGdalWriteDrivers ) + foreach ( const QString& str, myGdalWriteDrivers ) strMap.insert( str.toLower(), str ); myGdalWriteDrivers = strMap.values(); myGdalWriteDrivers.removeAll( "Gtiff" ); myGdalWriteDrivers.prepend( "GTiff" ); cmbEditCreateOptions->clear(); - foreach ( QString myName, myGdalWriteDrivers ) + foreach ( const QString& myName, myGdalWriteDrivers ) { cmbEditCreateOptions->addItem( myName ); } diff --git a/src/app/qgspluginregistry.cpp b/src/app/qgspluginregistry.cpp index 96409696bb2..714b57de274 100644 --- a/src/app/qgspluginregistry.cpp +++ b/src/app/qgspluginregistry.cpp @@ -138,8 +138,9 @@ void QgsPluginRegistry::dump() if ( mPythonUtils && mPythonUtils->isEnabled() ) { QgsDebugMsg( "PYTHON PLUGINS IN REGISTRY:" ); - foreach ( QString pluginName, mPythonUtils->listActivePlugins() ) + foreach ( const QString& pluginName, mPythonUtils->listActivePlugins() ) { + Q_UNUSED( pluginName ); QgsDebugMsg( pluginName ); } } @@ -176,7 +177,7 @@ void QgsPluginRegistry::unloadAll() if ( mPythonUtils && mPythonUtils->isEnabled() ) { - foreach ( QString pluginName, mPythonUtils->listActivePlugins() ) + foreach ( const QString& pluginName, mPythonUtils->listActivePlugins() ) { mPythonUtils->unloadPlugin( pluginName ); } diff --git a/src/app/qgsprojectlayergroupdialog.cpp b/src/app/qgsprojectlayergroupdialog.cpp index ca0efbda9e1..8a7f7a05524 100644 --- a/src/app/qgsprojectlayergroupdialog.cpp +++ b/src/app/qgsprojectlayergroupdialog.cpp @@ -62,7 +62,7 @@ QStringList QgsProjectLayerGroupDialog::selectedGroups() const { QStringList groups; QgsLayerTreeModel* model = mTreeView->layerTreeModel(); - foreach ( QModelIndex index, mTreeView->selectionModel()->selectedIndexes() ) + foreach ( const QModelIndex& index, mTreeView->selectionModel()->selectedIndexes() ) { QgsLayerTreeNode* node = model->index2node( index ); if ( QgsLayerTree::isGroup( node ) ) @@ -75,7 +75,7 @@ QStringList QgsProjectLayerGroupDialog::selectedLayerIds() const { QStringList layerIds; QgsLayerTreeModel* model = mTreeView->layerTreeModel(); - foreach ( QModelIndex index, mTreeView->selectionModel()->selectedIndexes() ) + foreach ( const QModelIndex& index, mTreeView->selectionModel()->selectedIndexes() ) { QgsLayerTreeNode* node = model->index2node( index ); if ( QgsLayerTree::isLayer( node ) ) @@ -88,7 +88,7 @@ QStringList QgsProjectLayerGroupDialog::selectedLayerNames() const { QStringList layerNames; QgsLayerTreeModel* model = mTreeView->layerTreeModel(); - foreach ( QModelIndex index, mTreeView->selectionModel()->selectedIndexes() ) + foreach ( const QModelIndex& index, mTreeView->selectionModel()->selectedIndexes() ) { QgsLayerTreeNode* node = model->index2node( index ); if ( QgsLayerTree::isLayer( node ) ) @@ -204,7 +204,7 @@ void QgsProjectLayerGroupDialog::removeEmbeddedNodes( QgsLayerTreeGroup* node ) void QgsProjectLayerGroupDialog::onTreeViewSelectionChanged() { - foreach ( QModelIndex index, mTreeView->selectionModel()->selectedIndexes() ) + foreach ( const QModelIndex& index, mTreeView->selectionModel()->selectedIndexes() ) { unselectChildren( index ); } diff --git a/src/app/qgsprojectproperties.cpp b/src/app/qgsprojectproperties.cpp index ea2398cdbd4..fcf5f2f0a2e 100644 --- a/src/app/qgsprojectproperties.cpp +++ b/src/app/qgsprojectproperties.cpp @@ -311,7 +311,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa if ( grpWMSList->isChecked() ) { QStringList list; - foreach ( QString value, values ) + foreach ( const QString& value, values ) { list << QString( "EPSG:%1" ).arg( value ); } diff --git a/src/app/qgsrasterlayerproperties.cpp b/src/app/qgsrasterlayerproperties.cpp index 3b3e409b0c6..7f25df6eee9 100644 --- a/src/app/qgsrasterlayerproperties.cpp +++ b/src/app/qgsrasterlayerproperties.cpp @@ -355,7 +355,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv //fill available renderers into combo box QgsRasterRendererRegistryEntry entry; - foreach ( QString name, QgsRasterRendererRegistry::instance()->renderersList() ) + foreach ( const QString& name, QgsRasterRendererRegistry::instance()->renderersList() ) { if ( QgsRasterRendererRegistry::instance()->rendererData( name, entry ) ) { diff --git a/src/app/qgssnappingdialog.cpp b/src/app/qgssnappingdialog.cpp index 7475eeb5d0f..cbb5c91b887 100644 --- a/src/app/qgssnappingdialog.cpp +++ b/src/app/qgssnappingdialog.cpp @@ -459,7 +459,7 @@ void QgsSnappingDialog::addLayer( QgsMapLayer *theMapLayer ) void QgsSnappingDialog::layersWillBeRemoved( QStringList thelayers ) { - foreach ( QString theLayerId, thelayers ) + foreach ( const QString& theLayerId, thelayers ) { QTreeWidgetItem *item = 0; diff --git a/src/app/qgsvisibilitypresets.cpp b/src/app/qgsvisibilitypresets.cpp index 16d1130eb80..bd1d395882b 100644 --- a/src/app/qgsvisibilitypresets.cpp +++ b/src/app/qgsvisibilitypresets.cpp @@ -59,7 +59,7 @@ void QgsVisibilityPresets::addPerLayerCheckedLegendSymbols( QgsVisibilityPresetC { QgsLayerTreeModel* model = QgisApp::instance()->layerTreeView()->layerTreeModel(); - foreach ( QString layerID, rec.mVisibleLayerIDs ) + foreach ( const QString& layerID, rec.mVisibleLayerIDs ) { QgsLayerTreeLayer* nodeLayer = model->rootGroup()->findLayer( layerID ); if ( !nodeLayer ) @@ -90,7 +90,7 @@ void QgsVisibilityPresets::addPerLayerCurrentStyle( QgsVisibilityPresetCollectio { QgsLayerTreeModel* model = QgisApp::instance()->layerTreeView()->layerTreeModel(); - foreach ( QString layerID, rec.mVisibleLayerIDs ) + foreach ( const QString& layerID, rec.mVisibleLayerIDs ) { QgsLayerTreeLayer* nodeLayer = model->rootGroup()->findLayer( layerID ); if ( !nodeLayer ) @@ -136,7 +136,7 @@ QStringList QgsVisibilityPresets::orderedPresetVisibleLayers( const QString& nam QgsLayerTreeMapCanvasBridge* bridge = QgisApp::instance()->layerTreeCanvasBridge(); QStringList order = bridge->hasCustomLayerOrder() ? bridge->customLayerOrder() : bridge->defaultLayerOrder(); QStringList order2; - foreach ( QString layerID, order ) + foreach ( const QString& layerID, order ) { if ( visibleIds.contains( layerID ) ) order2 << layerID; diff --git a/src/core/composer/qgsatlascomposition.cpp b/src/core/composer/qgsatlascomposition.cpp index fd13ec21e6c..d582ab2b33d 100644 --- a/src/core/composer/qgsatlascomposition.cpp +++ b/src/core/composer/qgsatlascomposition.cpp @@ -70,7 +70,7 @@ void QgsAtlasComposition::removeLayers( QStringList layers ) return; } - foreach ( QString layerId, layers ) + foreach ( const QString& layerId, layers ) { if ( layerId == mCoverageLayer->id() ) { diff --git a/src/core/composer/qgscomposermap.cpp b/src/core/composer/qgscomposermap.cpp index 523d53971cf..9f8c5547cfc 100644 --- a/src/core/composer/qgscomposermap.cpp +++ b/src/core/composer/qgscomposermap.cpp @@ -555,7 +555,7 @@ QStringList QgsComposerMap::layersToRender() const QStringList layerNames = exprVal.toString().split( "|" ); //need to convert layer names to layer ids - Q_FOREACH ( QString name, layerNames ) + Q_FOREACH ( const QString& name, layerNames ) { QList< QgsMapLayer* > matchingLayers = QgsMapLayerRegistry::instance()->mapLayersByName( name ); Q_FOREACH ( QgsMapLayer* layer, matchingLayers ) diff --git a/src/core/composer/qgscomposertablev2.cpp b/src/core/composer/qgscomposertablev2.cpp index fc863123db0..5288e26a81f 100644 --- a/src/core/composer/qgscomposertablev2.cpp +++ b/src/core/composer/qgscomposertablev2.cpp @@ -942,7 +942,7 @@ bool QgsComposerTableV2::calculateMaxColumnWidths() //column width set to automatic, so check content size QStringList multiLineSplit = ( *colIt ).toString().split( "\n" ); currentCellTextWidth = 0; - Q_FOREACH ( QString line, multiLineSplit ) + Q_FOREACH ( const QString& line, multiLineSplit ) { currentCellTextWidth = qMax( currentCellTextWidth, QgsComposerUtils::textWidthMM( mContentFont, line ) ); } @@ -1168,7 +1168,7 @@ bool QgsComposerTableV2::textRequiresWrapping( const QString& text, double colum QStringList multiLineSplit = text.split( "\n" ); double currentTextWidth = 0; - Q_FOREACH ( QString line, multiLineSplit ) + Q_FOREACH ( const QString& line, multiLineSplit ) { currentTextWidth = qMax( currentTextWidth, QgsComposerUtils::textWidthMM( font, line ) ); } @@ -1180,7 +1180,7 @@ QString QgsComposerTableV2::wrappedText( const QString &value, double columnWidt { QStringList lines = value.split( "\n" ); QStringList outLines; - Q_FOREACH ( QString line, lines ) + Q_FOREACH ( const QString& line, lines ) { if ( textRequiresWrapping( line, columnWidth, font ) ) { @@ -1188,7 +1188,7 @@ QString QgsComposerTableV2::wrappedText( const QString &value, double columnWidt QStringList words = line.split( " " ); QStringList linesToProcess; QString wordsInCurrentLine; - Q_FOREACH ( QString word, words ) + Q_FOREACH ( const QString& word, words ) { if ( textRequiresWrapping( word, columnWidth, font ) ) { @@ -1208,7 +1208,7 @@ QString QgsComposerTableV2::wrappedText( const QString &value, double columnWidt if ( !wordsInCurrentLine.isEmpty() ) linesToProcess << wordsInCurrentLine; - Q_FOREACH ( QString line, linesToProcess ) + Q_FOREACH ( const QString& line, linesToProcess ) { QString remainingText = line; int lastPos = remainingText.lastIndexOf( " " ); diff --git a/src/core/diagram/qgshistogramdiagram.cpp b/src/core/diagram/qgshistogramdiagram.cpp index cde130f1dca..5bd32bc87d9 100644 --- a/src/core/diagram/qgshistogramdiagram.cpp +++ b/src/core/diagram/qgshistogramdiagram.cpp @@ -53,7 +53,7 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsFeature& feature, const QgsRen if ( feature.fields() ) expressionContext.setFields( *feature.fields() ); - foreach ( QString cat, s.categoryAttributes ) + foreach ( const QString& cat, s.categoryAttributes ) { QgsExpression* expression = getExpression( cat, expressionContext ); maxValue = qMax( expression->evaluate( &expressionContext ).toDouble(), maxValue ); @@ -135,7 +135,7 @@ void QgsHistogramDiagram::renderDiagram( const QgsFeature& feature, QgsRenderCon if ( feature.fields() ) expressionContext.setFields( *feature.fields() ); - foreach ( QString cat, s.categoryAttributes ) + foreach ( const QString& cat, s.categoryAttributes ) { QgsExpression* expression = getExpression( cat, expressionContext ); double currentVal = expression->evaluate( &expressionContext ).toDouble(); diff --git a/src/core/dxf/qgsdxfexport.cpp b/src/core/dxf/qgsdxfexport.cpp index 4199d58a5b8..37dd41e7e88 100644 --- a/src/core/dxf/qgsdxfexport.cpp +++ b/src/core/dxf/qgsdxfexport.cpp @@ -588,7 +588,7 @@ void QgsDxfExport::writeTables() writeGroup( 100, "AcDbSymbolTable" ); writeGroup( 70, 0 ); - foreach ( QString block, QStringList() << "*Model_Space" << "*Paper_Space" << "*Paper_Space0" ) + foreach ( const QString& block, QStringList() << "*Model_Space" << "*Paper_Space" << "*Paper_Space0" ) { writeGroup( 0, "BLOCK_RECORD" ); mBlockHandles.insert( block, writeHandle() ); @@ -722,7 +722,7 @@ void QgsDxfExport::writeTables() { QList values; layerIt->first->uniqueValues( layerIt->second, values ); - foreach ( QVariant v, values ) + foreach ( const QVariant& v, values ) { layerNames << dxfLayerName( v.toString() ); } @@ -748,7 +748,7 @@ void QgsDxfExport::writeTables() writeGroup( 6, "CONTINUOUS" ); writeHandle( 390, DXF_HANDPLOTSTYLE ); - foreach ( QString layerName, layerNames ) + foreach ( const QString& layerName, layerNames ) { writeGroup( 0, "LAYER" ); writeHandle(); @@ -794,7 +794,7 @@ void QgsDxfExport::writeBlocks() startSection(); writeGroup( 2, "BLOCKS" ); - foreach ( QString block, QStringList() << "*Model_Space" << "*Paper_Space" << "*Paper_Space0" ) + foreach ( const QString& block, QStringList() << "*Model_Space" << "*Paper_Space" << "*Paper_Space0" ) { writeGroup( 0, "BLOCK" ); writeHandle(); @@ -3869,7 +3869,7 @@ QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > > QgsDxfExport::symbolLayers( Qg void QgsDxfExport::writeDefaultLinetypes() { // continuous (Qt solid line) - foreach ( QString ltype, QStringList() << "ByLayer" << "ByBlock" << "CONTINUOUS" ) + foreach ( const QString& ltype, QStringList() << "ByLayer" << "ByBlock" << "CONTINUOUS" ) { writeGroup( 0, "LTYPE" ); writeHandle(); diff --git a/src/core/effects/qgspainteffectregistry.cpp b/src/core/effects/qgspainteffectregistry.cpp index c24fc3e5fcc..90c6789eab9 100644 --- a/src/core/effects/qgspainteffectregistry.cpp +++ b/src/core/effects/qgspainteffectregistry.cpp @@ -53,7 +53,7 @@ QgsPaintEffectRegistry::QgsPaintEffectRegistry() QgsPaintEffectRegistry::~QgsPaintEffectRegistry() { - foreach ( QString name, mMetadata.keys() ) + foreach ( const QString& name, mMetadata.keys() ) { delete mMetadata[name]; } diff --git a/src/core/gps/qgsgpsdetector.cpp b/src/core/gps/qgsgpsdetector.cpp index 9d56b1a56cf..aa541b578b9 100644 --- a/src/core/gps/qgsgpsdetector.cpp +++ b/src/core/gps/qgsgpsdetector.cpp @@ -44,7 +44,7 @@ QList< QPair > QgsGPSDetector::availablePorts() #ifdef Q_OS_LINUX // look for linux serial devices - foreach ( QString linuxDev, QStringList() << "/dev/ttyS%1" << "/dev/ttyUSB%1" << "/dev/rfcomm%1" << "/dev/ttyACM%1" ) + foreach ( const QString& linuxDev, QStringList() << "/dev/ttyS%1" << "/dev/ttyUSB%1" << "/dev/rfcomm%1" << "/dev/ttyACM%1" ) { for ( int i = 0; i < 10; ++i ) { @@ -58,7 +58,7 @@ QList< QPair > QgsGPSDetector::availablePorts() #ifdef Q_OS_FREEBSD // and freebsd devices (untested) - foreach ( QString freebsdDev, QStringList() << "/dev/cuaa%1" << "/dev/ucom%1" ) + foreach ( const QString& freebsdDev, QStringList() << "/dev/cuaa%1" << "/dev/ucom%1" ) { for ( int i = 0; i < 10; ++i ) { diff --git a/src/core/layertree/qgslayertreemodel.cpp b/src/core/layertree/qgslayertreemodel.cpp index 3016944313c..bd56b29891a 100644 --- a/src/core/layertree/qgslayertreemodel.cpp +++ b/src/core/layertree/qgslayertreemodel.cpp @@ -415,7 +415,7 @@ static bool _isChildOfNodes( QgsLayerTreeNode* child, QList n QList QgsLayerTreeModel::indexes2nodes( const QModelIndexList& list, bool skipInternal ) const { QList nodes; - foreach ( QModelIndex index, list ) + foreach ( const QModelIndex& index, list ) { QgsLayerTreeNode* node = index2node( index ); if ( !node ) diff --git a/src/core/layertree/qgslayertreeregistrybridge.cpp b/src/core/layertree/qgslayertreeregistrybridge.cpp index b22042f3e5f..69e24dd6963 100644 --- a/src/core/layertree/qgslayertreeregistrybridge.cpp +++ b/src/core/layertree/qgslayertreeregistrybridge.cpp @@ -84,7 +84,7 @@ void QgsLayerTreeRegistryBridge::layersWillBeRemoved( QStringList layerIds ) // the registry _again_ in groupRemovedChildren() - this prevents it mRegistryRemovingLayers = true; - foreach ( QString layerId, layerIds ) + foreach ( const QString& layerId, layerIds ) { QgsLayerTreeLayer* nodeLayer = mRoot->findLayer( layerId ); if ( nodeLayer ) @@ -132,7 +132,7 @@ void QgsLayerTreeRegistryBridge::groupRemovedChildren() // remove only those that really do not exist in the tree // (ignores layers that were dragged'n'dropped: 1. drop new 2. remove old) QStringList toRemove; - foreach ( QString layerId, mLayerIdsForRemoval ) + foreach ( const QString& layerId, mLayerIdsForRemoval ) if ( !mRoot->findLayer( layerId ) ) toRemove << layerId; mLayerIdsForRemoval.clear(); diff --git a/src/core/layertree/qgslayertreeutils.cpp b/src/core/layertree/qgslayertreeutils.cpp index cabd70bda12..51efeac8be9 100644 --- a/src/core/layertree/qgslayertreeutils.cpp +++ b/src/core/layertree/qgslayertreeutils.cpp @@ -95,7 +95,7 @@ bool QgsLayerTreeUtils::readOldLegendLayerOrder( const QDomElement& legendElem, if ( !res && hasCustomOrder ) return false; // invalid state - foreach ( QString layerId, layerIndexes ) + foreach ( const QString& layerId, layerIndexes ) { QgsDebugMsg( layerId ); order.append( layerId ); diff --git a/src/core/pal/layer.cpp b/src/core/pal/layer.cpp index 5f21fc191ea..9ed336601dd 100644 --- a/src/core/pal/layer.cpp +++ b/src/core/pal/layer.cpp @@ -312,7 +312,7 @@ namespace pal void Layer::joinConnectedFeatures() { // go through all label texts - Q_FOREACH ( QString labelText, mConnectedTexts ) + Q_FOREACH ( const QString& labelText, mConnectedTexts ) { if ( !mConnectedHashtable.contains( labelText ) ) continue; // shouldn't happen diff --git a/src/core/pal/pal.cpp b/src/core/pal/pal.cpp index 23a3cc0e8de..754d46b5657 100644 --- a/src/core/pal/pal.cpp +++ b/src/core/pal/pal.cpp @@ -313,7 +313,7 @@ namespace pal QStringList layersWithFeaturesInBBox; mMutex.lock(); - Q_FOREACH ( QString layerName, layerNames ) + Q_FOREACH ( const QString& layerName, layerNames ) { layer = mLayers.value( layerName, 0 ); if ( !layer ) diff --git a/src/core/qgsapplication.cpp b/src/core/qgsapplication.cpp index 8704c455a11..709bda3fc5a 100644 --- a/src/core/qgsapplication.cpp +++ b/src/core/qgsapplication.cpp @@ -1025,14 +1025,14 @@ void QgsApplication::copyPath( QString src, QString dst ) if ( ! dir.exists() ) return; - foreach ( QString d, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) ) + foreach ( const QString& d, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) ) { QString dst_path = dst + QDir::separator() + d; dir.mkpath( dst_path ); copyPath( src + QDir::separator() + d, dst_path ); } - foreach ( QString f, dir.entryList( QDir::Files ) ) + foreach ( const QString& f, dir.entryList( QDir::Files ) ) { QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f ); } diff --git a/src/core/qgsbrowsermodel.cpp b/src/core/qgsbrowsermodel.cpp index 3fa9ed7f41c..c6ac28be179 100644 --- a/src/core/qgsbrowsermodel.cpp +++ b/src/core/qgsbrowsermodel.cpp @@ -109,7 +109,7 @@ void QgsBrowserModel::addRootItems() } // add drives - foreach ( QFileInfo drive, QDir::drives() ) + foreach ( const QFileInfo& drive, QDir::drives() ) { QString path = drive.absolutePath(); QgsDirectoryItem *item = new QgsDirectoryItem( NULL, path, path ); diff --git a/src/core/qgscolorscheme.cpp b/src/core/qgscolorscheme.cpp index 64cc7f03d30..02a37e88922 100644 --- a/src/core/qgscolorscheme.cpp +++ b/src/core/qgscolorscheme.cpp @@ -69,7 +69,7 @@ QgsNamedColorList QgsRecentColorScheme::fetchColors( const QString &context, con //generate list from recent colors QgsNamedColorList colorList; - foreach ( QVariant color, recentColorVariants ) + foreach ( const QVariant& color, recentColorVariants ) { colorList.append( qMakePair( color.value(), QgsSymbolLayerV2Utils::colorToName( color.value() ) ) ); } diff --git a/src/core/qgsconditionalstyle.cpp b/src/core/qgsconditionalstyle.cpp index 350e20f0137..35c8cd8fccb 100644 --- a/src/core/qgsconditionalstyle.cpp +++ b/src/core/qgsconditionalstyle.cpp @@ -38,7 +38,7 @@ bool QgsConditionalLayerStyles::writeXml( QDomNode &node, QDomDocument &doc ) co { QDomElement stylesel = doc.createElement( "conditionalstyles" ); QDomElement rowel = doc.createElement( "rowstyles" ); - foreach ( QgsConditionalStyle style, mRowStyles ) + foreach ( const QgsConditionalStyle& style, mRowStyles ) { style.writeXml( rowel, doc ); } @@ -51,7 +51,7 @@ bool QgsConditionalLayerStyles::writeXml( QDomNode &node, QDomDocument &doc ) co QDomElement fieldel = doc.createElement( "fieldstyle" ); fieldel.setAttribute( "fieldname", field ); QgsConditionalStyles styles = mFieldStyles[field]; - foreach ( QgsConditionalStyle style, styles ) + foreach ( const QgsConditionalStyle& style, styles ) { style.writeXml( fieldel, doc ); } @@ -225,7 +225,7 @@ bool QgsConditionalStyle::validTextColor() const QList QgsConditionalStyle::matchingConditionalStyles( QList styles, QVariant value, QgsExpressionContext& context ) { QList matchingstyles; - foreach ( QgsConditionalStyle style, styles ) + foreach ( const QgsConditionalStyle& style, styles ) { if ( style.matches( value, context ) ) matchingstyles.append( style ); @@ -235,7 +235,7 @@ QList QgsConditionalStyle::matchingConditionalStyles( QList QgsConditionalStyle QgsConditionalStyle::matchingConditionalStyle( QList styles, QVariant value, QgsExpressionContext& context ) { - foreach ( QgsConditionalStyle style, styles ) + foreach ( const QgsConditionalStyle& style, styles ) { if ( style.matches( value, context ) ) return style; @@ -246,7 +246,7 @@ QgsConditionalStyle QgsConditionalStyle::matchingConditionalStyle( QList styles ) { QgsConditionalStyle style; - foreach ( QgsConditionalStyle s, styles ) + foreach ( const QgsConditionalStyle& s, styles ) { style.setFont( s.font() ); if ( s.backgroundColor().isValid() && s.backgroundColor().alpha() != 0 ) @@ -259,7 +259,7 @@ QgsConditionalStyle QgsConditionalStyle::compressStyles( QList QgsDirectoryItem::createChildren() { QVector children; QDir dir( mDirPath ); - QSettings settings; QStringList entries = dir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase ); - foreach ( QString subdir, entries ) + foreach ( const QString& subdir, entries ) { if ( mRefreshLater ) { @@ -796,7 +795,7 @@ QVector QgsDirectoryItem::createChildren() } QStringList fileEntries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files, QDir::Name ); - foreach ( QString name, fileEntries ) + foreach ( const QString& name, fileEntries ) { if ( mRefreshLater ) { @@ -931,7 +930,7 @@ QgsDirectoryParamWidget::QgsDirectoryParamWidget( QString path, QWidget* parent QDir dir( path ); QStringList entries = dir.entryList( QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase ); - foreach ( QString name, entries ) + foreach ( const QString& name, entries ) { QFileInfo fi( dir.absoluteFilePath( name ) ); QStringList texts; @@ -1002,7 +1001,7 @@ QgsDirectoryParamWidget::QgsDirectoryParamWidget( QString path, QWidget* parent // hide columns that are not requested QSettings settings; QList lst = settings.value( "/dataitem/directoryHiddenColumns" ).toList(); - foreach ( QVariant colVariant, lst ) + foreach ( const QVariant& colVariant, lst ) { setColumnHidden( colVariant.toInt(), true ); } @@ -1083,7 +1082,7 @@ QVector QgsFavouritesItem::createChildren() QSettings settings; QStringList favDirs = settings.value( "/browser/favourites", QVariant() ).toStringList(); - foreach ( QString favDir, favDirs ) + foreach ( const QString& favDir, favDirs ) { QString pathName = pathComponent( favDir ); QgsDataItem *item = new QgsDirectoryItem( this, favDir, favDir, mPath + "/" + pathName ); @@ -1303,7 +1302,7 @@ QVector QgsZipItem::createChildren() getZipFileList(); // loop over files inside zip - foreach ( QString fileName, mZipFileList ) + foreach ( const QString& fileName, mZipFileList ) { QFileInfo info( fileName ); tmpPath = mVsiPrefix + mFilePath + "/" + fileName; diff --git a/src/core/qgsdataitemproviderregistry.cpp b/src/core/qgsdataitemproviderregistry.cpp index 545619f3ed8..ddf921e632d 100644 --- a/src/core/qgsdataitemproviderregistry.cpp +++ b/src/core/qgsdataitemproviderregistry.cpp @@ -55,7 +55,7 @@ QgsDataItemProviderRegistry::QgsDataItemProviderRegistry() { QStringList providersList = QgsProviderRegistry::instance()->providerList(); - foreach ( QString key, providersList ) + foreach ( const QString& key, providersList ) { QLibrary *library = QgsProviderRegistry::instance()->providerLibrary( key ); if ( !library ) diff --git a/src/core/qgsdatasourceuri.cpp b/src/core/qgsdatasourceuri.cpp index e527bf62aa8..f30dbf564a5 100644 --- a/src/core/qgsdatasourceuri.cpp +++ b/src/core/qgsdatasourceuri.cpp @@ -548,9 +548,9 @@ QString QgsDataSourceURI::uri() const QByteArray QgsDataSourceURI::encodedUri() const { QUrl url; - foreach ( QString key, mParams.uniqueKeys() ) + foreach ( const QString& key, mParams.uniqueKeys() ) { - foreach ( QString value, mParams.values( key ) ) + foreach ( const QString& value, mParams.values( key ) ) { url.addQueryItem( key, value ); } @@ -660,7 +660,7 @@ void QgsDataSourceURI::setParam( const QString &key, const QString &value ) void QgsDataSourceURI::setParam( const QString &key, const QStringList &value ) { - foreach ( QString val, value ) + foreach ( const QString& val, value ) { mParams.insertMulti( key, val ); } diff --git a/src/core/qgserror.cpp b/src/core/qgserror.cpp index 2ccd2a4243c..cb74279388f 100644 --- a/src/core/qgserror.cpp +++ b/src/core/qgserror.cpp @@ -64,7 +64,7 @@ QString QgsError::message( QgsErrorMessage::Format theFormat ) const } #endif - foreach ( QgsErrorMessage m, mMessageList ) + foreach ( const QgsErrorMessage& m, mMessageList ) { #ifdef QGISDEBUG QString file; diff --git a/src/core/qgsexpression.cpp b/src/core/qgsexpression.cpp index f0989dbdb75..cd86477324c 100644 --- a/src/core/qgsexpression.cpp +++ b/src/core/qgsexpression.cpp @@ -73,7 +73,7 @@ QgsExpression::Interval QgsExpression::Interval::fromString( QString string ) map.insert( 0 + MONTHS, QStringList() << "month" << "months" << QObject::tr( "month|months", "list of words separated by | which reference months" ).split( "|" ) ); map.insert( 0 + YEARS, QStringList() << "year" << "years" << QObject::tr( "year|years", "list of words separated by | which reference years" ).split( "|" ) ); - foreach ( QString match, list ) + foreach ( const QString& match, list ) { QStringList split = match.split( QRegExp( "\\s+" ) ); bool ok; @@ -86,7 +86,7 @@ QgsExpression::Interval QgsExpression::Interval::fromString( QString string ) bool matched = false; foreach ( int duration, map.keys() ) { - foreach ( QString name, map[duration] ) + foreach ( const QString& name, map[duration] ) { if ( match.contains( name, Qt::CaseInsensitive ) ) { @@ -2184,7 +2184,7 @@ int QgsExpression::functionIndex( const QString &name ) { if ( QString::compare( name, Functions()[i]->name(), Qt::CaseInsensitive ) == 0 ) return i; - foreach ( QString alias, Functions()[i]->aliases() ) + foreach ( const QString& alias, Functions()[i]->aliases() ) { if ( QString::compare( name, alias, Qt::CaseInsensitive ) == 0 ) return i; diff --git a/src/core/qgsexpressioncontext.cpp b/src/core/qgsexpressioncontext.cpp index c965adb6c32..c78a1ab32e4 100644 --- a/src/core/qgsexpressioncontext.cpp +++ b/src/core/qgsexpressioncontext.cpp @@ -46,7 +46,7 @@ QgsExpressionContextScope::QgsExpressionContextScope( const QgsExpressionContext : mName( other.mName ) , mVariables( other.mVariables ) { - Q_FOREACH ( QString key, other.mFunctions.keys() ) + Q_FOREACH ( const QString& key, other.mFunctions.keys() ) { mFunctions.insert( key, other.mFunctions.value( key )->clone() ); } @@ -59,7 +59,7 @@ QgsExpressionContextScope& QgsExpressionContextScope::operator=( const QgsExpres qDeleteAll( mFunctions ); mFunctions.clear(); - Q_FOREACH ( QString key, other.mFunctions.keys() ) + Q_FOREACH ( const QString& key, other.mFunctions.keys() ) { mFunctions.insert( key, other.mFunctions.value( key )->clone() ); } @@ -269,7 +269,7 @@ QStringList QgsExpressionContext::filteredVariableNames() const { QStringList allVariables = variableNames(); QStringList filtered; - Q_FOREACH ( QString variable, allVariables ) + Q_FOREACH ( const QString& variable, allVariables ) { if ( variable.startsWith( "_" ) ) continue; @@ -432,7 +432,7 @@ void QgsExpressionContextUtils::setGlobalVariables( const QgsStringMap &variable QList< QVariant > customVariableVariants; QList< QVariant > customVariableNames; - Q_FOREACH ( QString variable, variables.keys() ) + Q_FOREACH ( const QString& variable, variables.keys() ) { customVariableNames << variable; customVariableVariants << variables.value( variable ); @@ -502,7 +502,7 @@ QgsExpressionContextScope* QgsExpressionContextUtils::projectScope() QStringList variableValues = project->readListEntry( "Variables", "/variableValues" ); int varIndex = 0; - foreach ( QString variableName, variableNames ) + foreach ( const QString& variableName, variableNames ) { if ( varIndex >= variableValues.length() ) { @@ -547,7 +547,7 @@ void QgsExpressionContextUtils::setProjectVariables( const QgsStringMap &variabl QStringList variableNames; QStringList variableValues; - Q_FOREACH ( QString variable, variables.keys() ) + Q_FOREACH ( const QString& variable, variables.keys() ) { variableNames << variable; variableValues << variables.value( variable ); @@ -569,7 +569,7 @@ QgsExpressionContextScope* QgsExpressionContextUtils::layerScope( const QgsMapLa QStringList variableValues = layer->customProperty( "variableValues" ).toStringList(); int varIndex = 0; - foreach ( QString variableName, variableNames ) + foreach ( const QString& variableName, variableNames ) { if ( varIndex >= variableValues.length() ) { @@ -621,7 +621,7 @@ void QgsExpressionContextUtils::setLayerVariables( QgsMapLayer* layer, const Qgs QStringList variableNames; QStringList variableValues; - Q_FOREACH ( QString variable, variables.keys() ) + Q_FOREACH ( const QString& variable, variables.keys() ) { variableNames << variable; variableValues << variables.value( variable ); @@ -654,7 +654,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::compositionScope( const Qg QStringList variableValues = composition->customProperty( "variableValues" ).toStringList(); int varIndex = 0; - foreach ( QString variableName, variableNames ) + foreach ( const QString& variableName, variableNames ) { if ( varIndex >= variableValues.length() ) { @@ -699,7 +699,7 @@ void QgsExpressionContextUtils::setCompositionVariables( QgsComposition* composi QStringList variableNames; QStringList variableValues; - Q_FOREACH ( QString variable, variables.keys() ) + Q_FOREACH ( const QString& variable, variables.keys() ) { variableNames << variable; variableValues << variables.value( variable ); @@ -757,7 +757,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::composerItemScope( const Q QStringList variableValues = composerItem->customProperty( "variableValues" ).toStringList(); int varIndex = 0; - foreach ( QString variableName, variableNames ) + foreach ( const QString& variableName, variableNames ) { if ( varIndex >= variableValues.length() ) { @@ -801,7 +801,7 @@ void QgsExpressionContextUtils::setComposerItemVariables( QgsComposerItem* compo QStringList variableNames; QStringList variableValues; - Q_FOREACH ( QString variable, variables.keys() ) + Q_FOREACH ( const QString& variable, variables.keys() ) { variableNames << variable; variableValues << variables.value( variable ); diff --git a/src/core/qgsgmlschema.cpp b/src/core/qgsgmlschema.cpp index 1ee741db1d4..c564a92d0b0 100644 --- a/src/core/qgsgmlschema.cpp +++ b/src/core/qgsgmlschema.cpp @@ -106,7 +106,7 @@ bool QgsGmlSchema::parseXSD( const QByteArray &xml ) //QgsDebugMsg( QString( "%1 elemets read" ).arg( elementElements.size() ) ); - foreach ( QDomElement elementElement, elementElements ) + foreach ( const QDomElement& elementElement, elementElements ) { QString name = elementElement.attribute( "name" ); QString type = elementElement.attribute( "type" ); @@ -160,7 +160,7 @@ bool QgsGmlSchema::xsdFeatureClass( const QDomElement &element, const QString & // Supported geometry types QStringList geometryPropertyTypes; - foreach ( QString geom, mGeometryTypes ) + foreach ( const QString& geom, mGeometryTypes ) { geometryPropertyTypes << geom + "PropertyType"; } @@ -173,7 +173,7 @@ bool QgsGmlSchema::xsdFeatureClass( const QDomElement &element, const QString & // Add attributes from current comple type QList sequenceElements = domElements( extrest, "sequence.element" ); - foreach ( QDomElement sequenceElement, sequenceElements ) + foreach ( const QDomElement& sequenceElement, sequenceElements ) { QString fieldName = sequenceElement.attribute( "name" ); QString fieldTypeName = stripNS( sequenceElement.attribute( "type" ) ); @@ -316,7 +316,7 @@ QDomElement QgsGmlSchema::domElement( const QDomElement &element, const QString QList QgsGmlSchema::domElements( QList &elements, const QString & attr, const QString & attrVal ) { QList list; - foreach ( QDomElement el, elements ) + foreach ( const QDomElement& el, elements ) { if ( el.attribute( attr ) == attrVal ) { diff --git a/src/core/qgslegendrenderer.cpp b/src/core/qgslegendrenderer.cpp index 110875c4e91..c0666e94425 100644 --- a/src/core/qgslegendrenderer.cpp +++ b/src/core/qgslegendrenderer.cpp @@ -59,7 +59,7 @@ QSizeF QgsLegendRenderer::paintAndDetermineSize( QPainter* painter ) qreal maxColumnWidth = 0; if ( mSettings.equalColumnWidth() ) { - foreach ( Atom atom, atomList ) + foreach ( const Atom& atom, atomList ) { maxColumnWidth = qMax( atom.size.width(), maxColumnWidth ); } @@ -76,7 +76,7 @@ QSizeF QgsLegendRenderer::paintAndDetermineSize( QPainter* painter ) double columnMaxHeight = 0; qreal columnWidth = 0; int column = 0; - foreach ( Atom atom, atomList ) + foreach ( const Atom& atom, atomList ) { if ( atom.column > column ) { @@ -262,7 +262,7 @@ void QgsLegendRenderer::setColumns( QList& atomList ) double totalHeight = 0; // bool first = true; qreal maxAtomHeight = 0; - foreach ( Atom atom, atomList ) + foreach ( const Atom& atom, atomList ) { //if ( !first ) //{ @@ -449,7 +449,7 @@ QSizeF QgsLegendRenderer::drawAtom( Atom atom, QPainter* painter, QPointF point { bool first = true; QSizeF size = QSizeF( atom.size ); - foreach ( Nucleon nucleon, atom.nucleons ) + foreach ( const Nucleon& nucleon, atom.nucleons ) { if ( QgsLayerTreeGroup* groupItem = qobject_cast( nucleon.item ) ) { diff --git a/src/core/qgsmaphittest.cpp b/src/core/qgsmaphittest.cpp index 8e232ebcff4..002eb591564 100644 --- a/src/core/qgsmaphittest.cpp +++ b/src/core/qgsmaphittest.cpp @@ -24,7 +24,7 @@ void QgsMapHitTest::run() QgsRenderContext context = QgsRenderContext::fromMapSettings( mSettings ); context.setPainter( &painter ); // we are not going to draw anything, but we still need a working painter - foreach ( QString layerID, mSettings.layers() ) + foreach ( const QString& layerID, mSettings.layers() ) { QgsVectorLayer* vl = qobject_cast( QgsMapLayerRegistry::instance()->mapLayer( layerID ) ); if ( !vl || !vl->rendererV2() ) diff --git a/src/core/qgsmaplayerlegend.cpp b/src/core/qgsmaplayerlegend.cpp index 0f53e323abc..1937b74d8f9 100644 --- a/src/core/qgsmaplayerlegend.cpp +++ b/src/core/qgsmaplayerlegend.cpp @@ -97,7 +97,7 @@ QList QgsMapLayerLegendUtils::legendNodeOrder( QgsLayerTreeLayer* nodeLayer int numNodes = _originalLegendNodeCount( nodeLayer ); QList lst; - foreach ( QString item, orderStr.split( "," ) ) + foreach ( const QString& item, orderStr.split( "," ) ) { bool ok; int id = item.toInt( &ok ); diff --git a/src/core/qgsmaprenderercache.cpp b/src/core/qgsmaprenderercache.cpp index aa85c417d08..e97fe68a4d6 100644 --- a/src/core/qgsmaprenderercache.cpp +++ b/src/core/qgsmaprenderercache.cpp @@ -35,7 +35,7 @@ void QgsMapRendererCache::clearInternal() mScale = 0; // make sure we are disconnected from all layers - foreach ( QString layerId, mCachedImages.keys() ) + foreach ( const QString& layerId, mCachedImages.keys() ) { QgsMapLayer* layer = QgsMapLayerRegistry::instance()->mapLayer( layerId ); if ( layer ) diff --git a/src/core/qgsmaprenderercustompainterjob.cpp b/src/core/qgsmaprenderercustompainterjob.cpp index 5506f1d3af5..dace6296aba 100644 --- a/src/core/qgsmaprenderercustompainterjob.cpp +++ b/src/core/qgsmaprenderercustompainterjob.cpp @@ -327,7 +327,7 @@ void QgsMapRendererJob::drawNewLabeling( const QgsMapSettings& settings, QgsRend void QgsMapRendererJob::updateLayerGeometryCaches() { - foreach ( QString id, mGeometryCaches.keys() ) + foreach ( const QString& id, mGeometryCaches.keys() ) { const QgsGeometryCache& cache = mGeometryCaches[id]; if ( QgsVectorLayer* vl = qobject_cast( QgsMapLayerRegistry::instance()->mapLayer( id ) ) ) diff --git a/src/core/qgsmaprendererjob.cpp b/src/core/qgsmaprendererjob.cpp index 028c91a68c2..0ec04cb28c3 100644 --- a/src/core/qgsmaprendererjob.cpp +++ b/src/core/qgsmaprendererjob.cpp @@ -300,7 +300,7 @@ void QgsMapRendererJob::cleanupJobs( LayerRenderJobs& jobs ) if ( job.renderer ) { - foreach ( QString message, job.renderer->errors() ) + foreach ( const QString& message, job.renderer->errors() ) mErrors.append( Error( job.renderer->layerID(), message ) ); delete job.renderer; diff --git a/src/core/qgsnetworkaccessmanager.cpp b/src/core/qgsnetworkaccessmanager.cpp index 906190ee699..02db68e8711 100644 --- a/src/core/qgsnetworkaccessmanager.cpp +++ b/src/core/qgsnetworkaccessmanager.cpp @@ -60,7 +60,7 @@ class QgsNetworkProxyFactory : public QNetworkProxyFactory QString url = query.url().toString(); - foreach ( QString exclude, nam->excludeList() ) + foreach ( const QString& exclude, nam->excludeList() ) { if ( url.startsWith( exclude ) ) { diff --git a/src/core/qgsnetworkreplyparser.cpp b/src/core/qgsnetworkreplyparser.cpp index 5ed40b85fef..a9c0034c312 100644 --- a/src/core/qgsnetworkreplyparser.cpp +++ b/src/core/qgsnetworkreplyparser.cpp @@ -119,7 +119,7 @@ QgsNetworkReplyParser::QgsNetworkReplyParser( QNetworkReply *reply ) QgsDebugMsg( "headers:\n" + headers ); QStringList headerRows = QString( headers ).split( QRegExp( "[\n\r]+" ) ); - foreach ( QString row, headerRows ) + foreach ( const QString& row, headerRows ) { QgsDebugMsg( "row = " + row ); QStringList kv = row.split( ": " ); diff --git a/src/core/qgsobjectcustomproperties.cpp b/src/core/qgsobjectcustomproperties.cpp index 6d835199e4f..7152556fe24 100644 --- a/src/core/qgsobjectcustomproperties.cpp +++ b/src/core/qgsobjectcustomproperties.cpp @@ -132,7 +132,7 @@ void QgsObjectCustomProperties::writeXml( QDomNode& parentNode, QDomDocument& do } else if ( it.value().canConvert() ) { - foreach ( QString value, it.value().toStringList() ) + foreach ( const QString& value, it.value().toStringList() ) { QDomElement itemElement = doc.createElement( "value" ); itemElement.appendChild( doc.createTextNode( value ) ); diff --git a/src/core/qgspallabeling.cpp b/src/core/qgspallabeling.cpp index 1ff6a3045f6..dabc5234d56 100644 --- a/src/core/qgspallabeling.cpp +++ b/src/core/qgspallabeling.cpp @@ -3309,7 +3309,7 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QStringList& attrNames, { QgsDebugMsgLevel( "Prepare error:" + exp->evalErrorString(), 4 ); } - foreach ( QString name, exp->referencedColumns() ) + foreach ( const QString& name, exp->referencedColumns() ) { QgsDebugMsgLevel( "REFERENCED COLUMN = " + name, 4 ); attrNames.append( name ); @@ -3342,7 +3342,7 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QStringList& attrNames, QStringList cols = dd->referencedColumns( ctx.expressionContext() ); // <-- prepares any expressions, too //QgsDebugMsgLevel( QString( "Data defined referenced columns:" ) + cols.join( "," ), 4 ); - foreach ( QString name, cols ) + foreach ( const QString& name, cols ) { attrNames.append( name ); } @@ -3530,7 +3530,7 @@ QStringList QgsPalLabeling::splitToLines( const QString &text, const QString &wr if ( !wrapCharacter.isEmpty() && wrapCharacter != QString( "\n" ) ) { //wrap on both the wrapchr and new line characters - foreach ( QString line, text.split( wrapCharacter ) ) + foreach ( const QString& line, text.split( wrapCharacter ) ) { multiLineSplit.append( line.split( QString( "\n" ) ) ); } diff --git a/src/core/qgspluginlayerregistry.cpp b/src/core/qgspluginlayerregistry.cpp index ffa481fde9b..8fa502cf563 100644 --- a/src/core/qgspluginlayerregistry.cpp +++ b/src/core/qgspluginlayerregistry.cpp @@ -75,7 +75,7 @@ QgsPluginLayerRegistry::~QgsPluginLayerRegistry() if ( !mPluginLayerTypes.isEmpty() ) { QgsDebugMsg( "QgsPluginLayerRegistry::~QgsPluginLayerRegistry(): creator list not empty" ); - foreach ( QString typeName, mPluginLayerTypes.keys() ) + foreach ( const QString& typeName, mPluginLayerTypes.keys() ) removePluginLayerType( typeName ); } } diff --git a/src/core/qgsproject.cpp b/src/core/qgsproject.cpp index 31d27eaba0a..778640c9f63 100644 --- a/src/core/qgsproject.cpp +++ b/src/core/qgsproject.cpp @@ -1772,7 +1772,7 @@ QgsLayerTreeGroup *QgsProject::createEmbeddedGroup( const QString &groupName, co mLayerTreeRegistryBridge->setEnabled( true ); // consider the layers might be identify disabled in its project - foreach ( QString layerId, newGroup->findLayerIds() ) + foreach ( const QString& layerId, newGroup->findLayerIds() ) { if ( embeddedIdentifyDisabledLayers.contains( layerId ) ) { diff --git a/src/core/qgsrelation.cpp b/src/core/qgsrelation.cpp index c6bc5ff95be..011f2629e48 100644 --- a/src/core/qgsrelation.cpp +++ b/src/core/qgsrelation.cpp @@ -97,7 +97,7 @@ void QgsRelation::writeXML( QDomNode &node, QDomDocument &doc ) const elem.setAttribute( "referencingLayer", mReferencingLayerId ); elem.setAttribute( "referencedLayer", mReferencedLayerId ); - Q_FOREACH ( FieldPair fields, mFieldPairs ) + Q_FOREACH ( const FieldPair& fields, mFieldPairs ) { QDomElement referenceElem = doc.createElement( "fieldRef" ); referenceElem.setAttribute( "referencingField", fields.first ); diff --git a/src/core/qgssnappingutils.cpp b/src/core/qgssnappingutils.cpp index 9f96f5fc732..65b67da6ce0 100644 --- a/src/core/qgssnappingutils.cpp +++ b/src/core/qgssnappingutils.cpp @@ -460,7 +460,7 @@ void QgsSnappingUtils::readConfigFromProject() void QgsSnappingUtils::onLayersWillBeRemoved( QStringList layerIds ) { // remove locators for layers that are going to be deleted - foreach ( QString layerId, layerIds ) + foreach ( const QString& layerId, layerIds ) { for ( LocatorsMap::iterator it = mLocators.begin(); it != mLocators.end(); ) { diff --git a/src/core/qgsvectordataprovider.cpp b/src/core/qgsvectordataprovider.cpp index 00d9908d824..4d50e38ee7f 100644 --- a/src/core/qgsvectordataprovider.cpp +++ b/src/core/qgsvectordataprovider.cpp @@ -468,7 +468,7 @@ const QStringList &QgsVectorDataProvider::availableEncodings() { if ( smEncodings.isEmpty() ) { - foreach ( QString codec, QTextCodec::availableCodecs() ) + foreach ( const QString& codec, QTextCodec::availableCodecs() ) { smEncodings << codec; } diff --git a/src/core/qgsvectorfilewriter.cpp b/src/core/qgsvectorfilewriter.cpp index a4aa3355ce7..e39511633b0 100644 --- a/src/core/qgsvectorfilewriter.cpp +++ b/src/core/qgsvectorfilewriter.cpp @@ -192,7 +192,7 @@ QgsVectorFileWriter::QgsVectorFileWriter( { QStringList allExts = exts.split( " ", QString::SkipEmptyParts ); bool found = false; - foreach ( QString ext, allExts ) + foreach ( const QString& ext, allExts ) { if ( vectorFileName.endsWith( "." + ext, Qt::CaseInsensitive ) ) { @@ -2099,7 +2099,7 @@ bool QgsVectorFileWriter::deleteShapeFile( QString theFileName ) } bool ok = true; - foreach ( QString file, dir.entryList( filter ) ) + foreach ( const QString& file, dir.entryList( filter ) ) { QFile f( dir.canonicalPath() + "/" + file ); if ( !f.remove( ) ) @@ -2202,7 +2202,7 @@ QMap QgsVectorFileWriter::ogrDriverList() } } - foreach ( QString drvName, writableDrivers ) + foreach ( const QString& drvName, writableDrivers ) { QString longName; QString trLongName; diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp index aec74af12f8..d4f7bedab43 100644 --- a/src/core/qgsvectorlayer.cpp +++ b/src/core/qgsvectorlayer.cpp @@ -323,7 +323,7 @@ void QgsVectorLayer::drawLabels( QgsRenderContext& rendererContext ) rendererContext.rendererScale() <= mLabel->maxScale() ) ) ) { QgsAttributeList attributes; - foreach ( QString attrName, mRendererV2->usedAttributes() ) + foreach ( const QString& attrName, mRendererV2->usedAttributes() ) { int attrNum = fieldNameIndex( attrName ); attributes.append( attrNum ); @@ -3290,7 +3290,7 @@ QList QgsVectorLayer::getDoubleValues( const QString &fieldOrExpression, return values; bool convertOk; - foreach ( QVariant value, variantValues ) + foreach ( const QVariant& value, variantValues ) { double val = value.toDouble( &convertOk ); if ( convertOk ) diff --git a/src/core/qgsvectorlayerjoinbuffer.cpp b/src/core/qgsvectorlayerjoinbuffer.cpp index c860e9c70c1..407e4d0d9be 100644 --- a/src/core/qgsvectorlayerjoinbuffer.cpp +++ b/src/core/qgsvectorlayerjoinbuffer.cpp @@ -287,7 +287,7 @@ void QgsVectorLayerJoinBuffer::writeXml( QDomNode& layer_node, QDomDocument& doc if ( joinIt->joinFieldNamesSubset() ) { QDomElement subsetElem = document.createElement( "joinFieldsSubset" ); - foreach ( QString fieldName, *joinIt->joinFieldNamesSubset() ) + foreach ( const QString& fieldName, *joinIt->joinFieldNamesSubset() ) { QDomElement fieldElem = document.createElement( "field" ); fieldElem.setAttribute( "name", fieldName ); diff --git a/src/core/qgsvisibilitypresetcollection.cpp b/src/core/qgsvisibilitypresetcollection.cpp index 84843e37dc7..3492c2101ed 100644 --- a/src/core/qgsvisibilitypresetcollection.cpp +++ b/src/core/qgsvisibilitypresetcollection.cpp @@ -240,7 +240,7 @@ void QgsVisibilityPresetCollection::writeXML( QDomDocument& doc ) const PresetRecord& rec = mPresets[grpName]; QDomElement visPresetElem = doc.createElement( "visibility-preset" ); visPresetElem.setAttribute( "name", grpName ); - foreach ( QString layerID, rec.mVisibleLayerIDs ) + foreach ( const QString& layerID, rec.mVisibleLayerIDs ) { QDomElement layerElem = doc.createElement( "layer" ); layerElem.setAttribute( "id", layerID ); @@ -249,11 +249,11 @@ void QgsVisibilityPresetCollection::writeXML( QDomDocument& doc ) visPresetElem.appendChild( layerElem ); } - foreach ( QString layerID, rec.mPerLayerCheckedLegendSymbols.keys() ) + foreach ( const QString& layerID, rec.mPerLayerCheckedLegendSymbols.keys() ) { QDomElement checkedLegendNodesElem = doc.createElement( "checked-legend-nodes" ); checkedLegendNodesElem.setAttribute( "id", layerID ); - foreach ( QString checkedLegendNode, rec.mPerLayerCheckedLegendSymbols[layerID] ) + foreach ( const QString& checkedLegendNode, rec.mPerLayerCheckedLegendSymbols[layerID] ) { QDomElement checkedLegendNodeElem = doc.createElement( "checked-legend-node" ); checkedLegendNodeElem.setAttribute( "id", checkedLegendNode ); @@ -270,9 +270,9 @@ void QgsVisibilityPresetCollection::writeXML( QDomDocument& doc ) void QgsVisibilityPresetCollection::registryLayersRemoved( QStringList layerIDs ) { - foreach ( QString layerID, layerIDs ) + foreach ( const QString& layerID, layerIDs ) { - foreach ( QString presetName, mPresets.keys() ) + foreach ( const QString& presetName, mPresets.keys() ) { PresetRecord& rec = mPresets[presetName]; rec.mVisibleLayerIDs.remove( layerID ); @@ -290,7 +290,7 @@ void QgsVisibilityPresetCollection::layerStyleRenamed( const QString& oldName, c QString layerID = styleMgr->layer()->id(); - foreach ( QString presetName, mPresets.keys() ) + foreach ( const QString& presetName, mPresets.keys() ) { PresetRecord& rec = mPresets[presetName]; diff --git a/src/core/raster/qgsrasterinterface.cpp b/src/core/raster/qgsrasterinterface.cpp index 96dd0e1c72f..f5b1570485f 100644 --- a/src/core/raster/qgsrasterinterface.cpp +++ b/src/core/raster/qgsrasterinterface.cpp @@ -107,7 +107,7 @@ bool QgsRasterInterface::hasStatistics( int theBandNo, QgsRasterBandStats myRasterBandStats; initStatistics( myRasterBandStats, theBandNo, theStats, theExtent, theSampleSize ); - foreach ( QgsRasterBandStats stats, mStatistics ) + foreach ( const QgsRasterBandStats& stats, mStatistics ) { if ( stats.contains( myRasterBandStats ) ) { @@ -130,7 +130,7 @@ QgsRasterBandStats QgsRasterInterface::bandStatistics( int theBandNo, QgsRasterBandStats myRasterBandStats; initStatistics( myRasterBandStats, theBandNo, theStats, theExtent, theSampleSize ); - foreach ( QgsRasterBandStats stats, mStatistics ) + foreach ( const QgsRasterBandStats& stats, mStatistics ) { if ( stats.contains( myRasterBandStats ) ) { @@ -381,7 +381,7 @@ bool QgsRasterInterface::hasHistogram( int theBandNo, QgsRasterHistogram myHistogram; initHistogram( myHistogram, theBandNo, theBinCount, theMinimum, theMaximum, theExtent, theSampleSize, theIncludeOutOfRange ); - foreach ( QgsRasterHistogram histogram, mHistograms ) + foreach ( const QgsRasterHistogram& histogram, mHistograms ) { if ( histogram == myHistogram ) { @@ -405,7 +405,7 @@ QgsRasterHistogram QgsRasterInterface::histogram( int theBandNo, initHistogram( myHistogram, theBandNo, theBinCount, theMinimum, theMaximum, theExtent, theSampleSize, theIncludeOutOfRange ); // Find cached - foreach ( QgsRasterHistogram histogram, mHistograms ) + foreach ( const QgsRasterHistogram& histogram, mHistograms ) { if ( histogram == myHistogram ) { diff --git a/src/core/raster/qgsrasterlayer.cpp b/src/core/raster/qgsrasterlayer.cpp index fbe83b7d6eb..c41c76b26ee 100644 --- a/src/core/raster/qgsrasterlayer.cpp +++ b/src/core/raster/qgsrasterlayer.cpp @@ -1523,7 +1523,7 @@ bool QgsRasterLayer::writeXml( QDomNode & layer_node, noDataRangeList.setAttribute( "bandNo", bandNo ); noDataRangeList.setAttribute( "useSrcNoData", mDataProvider->useSrcNoDataValue( bandNo ) ); - foreach ( QgsRasterRange range, mDataProvider->userNoDataValues( bandNo ) ) + foreach ( const QgsRasterRange& range, mDataProvider->userNoDataValues( bandNo ) ) { QDomElement noDataRange = document.createElement( "noDataRange" ); diff --git a/src/core/raster/qgsrasterrange.cpp b/src/core/raster/qgsrasterrange.cpp index 7d5486cf741..74fe5a00879 100644 --- a/src/core/raster/qgsrasterrange.cpp +++ b/src/core/raster/qgsrasterrange.cpp @@ -37,7 +37,7 @@ QgsRasterRange::~QgsRasterRange() bool QgsRasterRange::contains( double value, const QgsRasterRangeList &rangeList ) { - foreach ( QgsRasterRange range, rangeList ) + foreach ( const QgsRasterRange& range, rangeList ) { if (( value >= range.mMin && value <= range.mMax ) || qgsDoubleNear( value, range.mMin ) || diff --git a/src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp b/src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp index 5b4d4be1a5f..52dc44f4bda 100644 --- a/src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp +++ b/src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp @@ -727,7 +727,7 @@ QgsLegendSymbolListV2 QgsCategorizedSymbolRendererV2::legendSymbolItemsV2() cons { // check that all symbols that have the same size expression QgsDataDefined ddSize; - foreach ( QgsRendererCategoryV2 category, mCategories ) + foreach ( const QgsRendererCategoryV2& category, mCategories ) { const QgsMarkerSymbolV2 * symbol = static_cast( category.symbol() ); if ( !ddSize.hasDefaultValues() && symbol->dataDefinedSize() != ddSize ) @@ -761,7 +761,7 @@ QgsLegendSymbolListV2 QgsCategorizedSymbolRendererV2::legendSymbolItemsV2() cons } // now list the categorized symbols const QgsLegendSymbolListV2 list2 = QgsFeatureRendererV2::legendSymbolItemsV2() ; - foreach ( QgsLegendSymbolItemV2 item, list2 ) + foreach ( const QgsLegendSymbolItemV2& item, list2 ) lst << item; return lst; } @@ -847,7 +847,7 @@ QString QgsCategorizedSymbolRendererV2::sizeScaleField() const void QgsCategorizedSymbolRendererV2::updateSymbols( QgsSymbolV2 * sym ) { int i = 0; - foreach ( QgsRendererCategoryV2 cat, mCategories ) + foreach ( const QgsRendererCategoryV2& cat, mCategories ) { QgsSymbolV2* symbol = sym->clone(); symbol->setColor( cat.symbol()->color() ); diff --git a/src/core/symbology-ng/qgscolorbrewerpalette.h b/src/core/symbology-ng/qgscolorbrewerpalette.h index a0479b326be..6a010598bb6 100644 --- a/src/core/symbology-ng/qgscolorbrewerpalette.h +++ b/src/core/symbology-ng/qgscolorbrewerpalette.h @@ -28,13 +28,13 @@ class CORE_EXPORT QgsColorBrewerPalette QList pal; QString palette( brewerString ); QStringList list = palette.split( QChar( '\n' ) ); - foreach ( QString entry, list ) + foreach ( const QString& entry, list ) { QStringList items = entry.split( QChar( '-' ) ); if ( items.count() != 3 || items[0] != schemeName || items[1].toInt() != colors ) continue; QStringList colors = items[2].split( QChar( ' ' ) ); - foreach ( QString clr, colors ) + foreach ( const QString& clr, colors ) { pal << QgsSymbolLayerV2Utils::parseColor( clr ); } @@ -48,7 +48,7 @@ class CORE_EXPORT QgsColorBrewerPalette QString palette( brewerString ); QStringList list = palette.split( QChar( '\n' ) ); - foreach ( QString entry, list ) + foreach ( const QString& entry, list ) { QStringList items = entry.split( QChar( '-' ) ); if ( items.count() != 3 ) @@ -65,7 +65,7 @@ class CORE_EXPORT QgsColorBrewerPalette QString palette( brewerString ); QStringList list = palette.split( QChar( '\n' ) ); - foreach ( QString entry, list ) + foreach ( const QString& entry, list ) { QStringList items = entry.split( QChar( '-' ) ); if ( items.count() != 3 || items[0] != schemeName ) diff --git a/src/core/symbology-ng/qgscptcityarchive.cpp b/src/core/symbology-ng/qgscptcityarchive.cpp index c360ddd565a..e0c8373e553 100644 --- a/src/core/symbology-ng/qgscptcityarchive.cpp +++ b/src/core/symbology-ng/qgscptcityarchive.cpp @@ -50,7 +50,7 @@ QgsCptCityArchive::QgsCptCityArchive( QString archiveName, QString baseDir ) // make Author items QgsCptCityDirectoryItem* dirItem = 0; - foreach ( QString path, QDir( mBaseDir ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name ) ) + foreach ( const QString& path, QDir( mBaseDir ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name ) ) { if ( path == "selections" ) continue; @@ -66,7 +66,7 @@ QgsCptCityArchive::QgsCptCityArchive( QString archiveName, QString baseDir ) QgsCptCitySelectionItem* selItem = 0; QDir seldir( mBaseDir + "/" + "selections" ); QgsDebugMsg( "populating selection from " + seldir.path() ); - foreach ( QString selfile, seldir.entryList( QStringList( "*.xml" ), QDir::Files ) ) + foreach ( const QString& selfile, seldir.entryList( QStringList( "*.xml" ), QDir::Files ) ) { QgsDebugMsg( "file= " + seldir.path() + "/" + selfile ); selItem = new QgsCptCitySelectionItem( NULL, QFileInfo( selfile ).baseName(), @@ -459,7 +459,7 @@ void QgsCptCityArchive::initArchives( bool loadAll ) if ( loadAll ) { QDir dir( baseDir ); - foreach ( QString entry, dir.entryList( QStringList( "cpt-city*" ), QDir::Dirs ) ) + foreach ( const QString& entry, dir.entryList( QStringList( "cpt-city*" ), QDir::Dirs ) ) { if ( QFile::exists( baseDir + "/" + entry + "/VERSION.xml" ) ) archivesMap[ entry ] = baseDir + "/" + entry; @@ -951,7 +951,7 @@ QVector QgsCptCityDirectoryItem::createChildren() } // add children dirs - foreach ( QString childPath, dirEntries() ) + foreach ( const QString& childPath, dirEntries() ) { QgsCptCityDataItem* childItem = QgsCptCityDirectoryItem::dataItem( this, childPath, mPath + "/" + childPath ); diff --git a/src/core/symbology-ng/qgsfillsymbollayerv2.cpp b/src/core/symbology-ng/qgsfillsymbollayerv2.cpp index c740be667e1..36c7f487f83 100644 --- a/src/core/symbology-ng/qgsfillsymbollayerv2.cpp +++ b/src/core/symbology-ng/qgsfillsymbollayerv2.cpp @@ -2703,7 +2703,7 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolV2RenderContext polygons.append( QPolygonF() << p5 << p6 ); } - foreach ( QPolygonF polygon, polygons ) + foreach ( const QPolygonF& polygon, polygons ) { fillLineSymbol->renderPolyline( polygon, context.feature(), lineRenderContext, -1, context.selected() ); } diff --git a/src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp b/src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp index b6c1c475a4c..ed2a3c0d7c3 100644 --- a/src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp +++ b/src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp @@ -1182,7 +1182,7 @@ QgsLegendSymbolListV2 QgsGraduatedSymbolRendererV2::legendSymbolItemsV2() const { // check that all symbols that have the same size expression QgsDataDefined ddSize; - foreach ( QgsRendererRangeV2 range, mRanges ) + foreach ( const QgsRendererRangeV2& range, mRanges ) { const QgsMarkerSymbolV2 * symbol = static_cast( range.symbol() ); if ( !ddSize.hasDefaultValues() && symbol->dataDefinedSize() != ddSize ) @@ -1216,7 +1216,7 @@ QgsLegendSymbolListV2 QgsGraduatedSymbolRendererV2::legendSymbolItemsV2() const } // now list the graduated symbols const QgsLegendSymbolListV2 list2 = QgsFeatureRendererV2::legendSymbolItemsV2() ; - foreach ( QgsLegendSymbolItemV2 item, list2 ) + foreach ( const QgsLegendSymbolItemV2& item, list2 ) list << item; return list; } @@ -1316,7 +1316,7 @@ void QgsGraduatedSymbolRendererV2::updateColorRamp( QgsVectorColorRampV2 *ramp, if ( mSourceColorRamp ) { - foreach ( QgsRendererRangeV2 range, mRanges ) + foreach ( const QgsRendererRangeV2& range, mRanges ) { QgsSymbolV2 *symbol = range.symbol() ? range.symbol()->clone() : 0; if ( symbol ) @@ -1341,7 +1341,7 @@ void QgsGraduatedSymbolRendererV2::updateSymbols( QgsSymbolV2 *sym ) return; int i = 0; - foreach ( QgsRendererRangeV2 range, mRanges ) + foreach ( const QgsRendererRangeV2& range, mRanges ) { QScopedPointer symbol( sym->clone() ); if ( mGraduatedMethod == GraduatedColor ) diff --git a/src/core/symbology-ng/qgsrendererv2registry.cpp b/src/core/symbology-ng/qgsrendererv2registry.cpp index 17e0849fd5c..12957f2f35a 100644 --- a/src/core/symbology-ng/qgsrendererv2registry.cpp +++ b/src/core/symbology-ng/qgsrendererv2registry.cpp @@ -59,7 +59,7 @@ QgsRendererV2Registry::QgsRendererV2Registry() QgsRendererV2Registry::~QgsRendererV2Registry() { - foreach ( QString name, mRenderers.keys() ) + foreach ( const QString& name, mRenderers.keys() ) { delete mRenderers[name]; } diff --git a/src/core/symbology-ng/qgsstylev2.cpp b/src/core/symbology-ng/qgsstylev2.cpp index a08e87e3816..096f513d488 100644 --- a/src/core/symbology-ng/qgsstylev2.cpp +++ b/src/core/symbology-ng/qgsstylev2.cpp @@ -1124,7 +1124,7 @@ QStringList QgsStyleV2::symbolsOfSmartgroup( StyleEntity type, int id ) { resultNames = type == SymbolEntity ? symbolNames() : colorRampNames(); QStringList unwanted = symbolsWithTag( type, tagId( param ) ); - foreach ( QString name, unwanted ) + foreach ( const QString& name, unwanted ) { resultNames.removeAll( name ); } @@ -1133,7 +1133,7 @@ QStringList QgsStyleV2::symbolsOfSmartgroup( StyleEntity type, int id ) { resultNames = type == SymbolEntity ? symbolNames() : colorRampNames(); QStringList unwanted = symbolsOfGroup( type, groupId( param ) ); - foreach ( QString name, unwanted ) + foreach ( const QString& name, unwanted ) { resultNames.removeAll( name ); } diff --git a/src/core/symbology-ng/qgssymbollayerv2registry.cpp b/src/core/symbology-ng/qgssymbollayerv2registry.cpp index 7f0e5659236..f7f1d1ed7c5 100644 --- a/src/core/symbology-ng/qgssymbollayerv2registry.cpp +++ b/src/core/symbology-ng/qgssymbollayerv2registry.cpp @@ -60,7 +60,7 @@ QgsSymbolLayerV2Registry::QgsSymbolLayerV2Registry() QgsSymbolLayerV2Registry::~QgsSymbolLayerV2Registry() { - foreach ( QString name, mMetadata.keys() ) + foreach ( const QString& name, mMetadata.keys() ) { delete mMetadata[name]; } diff --git a/src/core/symbology-ng/qgssymbollayerv2utils.cpp b/src/core/symbology-ng/qgssymbollayerv2utils.cpp index d745c7af7fe..77e02a5c583 100644 --- a/src/core/symbology-ng/qgssymbollayerv2utils.cpp +++ b/src/core/symbology-ng/qgssymbollayerv2utils.cpp @@ -2722,7 +2722,7 @@ QDomElement QgsSymbolLayerV2Utils::saveSymbols( QgsSymbolV2Map& symbols, QString void QgsSymbolLayerV2Utils::clearSymbolMap( QgsSymbolV2Map& symbols ) { - foreach ( QString name, symbols.keys() ) + foreach ( const QString& name, symbols.keys() ) { delete symbols.value( name ); } @@ -3520,12 +3520,12 @@ QStringList QgsSymbolLayerV2Utils::listSvgFiles() for ( int i = 0; i < svgPaths.size(); i++ ) { QDir dir( svgPaths[i] ); - foreach ( QString item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) ) + foreach ( const QString& item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) ) { svgPaths.insert( i + 1, dir.path() + "/" + item ); } - foreach ( QString item, dir.entryList( QStringList( "*.svg" ), QDir::Files ) ) + foreach ( const QString& item, dir.entryList( QStringList( "*.svg" ), QDir::Files ) ) { // TODO test if it is correct SVG list.append( dir.path() + "/" + item ); @@ -3546,12 +3546,12 @@ QStringList QgsSymbolLayerV2Utils::listSvgFilesAt( QString directory ) for ( int i = 0; i < svgPaths.size(); i++ ) { QDir dir( svgPaths[i] ); - foreach ( QString item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) ) + foreach ( const QString& item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) ) { svgPaths.insert( i + 1, dir.path() + "/" + item ); } - foreach ( QString item, dir.entryList( QStringList( "*.svg" ), QDir::Files ) ) + foreach ( const QString& item, dir.entryList( QStringList( "*.svg" ), QDir::Files ) ) { list.append( dir.path() + "/" + item ); } diff --git a/src/core/symbology-ng/qgsvectorcolorrampv2.cpp b/src/core/symbology-ng/qgsvectorcolorrampv2.cpp index d82a8f94203..e950b72fd72 100644 --- a/src/core/symbology-ng/qgsvectorcolorrampv2.cpp +++ b/src/core/symbology-ng/qgsvectorcolorrampv2.cpp @@ -61,7 +61,7 @@ QgsVectorColorRampV2* QgsVectorGradientColorRampV2::create( const QgsStringMap& QgsGradientStopsList stops; if ( props.contains( "stops" ) ) { - foreach ( QString stop, props["stops"].split( ':' ) ) + foreach ( const QString& stop, props["stops"].split( ':' ) ) { int i = stop.indexOf( ';' ); if ( i == -1 )