Skip to content
Permalink
Browse files
Followup 73ffb83, finishing changing all Q_FOREACH to references
  • Loading branch information
nyalldawson committed Sep 9, 2015
1 parent d4e3fcd commit 7c10760225396a4cf04886ca9a94ef417bf4ed4e
Show file tree
Hide file tree
Showing 99 changed files with 226 additions and 225 deletions.
@@ -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 ) )
{
@@ -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() );
@@ -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 );
}
@@ -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;
@@ -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();
}
@@ -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;
@@ -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() ) );
}
}
@@ -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 );
@@ -1567,7 +1567,7 @@ void QgsProjectProperties::populateEllipsoidList()

// Add all items to selector

foreach ( i, mEllipsoidList )
foreach ( const EllipsoidDefs& i, mEllipsoidList )
{
cmbEllipsoid->addItem( i.description );
}
@@ -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 );
@@ -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
@@ -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();
@@ -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;
@@ -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 ) );
}
@@ -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 );
}
@@ -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>')" );
}
@@ -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>();
}
@@ -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 );
}
@@ -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();

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