Skip to content
Permalink
Browse files

list action with MultipleFeatures as target to be run for the layer s…

…election
  • Loading branch information
3nids committed Feb 4, 2020
1 parent 95a6a89 commit e855faa70e25a01e1fe8062cb9485951dd63068a
Showing with 17 additions and 0 deletions.
  1. +17 −0 src/gui/attributetable/qgsdualview.cpp
@@ -720,6 +720,23 @@ void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atInd
}
}

// entries for multiple features layer actions
if ( mLayer->selectedFeatureCount() > 1 )
{
const QList<QgsMapLayerAction *> constRegisteredActions = QgsGui::mapLayerActionRegistry()->mapLayerActions( mLayer, QgsMapLayerAction::MultipleFeatures );
if ( !constRegisteredActions.isEmpty() )
{
menu->addSeparator();
QAction *action = menu->addAction( tr( "Actions on selection (%1)" ).arg( mLayer->selectedFeatureCount() ) );
action->setEnabled( false );

for ( QgsMapLayerAction *action : constRegisteredActions )
{
menu->addAction( action->text(), action, [ = ]() {action->triggerForFeatures( mLayer, mLayer->selectedFeatures() );} );
}
}
}

menu->addSeparator();
QgsAttributeTableAction *a = new QgsAttributeTableAction( tr( "Open Form" ), this, QString(), rowSourceIndex );
menu->addAction( tr( "Open Form" ), a, &QgsAttributeTableAction::featureForm );

0 comments on commit e855faa

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