Make sure a lot of foreach loops use references

This commit is contained in:
Nyall Dawson 2015-09-08 17:32:05 +10:00
parent bd2d78cea9
commit 73ffb83ad4
72 changed files with 162 additions and 162 deletions

View File

@ -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 );

View File

@ -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 );

View File

@ -1141,7 +1141,7 @@ APP_EXPORT int main( int argc, char *argv[] )
QList< QPair<QgsVectorLayer *, int > > 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<QgsVectorLayer *>( QgsMapLayerRegistry::instance()->mapLayer( layer ) );
if ( !vl )

View File

@ -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 );

View File

@ -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() )
{

View File

@ -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 )

View File

@ -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 );

View File

@ -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 )
{

View File

@ -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<QString, QString> 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 );
}

View File

@ -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 );
}

View File

@ -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 );
}

View File

@ -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 );
}

View File

@ -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 ) )
{

View File

@ -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;

View File

@ -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;

View File

@ -70,7 +70,7 @@ void QgsAtlasComposition::removeLayers( QStringList layers )
return;
}
foreach ( QString layerId, layers )
foreach ( const QString& layerId, layers )
{
if ( layerId == mCoverageLayer->id() )
{

View File

@ -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 )

View File

@ -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( " " );

View File

@ -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();

View File

@ -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<QVariant> 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();

View File

@ -53,7 +53,7 @@ QgsPaintEffectRegistry::QgsPaintEffectRegistry()
QgsPaintEffectRegistry::~QgsPaintEffectRegistry()
{
foreach ( QString name, mMetadata.keys() )
foreach ( const QString& name, mMetadata.keys() )
{
delete mMetadata[name];
}

View File

@ -44,7 +44,7 @@ QList< QPair<QString, QString> > 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<QString, QString> > 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 )
{

View File

@ -415,7 +415,7 @@ static bool _isChildOfNodes( QgsLayerTreeNode* child, QList<QgsLayerTreeNode*> n
QList<QgsLayerTreeNode*> QgsLayerTreeModel::indexes2nodes( const QModelIndexList& list, bool skipInternal ) const
{
QList<QgsLayerTreeNode*> nodes;
foreach ( QModelIndex index, list )
foreach ( const QModelIndex& index, list )
{
QgsLayerTreeNode* node = index2node( index );
if ( !node )

View File

@ -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();

View File

@ -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 );

View File

@ -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

View File

@ -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 )

View File

@ -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 );
}

View File

@ -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 );

View File

@ -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<QColor>(), QgsSymbolLayerV2Utils::colorToName( color.value<QColor>() ) ) );
}

View File

