Skip to content
Permalink
Browse files

Fix Duplicate and Digitize action duplicates wrong feature when

table is sorted

Fixes #33665
  • Loading branch information
roya0045 authored and nyalldawson committed Apr 28, 2020
1 parent 7e0e4a1 commit c6ccf375721bc9e2583797c955e8962769257a3a
Showing with 6 additions and 8 deletions.
  1. +1 −1 src/gui/attributetable/qgsattributetableview.cpp
  2. +5 −7 src/gui/attributetable/qgsdualview.cpp
@@ -359,7 +359,7 @@ void QgsAttributeTableView::contextMenuEvent( QContextMenuEvent *event )
delete mActionPopup;
mActionPopup = nullptr;

QModelIndex idx = indexAt( event->pos() );
QModelIndex idx = mFilterModel->mapToMaster( indexAt( event->pos() ) );
if ( !idx.isValid() )
{
return;
@@ -709,7 +709,7 @@ void QgsDualView::copyCellContent() const
if ( action && action->data().isValid() && action->data().canConvert<QModelIndex>() )
{
QModelIndex index = action->data().toModelIndex();
QVariant var = masterModel()->data( index, Qt::DisplayRole );
QVariant var = mMasterModel->data( index, Qt::DisplayRole );
QApplication::clipboard()->setText( var.toString() );
}
}
@@ -741,10 +741,8 @@ void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atInd
return;
}

QModelIndex sourceIndex = mFilterModel->mapToSource( atIndex );

QAction *copyContentAction = new QAction( tr( "Copy Cell Content" ), this );
copyContentAction->setData( QVariant::fromValue<QModelIndex>( sourceIndex ) );
copyContentAction->setData( QVariant::fromValue<QModelIndex>( atIndex ) );
menu->addAction( copyContentAction );
connect( copyContentAction, &QAction::triggered, this, &QgsDualView::copyCellContent );

@@ -773,11 +771,11 @@ void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atInd
if ( vl && !vl->isEditable() && action.isEnabledOnlyWhenEditable() )
continue;

QgsAttributeTableAction *a = new QgsAttributeTableAction( action.name(), this, action.id(), sourceIndex );
QgsAttributeTableAction *a = new QgsAttributeTableAction( action.name(), this, action.id(), atIndex );
menu->addAction( action.name(), a, &QgsAttributeTableAction::execute );
}
}
QModelIndex rowSourceIndex = mFilterModel->fidToIndex( mFilterModel->rowToId( atIndex ) );
QModelIndex rowSourceIndex = mMasterModel->index( atIndex.row(), 0 );
if ( ! rowSourceIndex.isValid() )
{
return;
@@ -799,7 +797,7 @@ void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atInd

// entries for multiple features layer actions
// only show if the context menu is shown over a selected row
QgsFeatureId currentFid = masterModel()->rowToId( sourceIndex.row() );
QgsFeatureId currentFid = masterModel()->rowToId( atIndex.row() );
if ( mLayer->selectedFeatureCount() > 1 && mLayer->selectedFeatureIds().contains( currentFid ) )
{
const QList<QgsMapLayerAction *> constRegisteredActions = QgsGui::mapLayerActionRegistry()->mapLayerActions( mLayer, QgsMapLayerAction::MultipleFeatures );

0 comments on commit c6ccf37

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