Skip to content

Commit

Permalink
Fix Duplicate and Digitize action duplicates wrong feature when
Browse files Browse the repository at this point in the history
table is sorted

Fixes #33665
  • Loading branch information
roya0045 authored and nyalldawson committed Jun 2, 2020
1 parent 7e0e4a1 commit c6ccf37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/gui/attributetable/qgsattributetableview.cpp
Expand Up @@ -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;
Expand Down
12 changes: 5 additions & 7 deletions src/gui/attributetable/qgsdualview.cpp
Expand Up @@ -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() );
}
}
Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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;
Expand All @@ -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 );
Expand Down

0 comments on commit c6ccf37

Please sign in to comment.