Skip to content

Commit

Permalink
Followup 73ffb83, finishing changing all Q_FOREACH to references
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 9, 2015
1 parent d4e3fcd commit 7c10760
Show file tree
Hide file tree
Showing 99 changed files with 226 additions and 225 deletions.
4 changes: 2 additions & 2 deletions src/app/composer/qgscomposerlegendwidget.cpp
Expand Up @@ -666,7 +666,7 @@ void QgsComposerLegendWidget::on_mRemoveToolButton_clicked()

// first try to remove legend nodes
QHash<QgsLayerTreeLayer*, QList<int> > nodesWithRemoval;
foreach ( const QPersistentModelIndex index, indexes )
foreach ( const QPersistentModelIndex& index, indexes )
{
if ( QgsLayerTreeModelLegendNode* legendNode = mItemTreeView->layerTreeModel()->index2legendNode( index ) )
{
Expand All @@ -691,7 +691,7 @@ void QgsComposerLegendWidget::on_mRemoveToolButton_clicked()
}

// then remove layer tree nodes
foreach ( const QPersistentModelIndex index, indexes )
foreach ( const QPersistentModelIndex& index, indexes )
{
if ( index.isValid() && mItemTreeView->layerTreeModel()->index2node( index ) )
mLegend->modelV2()->removeRow( index.row(), index.parent() );
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -7495,7 +7495,7 @@ void QgisApp::duplicateLayers( QList<QgsMapLayer *> lyrList )
QgsVectorLayer* vDupLayer = dynamic_cast<QgsVectorLayer*>( dupLayer );
if ( vLayer && vDupLayer )
{
foreach ( const QgsVectorJoinInfo join, vLayer->vectorJoins() )
foreach ( const QgsVectorJoinInfo& join, vLayer->vectorJoins() )
{
vDupLayer->addJoin( join );
}
Expand Down Expand Up @@ -10530,7 +10530,7 @@ void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors
bool otherError = false;
static QSet<QSslError::SslError> ignoreErrors;

foreach ( QSslError error, errors )
foreach ( const QSslError& error, errors )
{
if ( error.error() == QSslError::NoError )
continue;
Expand All @@ -10550,7 +10550,7 @@ void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors
msg,
QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Ok )
{
foreach ( QSslError error, errors )
foreach ( const QSslError& error, errors )
{
ignoreErrors << error.error();
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsaddtaborgroup.cpp
Expand Up @@ -36,7 +36,7 @@ QgsAddTabOrGroup::QgsAddTabOrGroup( QgsVectorLayer *lyr, QList < TabPair > tabLi
if ( mTabs.size() > 0 )
{
int i = 0;
foreach ( TabPair tab, mTabs )
foreach ( const TabPair& tab, mTabs )
{
mTabList->addItem( tab.first, i );
++i;
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsapplayertreeviewmenuprovider.cpp
Expand Up @@ -261,8 +261,9 @@ QList< LegendLayerAction > QgsAppLayerTreeViewMenuProvider::legendLayerActions(
{
QgsDebugMsg( QString( "legendLayerActions for layers of type %1:" ).arg( type ) );

foreach ( LegendLayerAction lyrAction, mLegendLayerActionMap[ type ] )
foreach ( const LegendLayerAction& lyrAction, mLegendLayerActionMap[ type ] )
{
Q_UNUSED( lyrAction );
QgsDebugMsg( QString( "%1/%2 - %3 layers" ).arg( lyrAction.menu ).arg( lyrAction.action->text() ).arg( lyrAction.layers.count() ) );
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -1499,7 +1499,7 @@ void QgsProjectProperties::populateEllipsoidList()
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;
EllipsoidDefs myItem, i;
EllipsoidDefs myItem;

myItem.acronym = GEO_NONE;
myItem.description = tr( GEO_NONE_DESC );
Expand Down Expand Up @@ -1567,7 +1567,7 @@ void QgsProjectProperties::populateEllipsoidList()

// Add all items to selector

foreach ( i, mEllipsoidList )
foreach ( const EllipsoidDefs& i, mEllipsoidList )
{
cmbEllipsoid->addItem( i.description );
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsconditionalstyle.cpp
Expand Up @@ -183,7 +183,7 @@ bool QgsConditionalStyle::matches( QVariant value, QgsExpressionContext& context
return exp.evaluate( &context ).toBool();
}

QPixmap QgsConditionalStyle::renderPreview()
QPixmap QgsConditionalStyle::renderPreview() const
{
QPixmap pixmap( 64, 32 );
pixmap.fill( Qt::transparent );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsconditionalstyle.h
Expand Up @@ -85,7 +85,7 @@ class CORE_EXPORT QgsConditionalStyle
* @brief Render a preview icon of the rule.
* @return QPixmap preview of the style
*/
QPixmap renderPreview();
QPixmap renderPreview() const;

/**
* @brief Set the name of the style. Names are optional but handy for display
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -652,7 +652,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &theProj4Strin
{
// Bugfix 8487 : test param lists are equal, except for +datum
QStringList foundParams;
foreach ( QString param, myRecord["parameters"].split( QRegExp( "\\s+(?=\\+)" ), QString::SkipEmptyParts ) )
foreach ( const QString& param, myRecord["parameters"].split( QRegExp( "\\s+(?=\\+)" ), QString::SkipEmptyParts ) )
{
if ( !param.startsWith( "+datum=" ) )
foundParams << param.trimmed();
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgscptcityarchive.cpp
Expand Up @@ -811,7 +811,7 @@ QIcon QgsCptCityColorRampItem::icon()

QIcon QgsCptCityColorRampItem::icon( const QSize& size )
{
foreach ( QIcon icon, mIcons )
foreach ( const QIcon& icon, mIcons )
{
if ( icon.availableSizes().contains( size ) )
return icon;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/attributetable/qgsattributetablefiltermodel.cpp
Expand Up @@ -322,7 +322,7 @@ QModelIndex QgsAttributeTableFilterModel::fidToIndex( QgsFeatureId fid )
QModelIndexList QgsAttributeTableFilterModel::fidToIndexList( QgsFeatureId fid )
{
QModelIndexList indexes;
foreach ( QModelIndex idx, masterModel()->idToIndexList( fid ) )
foreach ( const QModelIndex& idx, masterModel()->idToIndexList( fid ) )
{
indexes.append( mapFromMaster( idx ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/attributetable/qgsattributetableview.cpp
Expand Up @@ -182,7 +182,7 @@ void QgsAttributeTableView::keyPressEvent( QKeyEvent *event )

void QgsAttributeTableView::repaintRequested( QModelIndexList indexes )
{
foreach ( const QModelIndex index, indexes )
foreach ( const QModelIndex& index, indexes )
{
update( index );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/attributetable/qgsdualview.cpp
Expand Up @@ -142,7 +142,7 @@ void QgsDualView::columnBoxInit()

// ... concat all fields
QStringList fieldNames;
foreach ( QgsField field, fields )
foreach ( const QgsField& field, fields )
{
fieldNames.append( "COALESCE(\"" + field.name() + "\", '<NULL>')" );
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/attributetable/qgsfeaturelistview.cpp
Expand Up @@ -103,7 +103,7 @@ QString QgsFeatureListView::parserErrorString()
QgsFeatureIds QgsFeatureListView::currentEditSelection()
{
QgsFeatureIds selection;
Q_FOREACH ( QModelIndex idx, mCurrentEditSelectionModel->selectedIndexes() )
Q_FOREACH ( const QModelIndex& idx, mCurrentEditSelectionModel->selectedIndexes() )
{
selection << idx.data( QgsAttributeTableModel::FeatureIdRole ).value<QgsFeatureId>();
}
Expand Down Expand Up @@ -200,7 +200,7 @@ void QgsFeatureListView::setEditSelection( const QModelIndex& index, QItemSelect

void QgsFeatureListView::repaintRequested( QModelIndexList indexes )
{
foreach ( const QModelIndex index, indexes )
foreach ( const QModelIndex& index, indexes )
{
update( index );
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/attributetable/qgsfeatureselectionmodel.cpp
Expand Up @@ -59,7 +59,7 @@ void QgsFeatureSelectionModel::selectFeatures( const QItemSelection &selection,
{
QgsFeatureIds ids;

foreach ( const QModelIndex index, selection.indexes() )
foreach ( const QModelIndex& index, selection.indexes() )
{
QgsFeatureId id = index.model()->data( index, QgsAttributeTableModel::FeatureIdRole ).toLongLong();

Expand Down Expand Up @@ -124,7 +124,7 @@ void QgsFeatureSelectionModel::selectFeatures( const QItemSelection &selection,
connect( mFeatureSelectionManager, SIGNAL( selectionChanged( QgsFeatureIds, QgsFeatureIds, bool ) ), this, SLOT( layerSelectionChanged( QgsFeatureIds, QgsFeatureIds, bool ) ) );

QModelIndexList updatedIndexes;
foreach ( QModelIndex idx, selection.indexes() )
foreach ( const QModelIndex& idx, selection.indexes() )
{
updatedIndexes.append( expandIndexToRow( idx ) );
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/attributetable/qgsfieldconditionalformatwidget.cpp
Expand Up @@ -222,7 +222,7 @@ void QgsFieldConditionalFormatWidget::setPresets( QList<QgsConditionalStyle> sty
{
mPresets.clear();
mPresetsModel->clear();
foreach ( QgsConditionalStyle style, styles )
foreach ( const QgsConditionalStyle& style, styles )
{
if ( style.isValid() )
{
Expand Down Expand Up @@ -322,7 +322,7 @@ void QgsFieldConditionalFormatWidget::reloadStyles()
{
mModel->clear();

foreach ( QgsConditionalStyle style, getStyles() )
foreach ( const QgsConditionalStyle& style, getStyles() )
{
QStandardItem* item = new QStandardItem( style.displayText() );
item->setIcon( QIcon( style.renderPreview() ) );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsrelationreferencewidget.cpp
Expand Up @@ -449,7 +449,7 @@ void QgsRelationReferenceWidget::init()
QVariant nullValue = QSettings().value( "qgis/nullValue", "NULL" );
cb->addItem( nullValue.toString(), QVariant( mReferencedLayer->fields()[idx].type() ) );

Q_FOREACH ( QVariant v, uniqueValues )
Q_FOREACH ( const QVariant& v, uniqueValues )
{
cb->addItem( v.toString(), v );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsuniquevaluewidgetwrapper.cpp
Expand Up @@ -65,7 +65,7 @@ void QgsUniqueValuesWidgetWrapper::initWidget( QWidget* editor )

layer()->uniqueValues( fieldIdx(), values );

Q_FOREACH ( QVariant v, values )
Q_FOREACH ( const QVariant& v, values )
{
if ( mComboBox )
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/effects/qgspainteffectpropertieswidget.cpp
Expand Up @@ -91,7 +91,7 @@ void QgsPaintEffectPropertiesWidget::populateEffectTypes()
QgsPaintEffectRegistry* registry = QgsPaintEffectRegistry::instance();
QStringList types = registry->effects();

foreach ( QString type, types )
foreach ( const QString& type, types )
{
//don't show stack effect
if ( type == "effectStack" )
Expand Down
2 changes: 1 addition & 1 deletion src/gui/layertree/qgscustomlayerorderwidget.cpp
Expand Up @@ -105,7 +105,7 @@ class CustomLayerOrderModel : public QAbstractListModel
QMimeData* mimeData( const QModelIndexList& indexes ) const override
{
QStringList lst;
foreach ( QModelIndex index, indexes )
foreach ( const QModelIndex& index, indexes )
lst << data( index, Qt::UserRole + 1 ).toString();

QMimeData* mimeData = new QMimeData();
Expand Down
6 changes: 3 additions & 3 deletions src/gui/layertree/qgslayertreemapcanvasbridge.cpp
Expand Up @@ -119,7 +119,7 @@ void QgsLayerTreeMapCanvasBridge::setCanvasLayers()

if ( mHasCustomLayerOrder )
{
foreach ( QString layerId, mCustomLayerOrder )
foreach ( const QString& layerId, mCustomLayerOrder )
{
QgsLayerTreeLayer* nodeLayer = mRoot->findLayer( layerId );
if ( nodeLayer )
Expand Down Expand Up @@ -236,7 +236,7 @@ void QgsLayerTreeMapCanvasBridge::writeProject( QDomDocument& doc )
QDomElement customOrderElem = doc.createElement( "custom-order" );
customOrderElem.setAttribute( "enabled", mHasCustomLayerOrder ? 1 : 0 );

foreach ( QString layerId, mCustomLayerOrder )
foreach ( const QString& layerId, mCustomLayerOrder )
{
QDomElement itemElem = doc.createElement( "item" );
itemElem.appendChild( doc.createTextNode( layerId ) );
Expand Down Expand Up @@ -289,7 +289,7 @@ void QgsLayerTreeMapCanvasBridge::nodeAddedChildren( QgsLayerTreeNode* node, int
}
}

foreach ( QString layerId, layerIds )
foreach ( const QString& layerId, layerIds )
{
if ( !mCustomLayerOrder.contains( layerId ) )
mCustomLayerOrder.append( layerId );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/layertree/qgslayertreeviewdefaultactions.cpp
Expand Up @@ -172,7 +172,7 @@ void QgsLayerTreeViewDefaultActions::zoomToGroup( QgsMapCanvas* canvas )
return;

QList<QgsMapLayer*> layers;
foreach ( QString layerId, groupNode->findLayerIds() )
foreach ( const QString& layerId, groupNode->findLayerIds() )
layers << QgsMapLayerRegistry::instance()->mapLayer( layerId );

zoomToLayers( canvas, layers );
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsbrowsertreeview.cpp
Expand Up @@ -79,7 +79,7 @@ void QgsBrowserTreeView::restoreState()
if ( !mExpandPaths.isEmpty() )
{
QSet<QModelIndex> expandIndexSet;
foreach ( QString path, mExpandPaths )
foreach ( const QString& path, mExpandPaths )
{
QModelIndex expandIndex = QgsBrowserModel::findPath( model(), path, Qt::MatchStartsWith );
if ( expandIndex.isValid() )
Expand All @@ -89,7 +89,7 @@ void QgsBrowserTreeView::restoreState()
QgsDebugMsg( "index for path " + path + " not found" );
}
}
foreach ( QModelIndex expandIndex, expandIndexSet )
foreach ( const QModelIndex& expandIndex, expandIndexSet )
{
expandTree( expandIndex );
}
Expand Down Expand Up @@ -168,7 +168,7 @@ void QgsBrowserTreeView::rowsInserted( const QModelIndex & parentIndex, int star
// Remove the subtree from mExpandPaths if user collapsed the item in the meantime
if ( !treeExpanded( parentIndex ) )
{
foreach ( QString path, mExpandPaths )
foreach ( const QString& path, mExpandPaths )
{
if ( path.startsWith( parentPath + "/" ) )
mExpandPaths.removeOne( path );
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgscolorschemelist.cpp
Expand Up @@ -85,7 +85,7 @@ void QgsColorSchemeList::removeSelection()

//remove rows in descending order
qSort( rowsToRemove.begin(), rowsToRemove.end(), qGreater<int>() );
foreach ( const int row, rowsToRemove )
foreach ( int row, rowsToRemove )
{
mModel->removeRow( row );
}
Expand Down Expand Up @@ -125,7 +125,7 @@ void QgsColorSchemeList::copyColors()
QList<int> rowsToCopy = QList<int>::fromSet( rows.toSet() );

QgsNamedColorList colorsToCopy;
foreach ( const int row, rowsToCopy )
foreach ( int row, rowsToCopy )
{
colorsToCopy << mModel->colors().at( row );
}
Expand All @@ -150,7 +150,7 @@ void QgsColorSchemeList::keyPressEvent( QKeyEvent *event )

//remove rows in descending order
qSort( rowsToRemove.begin(), rowsToRemove.end(), qGreater<int>() );
foreach ( const int row, rowsToRemove )
foreach ( int row, rowsToRemove )
{
mModel->removeRow( row );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsdatadefinedbutton.cpp
Expand Up @@ -328,7 +328,7 @@ void QgsDataDefinedButton::aboutToShowMenu()
{
QgsExpressionContext context = mExpressionContextCallback( mExpressionContextCallbackContext );
QStringList variables = context.variableNames();
Q_FOREACH ( QString variable, variables )
Q_FOREACH ( const QString& variable, variables )
{
if ( context.isReadOnly( variable ) ) //only want to show user-set variables
continue;
Expand Down
10 changes: 5 additions & 5 deletions src/gui/qgsexpressionbuilderwidget.cpp
Expand Up @@ -188,7 +188,7 @@ void QgsExpressionBuilderWidget::updateFunctionFileList( QString path )
dir.setNameFilters( QStringList() << "*.py" );
QStringList files = dir.entryList( QDir::Files );
cmbFileNames->clear();
foreach ( QString name, files )
foreach ( const QString& name, files )
{
QFileInfo info( mFunctionsPath + QDir::separator() + name );
if ( info.baseName() == "__init__" ) continue;
Expand Down Expand Up @@ -321,7 +321,7 @@ void QgsExpressionBuilderWidget::fillFieldValues( const QString& fieldName, int
QList<QVariant> values;
QStringList strValues;
mLayer->uniqueValues( fieldIndex, values, countLimit );
foreach ( QVariant value, values )
foreach ( const QVariant& value, values )
{
QString strValue;
if ( value.isNull() )
Expand Down Expand Up @@ -416,7 +416,7 @@ void QgsExpressionBuilderWidget::loadRecent( QString key )
QSettings settings;
QString location = QString( "/expressions/recent/%1" ).arg( key );
QStringList expressions = settings.value( location ).toStringList();
foreach ( QString expression, expressions )
foreach ( const QString& expression, expressions )
{
this->registerItem( name, expression, expression, expression );
}
Expand Down Expand Up @@ -604,7 +604,7 @@ QString QgsExpressionBuilderWidget::formatPreviewString( const QString& previewS
void QgsExpressionBuilderWidget::loadExpressionContext()
{
QStringList variableNames = mExpressionContext.filteredVariableNames();
Q_FOREACH ( QString variable, variableNames )
Q_FOREACH ( const QString& variable, variableNames )
{
registerItem( "Variables", variable, " @" + variable + " ",
QgsExpression::variableHelpText( variable, true, mExpressionContext.variable( variable ) ),
Expand All @@ -614,7 +614,7 @@ void QgsExpressionBuilderWidget::loadExpressionContext()

// Load the functions from the expression context
QStringList contextFunctions = mExpressionContext.functionNames();
Q_FOREACH ( QString functionName, contextFunctions )
Q_FOREACH ( const QString& functionName, contextFunctions )
{
QgsExpression::Function* func = mExpressionContext.function( functionName );
QString name = func->name();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsexpressionhighlighter.cpp
Expand Up @@ -48,7 +48,7 @@ void QgsExpressionHighlighter::addFields( QStringList fieldList )
{
columnNameFormat.setForeground( Qt::darkRed );
HighlightingRule rule;
foreach ( const QString field, fieldList )
foreach ( const QString& field, fieldList )
{
if ( field.isEmpty() ) // this really happened :)
continue;
Expand Down

0 comments on commit 7c10760

Please sign in to comment.