Skip to content

Commit 7f1bb72

Browse files
authoredJul 28, 2017
Merge pull request #4937 from m-kuhn/attributeTableCodeEnhancements$
Attribute table code enhancements
2 parents 4705c97 + f43df12 commit 7f1bb72

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed
 

‎src/gui/attributetable/qgsdualview.cpp

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

476476
QgsAttributeTableAction *a = new QgsAttributeTableAction( action.name(), this, action.id(), sourceIndex );
477+
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
477478
menu->addAction( action.name(), a, SLOT( execute() ) );
479+
#else
480+
menu->addAction( action.name(), a, &QgsAttributeTableAction::execute );
481+
#endif
478482
}
479483
}
480484

@@ -485,17 +489,24 @@ void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atInd
485489
//add a separator between user defined and standard actions
486490
menu->addSeparator();
487491

488-
QList<QgsMapLayerAction *>::iterator actionIt;
489-
for ( actionIt = registeredActions.begin(); actionIt != registeredActions.end(); ++actionIt )
492+
Q_FOREACH ( QgsMapLayerAction *action, registeredActions )
490493
{
491-
QgsAttributeTableMapLayerAction *a = new QgsAttributeTableMapLayerAction( ( *actionIt )->text(), this, ( *actionIt ), sourceIndex );
492-
menu->addAction( ( *actionIt )->text(), a, SLOT( execute() ) );
494+
QgsAttributeTableMapLayerAction *a = new QgsAttributeTableMapLayerAction( action->text(), this, action, sourceIndex );
495+
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
496+
menu->addAction( action->text(), a, SLOT( execut() ) );
497+
#else
498+
menu->addAction( action->text(), a, &QgsAttributeTableMapLayerAction::execute );
499+
#endif
493500
}
494501
}
495502

496503
menu->addSeparator();
497504
QgsAttributeTableAction *a = new QgsAttributeTableAction( tr( "Open form" ), this, QString(), sourceIndex );
505+
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
498506
menu->addAction( tr( "Open form" ), a, SLOT( featureForm() ) );
507+
#else
508+
menu->addAction( tr( "Open form" ), a, &QgsAttributeTableAction::featureForm );
509+
#endif
499510
}
500511

501512
void QgsDualView::showViewHeaderMenu( QPoint point )

‎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.