void QgsAttributeTableView::contextMenuEvent( QContextMenuEvent *event ) { if ( mActionPopup ) { delete mActionPopup; mActionPopup = 0; } QModelIndex idx = indexAt( event->pos() ); if ( !idx.isValid() ) { return; } QgsVectorLayer *vlayer = mModel->layer(); if ( !vlayer ) return; mActionPopup = new QMenu(); // let some other parts of the application add some actions emit willShowContextMenu( mActionPopup, idx ); if ( mActionPopup->actions().count() > 0 ) { mActionPopup->popup( event->globalPos() ); } }
void QgsFeatureListView::contextMenuEvent( QContextMenuEvent *event ) { QModelIndex index = indexAt( event->pos() ); if ( index.isValid() ) { QgsFeature feature = mModel->data( index, QgsFeatureListModel::FeatureRole ).value<QgsFeature>(); QgsActionMenu *menu = new QgsActionMenu( mModel->layerCache()->layer(), feature, QStringLiteral( "Feature" ), this ); emit willShowContextMenu( menu, index ); menu->exec( event->globalPos() ); } }