@ -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> QgsConditionalStyle::matchingConditionalStyles( QList<QgsConditionalStyle> styles, QVariant value, QgsExpressionContext& context )
{
QList<QgsConditionalStyle> matchingstyles;
foreach ( QgsConditionalStyle style, styles )
foreach ( const QgsConditionalStyle& style, styles )
{
if ( style.matches( value, context ) )
matchingstyles.append( style );
@ -235,7 +235,7 @@ QList<QgsConditionalStyle> QgsConditionalStyle::matchingConditionalStyles( QList
QgsConditionalStyle QgsConditionalStyle::matchingConditionalStyle( QList<QgsConditionalStyle> 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<QgsCond
QgsConditionalStyle QgsConditionalStyle::compressStyles( QList<QgsConditionalStyle> 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<QgsConditionalSty
return style;
}
bool QgsConditionalStyle::writeXml( QDomNode &node, QDomDocument &doc )
bool QgsConditionalStyle::writeXml( QDomNode &node, QDomDocument &doc ) const
{
QDomElement stylesel = doc.createElement( "style" );
stylesel.setAttribute( "rule", mRule );

View File

@ -225,7 +225,7 @@ class CORE_EXPORT QgsConditionalStyle
/** Write vector conditional style specific state from layer Dom node.
*/
virtual bool writeXml( QDomNode & node, QDomDocument & doc );
virtual bool writeXml( QDomNode & node, QDomDocument & doc ) const;
private:

View File

@ -622,7 +622,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &theProj4Strin
// also with parameters containing spaces (e.g. +nadgrids)
// make sure result is trimmed (#5598)
QStringList myParams;
foreach ( QString param, myProj4String.split( QRegExp( "\\s+(?=\\+)" ), QString::SkipEmptyParts ) )
foreach ( const QString& param, myProj4String.split( QRegExp( "\\s+(?=\\+)" ), QString::SkipEmptyParts ) )
{
QString arg = QString( "' '||parameters||' ' LIKE %1" ).arg( quotedValue( QString( "% %1 %" ).arg( param.trimmed() ) ) );
if ( param.startsWith( "+datum=" ) )
@ -1623,7 +1623,7 @@ bool QgsCoordinateReferenceSystem::loadIDs( QHash<int, QString> &wkts )
{
OGRSpatialReferenceH crs = OSRNewSpatialReference( NULL );
foreach ( QString csv, QStringList() << "gcs.csv" << "pcs.csv" << "vertcs.csv" << "compdcs.csv" << "geoccs.csv" )
foreach ( const QString& csv, QStringList() << "gcs.csv" << "pcs.csv" << "vertcs.csv" << "compdcs.csv" << "geoccs.csv" )
{
QString filename = CPLFindFile( "gdal", csv.toUtf8() );

View File

@ -775,10 +775,9 @@ QVector<QgsDataItem*> QgsDirectoryItem::createChildren()
{
QVector<QgsDataItem*> 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<QgsDataItem*> 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<QVariant> lst = settings.value( "/dataitem/directoryHiddenColumns" ).toList();
foreach ( QVariant colVariant, lst )
foreach ( const QVariant& colVariant, lst )
{
setColumnHidden( colVariant.toInt(), true );
}
@ -1083,7 +1082,7 @@ QVector<QgsDataItem*> 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<QgsDataItem*> QgsZipItem::createChildren()
getZipFileList();
// loop over files inside zip
foreach ( QString fileName, mZipFileList )
foreach ( const QString& fileName, mZipFileList )
{
QFileInfo info( fileName );
tmpPath = mVsiPrefix + mFilePath + "/" + fileName;

View File

@ -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 )

View File

@ -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 );
}

View File

@ -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;

View File

@ -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;

View File

@ -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 );

View File

@ -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<QDomElement> 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<QDomElement> QgsGmlSchema::domElements( QList<QDomElement> &elements, const QString & attr, const QString & attrVal )
{
QList<QDomElement> list;
foreach ( QDomElement el, elements )
foreach ( const QDomElement& el, elements )
{
if ( el.attribute( attr ) == attrVal )
{

View File

@ -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<Atom>& 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<QgsLayerTreeGroup*>( nucleon.item ) )
{

View File

@ -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<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerID ) );
if ( !vl || !vl->rendererV2() )

View File

@ -97,7 +97,7 @@ QList<int> QgsMapLayerLegendUtils::legendNodeOrder( QgsLayerTreeLayer* nodeLayer
int numNodes = _originalLegendNodeCount( nodeLayer );
QList<int> lst;
foreach ( QString item, orderStr.split( "," ) )
foreach ( const QString& item, orderStr.split( "," ) )
{
bool ok;
int id = item.toInt( &ok );

View File

@ -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 )

View File

@ -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<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( id ) ) )

View File

@ -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;

View File

@ -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 ) )
{

View File

@ -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( ": " );

View File

@ -132,7 +132,7 @@ void QgsObjectCustomProperties::writeXml( QDomNode& parentNode, QDomDocument& do
}
else if ( it.value().canConvert<QStringList>() )
{
foreach ( QString value, it.value().toStringList() )
foreach ( const QString& value, it.value().toStringList() )
{
QDomElement itemElement = doc.createElement( "value" );
itemElement.appendChild( doc.createTextNode( value ) );

View File

@ -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" ) ) );
}

View File

@ -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 );
}
}

View File

@ -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 ) )
{

View File

@ -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 );

View File

@ -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(); )
{

View File

@ -468,7 +468,7 @@ const QStringList &QgsVectorDataProvider::availableEncodings()
{
if ( smEncodings.isEmpty() )
{
foreach ( QString codec, QTextCodec::availableCodecs() )
foreach ( const QString& codec, QTextCodec::availableCodecs() )
{
smEncodings << codec;
}

View File

@ -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<QString, QString> QgsVectorFileWriter::ogrDriverList()
}
}
foreach ( QString drvName, writableDrivers )
foreach ( const QString& drvName, writableDrivers )
{
QString longName;
QString trLongName;

View File

@ -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<double> 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 )

View File

@ -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 );

View File

@ -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];

View File

@ -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 )
{

View File

@ -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" );

View File

@ -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 ) ||

View File

@ -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<const QgsMarkerSymbolV2 *>( 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() );

View File

@ -28,13 +28,13 @@ class CORE_EXPORT QgsColorBrewerPalette
QList<QColor> 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 )

View File

@ -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<QgsCptCityDataItem*> QgsCptCityDirectoryItem::createChildren()
}
// add children dirs
foreach ( QString childPath, dirEntries() )
foreach ( const QString& childPath, dirEntries() )
{
QgsCptCityDataItem* childItem =
QgsCptCityDirectoryItem::dataItem( this, childPath, mPath + "/" + childPath );

View File

@ -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() );
}

View File

@ -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<const QgsMarkerSymbolV2 *>( 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<QgsSymbolV2> symbol( sym->clone() );
if ( mGraduatedMethod == GraduatedColor )

View File

@ -59,7 +59,7 @@ QgsRendererV2Registry::QgsRendererV2Registry()
QgsRendererV2Registry::~QgsRendererV2Registry()
{
foreach ( QString name, mRenderers.keys() )
foreach ( const QString& name, mRenderers.keys() )
{
delete mRenderers[name];
}

View File

@ -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 );
}

View File

@ -60,7 +60,7 @@ QgsSymbolLayerV2Registry::QgsSymbolLayerV2Registry()
QgsSymbolLayerV2Registry::~QgsSymbolLayerV2Registry()
{
foreach ( QString name, mMetadata.keys() )
foreach ( const QString& name, mMetadata.keys() )
{
delete mMetadata[name];
}

View File

@ -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 );
}

View File

@ -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 )