Skip to content
Permalink
Browse files

Remaining Q_FOREACH to for changes

  • Loading branch information
m-kuhn committed Apr 15, 2019
1 parent 6cd293f commit 2f3646a1424c1bab436ab1a28263eb1ed75e5c53

Large diffs are not rendered by default.

@@ -1756,8 +1756,9 @@ void QgisApp::dropEvent( QDropEvent *event )

void QgisApp::annotationCreated( QgsAnnotation *annotation )
{
const auto canvases = mapCanvases();
// create canvas annotation item for annotation
Q_FOREACH ( QgsMapCanvas *canvas, mapCanvases() )
for ( QgsMapCanvas *canvas : canvases )
{
QgsMapCanvasAnnotationItem *canvasItem = new QgsMapCanvasAnnotationItem( annotation, canvas );
Q_UNUSED( canvasItem ); //item is already added automatically to canvas scene
@@ -3469,7 +3470,8 @@ void QgisApp::setupConnections()

connect( mRenderSuppressionCBox, &QAbstractButton::toggled, this, [ = ]( bool flag )
{
Q_FOREACH ( QgsMapCanvas *canvas, mapCanvases() )
const auto canvases = mapCanvases();
for ( QgsMapCanvas *canvas : canvases )
canvas->setRenderFlag( flag );
if ( !flag )
canvasRefreshFinished(); // deals with the busy indicator in case of ongoing rendering
@@ -3829,7 +3831,8 @@ QgsMapCanvas *QgisApp::createNewMapCanvas( const QString &name )

QgsMapCanvasDockWidget *QgisApp::createNewMapCanvasDock( const QString &name )
{
Q_FOREACH ( QgsMapCanvas *canvas, mapCanvases() )
const auto canvases = mapCanvases();
for ( QgsMapCanvas *canvas : canvases )
{
if ( canvas->objectName() == name )
{
@@ -3897,7 +3900,8 @@ void QgisApp::setupDockWidget( QDockWidget *dockWidget, bool isFloating, QRect d

void QgisApp::closeMapCanvas( const QString &name )
{
Q_FOREACH ( QgsMapCanvasDockWidget *w, findChildren< QgsMapCanvasDockWidget * >() )
const auto dockWidgets = findChildren< QgsMapCanvasDockWidget * >();
for ( QgsMapCanvasDockWidget *w : dockWidgets )
{
if ( w->mapCanvas()->objectName() == name )
{
@@ -3911,7 +3915,8 @@ void QgisApp::closeMapCanvas( const QString &name )
void QgisApp::closeAdditionalMapCanvases()
{
freezeCanvases( true ); // closing docks may cause canvases to resize, and we don't want a map refresh occurring
Q_FOREACH ( QgsMapCanvasDockWidget *w, findChildren< QgsMapCanvasDockWidget * >() )
const auto dockWidgets = findChildren< QgsMapCanvasDockWidget * >();
for ( QgsMapCanvasDockWidget *w : dockWidgets )
{
w->close();
delete w;
@@ -3933,7 +3938,8 @@ void QgisApp::closeAdditional3DMapCanvases()

void QgisApp::freezeCanvases( bool frozen )
{
Q_FOREACH ( QgsMapCanvas *canvas, mapCanvases() )
const auto canvases = mapCanvases();
for ( QgsMapCanvas *canvas : canvases )
{
canvas->freeze( frozen );
}
@@ -6926,7 +6932,8 @@ void QgisApp::removeWindow( QAction *action )

void QgisApp::stopRendering()
{
Q_FOREACH ( QgsMapCanvas *canvas, mapCanvases() )
const auto canvases = mapCanvases();
for ( QgsMapCanvas *canvas : canvases )
canvas->stopRendering();
}

@@ -7266,7 +7273,8 @@ void QgisApp::modifyAnnotation()

void QgisApp::reprojectAnnotations()
{
Q_FOREACH ( QgsMapCanvasAnnotationItem *annotation, annotationItems() )
const auto annotations = annotationItems();
for ( QgsMapCanvasAnnotationItem *annotation : annotations )
{
annotation->updatePosition();
}
@@ -9393,7 +9401,8 @@ void QgisApp::copyFeatures( QgsFeatureStore &featureStore )

void QgisApp::refreshMapCanvas()
{
Q_FOREACH ( QgsMapCanvas *canvas, mapCanvases() )
const auto canvases = mapCanvases();
for ( QgsMapCanvas *canvas : canvases )
{
//stop any current rendering
canvas->stopRendering();
@@ -9666,7 +9675,8 @@ void QgisApp::saveAllEdits( bool verifyAction )
return;
}

Q_FOREACH ( QgsMapLayer *layer, editableLayers( true ) )
const auto layers = editableLayers( true );
for ( QgsMapLayer *layer : layers )
{
saveEdits( layer, true, false );
}
@@ -9693,7 +9703,8 @@ void QgisApp::rollbackAllEdits( bool verifyAction )
return;
}

Q_FOREACH ( QgsMapLayer *layer, editableLayers( true ) )
const auto layers = editableLayers( true );
for ( QgsMapLayer *layer : layers )
{
cancelEdits( layer, true, false );
}
@@ -9720,7 +9731,8 @@ void QgisApp::cancelAllEdits( bool verifyAction )
return;
}

Q_FOREACH ( QgsMapLayer *layer, editableLayers() )
const auto layers = editableLayers();
for ( QgsMapLayer *layer : layers )
{
cancelEdits( layer, false, false );
}
@@ -10758,7 +10770,8 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString &currentPage, in

setupLayerTreeViewFromSettings();

Q_FOREACH ( QgsMapCanvas *canvas, mapCanvases() )
const auto canvases = mapCanvases();
for ( QgsMapCanvas *canvas : canvases )
{
applyDefaultSettingsToCanvas( canvas );
}
@@ -10773,7 +10786,7 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString &currentPage, in
}

//do we need this? TS
Q_FOREACH ( QgsMapCanvas *canvas, mapCanvases() )
for ( QgsMapCanvas *canvas : canvases )
{
canvas->refresh();
}
@@ -13120,12 +13133,13 @@ void QgisApp::renameView()

// calculate existing names
QStringList names;
Q_FOREACH ( QgsMapCanvas *c, mapCanvases() )
const auto canvases = mapCanvases();
for ( QgsMapCanvas *canvas : canvases )
{
if ( c == view->mapCanvas() )
if ( canvas == view->mapCanvas() )
continue;

names << c->objectName();
names << canvas->objectName();
}

QString currentName = view->mapCanvas()->objectName();
@@ -13693,7 +13707,8 @@ void QgisApp::writeProject( QDomDocument &doc )

// Save the position of the map view docks
QDomElement mapViewNode = doc.createElement( QStringLiteral( "mapViewDocks" ) );
Q_FOREACH ( QgsMapCanvasDockWidget *w, findChildren< QgsMapCanvasDockWidget * >() )
const auto dockWidgets = findChildren< QgsMapCanvasDockWidget * >();
for ( QgsMapCanvasDockWidget *w : dockWidgets )
{
QDomElement node = doc.createElement( QStringLiteral( "view" ) );
node.setAttribute( QStringLiteral( "name" ), w->mapCanvas()->objectName() );
@@ -596,7 +596,8 @@ QList< LegendLayerAction > QgsAppLayerTreeViewMenuProvider::legendLayerActions(
{
QgsDebugMsg( QStringLiteral( "legendLayerActions for layers of type %1:" ).arg( static_cast<int>( type ) ) );

Q_FOREACH ( const LegendLayerAction &lyrAction, mLegendLayerActionMap[ type ] )
const auto legendLayerActions { mLegendLayerActionMap.value( type ) };
for ( const LegendLayerAction &lyrAction : legendLayerActions )
{
Q_UNUSED( lyrAction );
QgsDebugMsg( QStringLiteral( "%1/%2 - %3 layers" ).arg( lyrAction.menu, lyrAction.action->text() ).arg( lyrAction.layers.count() ) );
@@ -28,10 +28,10 @@ QgsDiscoverRelationsDlg::QgsDiscoverRelationsDlg( const QList<QgsRelation> &exis
connect( mRelationsTable->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsDiscoverRelationsDlg::onSelectionChanged );

mFoundRelations = QgsRelationManager::discoverRelations( existingRelations, layers );
Q_FOREACH ( const QgsRelation &relation, mFoundRelations ) addRelation( relation );
for ( const QgsRelation &relation : qgis::as_const( mFoundRelations ) )
addRelation( relation );

mRelationsTable->resizeColumnsToContents();

}

void QgsDiscoverRelationsDlg::addRelation( const QgsRelation &rel )
@@ -53,7 +53,6 @@ void QgsDiscoverRelationsDlg::addRelation( const QgsRelation &rel )
}

mRelationsTable->item( row, 5 )->setToolTip( QStringLiteral( "Composition (child features will be copied too) or Association" ) );

}

QList<QgsRelation> QgsDiscoverRelationsDlg::relations() const
@@ -88,7 +88,8 @@ void QgsMapLayerStyleGuiUtils::addStyleManagerActions( QMenu *m, QgsMapLayer *la
m->addAction( actionRemoveStyle( layer, m ) );
m->addAction( actionRenameStyle( layer, m ) );
m->addSeparator();
Q_FOREACH ( QAction *a, actionsUseStyle( layer, m ) )
const auto actions {actionsUseStyle( layer, m )};
for ( QAction *a : actions )
m->addAction( a );
}

@@ -229,7 +229,7 @@ QComboBox *QgsMergeAttributesDialog::createMergeComboBox( QVariant::Type columnT
case QVariant::Int:
case QVariant::LongLong:
{
Q_FOREACH ( QgsStatisticalSummary::Statistic stat, DISPLAY_STATS )
for ( QgsStatisticalSummary::Statistic stat : qgis::as_const( DISPLAY_STATS ) )
{
newComboBox->addItem( QgsStatisticalSummary::displayName( stat ), stat );
}
@@ -207,7 +207,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
///////////////////////////////////////////////////////////
// Properties stored in QgsProject

Q_FOREACH ( QgsVectorLayer *layer, QgsProject::instance()->layers<QgsVectorLayer *>() )
const auto layers { QgsProject::instance()->layers<QgsVectorLayer *>() };
for ( QgsVectorLayer *layer : layers )
{
if ( layer->isEditable() )
{
@@ -2339,7 +2340,8 @@ void QgsProjectProperties::populateEllipsoidList()
myItem.semiMinor = 6370997.0;
mEllipsoidList.append( myItem );

Q_FOREACH ( const QgsEllipsoidUtils::EllipsoidDefinition &def, QgsEllipsoidUtils::definitions() )
const auto definitions {QgsEllipsoidUtils::definitions()};
for ( const QgsEllipsoidUtils::EllipsoidDefinition &def : definitions )
{
myItem.acronym = def.acronym;
myItem.description = def.description;
@@ -116,8 +116,8 @@ void QgsRelationManagerDialog::mBtnAddRelation_clicked()

QStringList existingNames;


Q_FOREACH ( const QgsRelation &rel, relations() )
const auto rels { relations() };
for ( const QgsRelation &rel : rels )
{
existingNames << rel.id();
}

0 comments on commit 2f3646a

Please sign in to comment.
You can’t perform that action at this time.