Skip to content

Commit a62b026

Browse files
committedJul 28, 2017
Q_FOREACH instead of non const iterator
1 parent cd83c3c commit a62b026

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed
 

‎src/gui/attributetable/qgsdualview.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atInd
474474
continue;
475475

476476
QgsAttributeTableAction *a = new QgsAttributeTableAction( action.name(), this, action.id(), sourceIndex );
477-
menu->addAction( action.name(), a, SLOT( execute() ) );
477+
menu->addAction( action.name(), a, &QgsAttributeTableAction::execute );
478478
}
479479
}
480480

@@ -485,11 +485,10 @@ void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atInd
485485
//add a separator between user defined and standard actions
486486
menu->addSeparator();
487487

488-
QList<QgsMapLayerAction *>::iterator actionIt;
489-
for ( actionIt = registeredActions.begin(); actionIt != registeredActions.end(); ++actionIt )
488+
Q_FOREACH ( QgsMapLayerAction *action, registeredActions )
490489
{
491-
QgsAttributeTableMapLayerAction *a = new QgsAttributeTableMapLayerAction( ( *actionIt )->text(), this, ( *actionIt ), sourceIndex );
492-
menu->addAction( ( *actionIt )->text(), a, &QgsAttributeTableMapLayerAction::execute );
490+
QgsAttributeTableMapLayerAction *a = new QgsAttributeTableMapLayerAction( action->text(), this, action, sourceIndex );
491+
menu->addAction( action->text(), a, &QgsAttributeTableMapLayerAction::execute );
493492
}
494493
}
495494

‎src/gui/qgsmaplayeractionregistry.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ void QgsMapLayerActionRegistry::addMapLayerAction( QgsMapLayerAction *action )
108108
QList< QgsMapLayerAction * > QgsMapLayerActionRegistry::mapLayerActions( QgsMapLayer *layer, QgsMapLayerAction::Targets targets )
109109
{
110110
QList< QgsMapLayerAction * > validActions;
111-
QList<QgsMapLayerAction *>::iterator actionIt;
112-
for ( actionIt = mMapLayerActionList.begin(); actionIt != mMapLayerActionList.end(); ++actionIt )
111+
112+
Q_FOREACH ( QgsMapLayerAction *action, mMapLayerActionList )
113113
{
114-
if ( ( *actionIt )->canRunUsingLayer( layer ) && ( targets & ( *actionIt )->targets() ) )
114+
if ( action->canRunUsingLayer( layer ) && ( targets & action->targets() ) )
115115
{
116-
validActions.append( ( *actionIt ) );
116+
validActions.append( action );
117117
}
118118
}
119119
return validActions;

0 commit comments

Comments
 (0)
Please sign in to comment.