Skip to content
Permalink
Browse files

Handle sorted or reordered columns when copying cell contents

  • Loading branch information
nyalldawson committed Jun 2, 2016
1 parent 3da3cf1 commit 3da460e44368a8e99a9debbcf29722611aa1f7a7
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/gui/attributetable/qgsdualview.cpp
@@ -389,7 +389,8 @@ void QgsDualView::copyCellContent() const
QModelIndex index = action->data().value<QModelIndex>();

QgsFeature f = masterModel()->feature( index );
QVariant var = f.attributes().at( index.column() );
int attrIndex = mMasterModel->fieldIdx( index.column() );
QVariant var = f.attributes().at( attrIndex );
QApplication::clipboard()->setText( var.toString() );
}
}
@@ -401,8 +402,11 @@ 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>( atIndex ) );
copyContentAction->setData( QVariant::fromValue<QModelIndex>( sourceIndex ) );
menu->addAction( copyContentAction );
connect( copyContentAction, SIGNAL( triggered() ), this, SLOT( copyCellContent() ) );

@@ -413,8 +417,6 @@ void QgsDualView::viewWillShowContextMenu( QMenu* menu, const QModelIndex& atInd
menu->addAction( tr( "Zoom to feature" ), this, SLOT( zoomToCurrentFeature() ) );
}

QModelIndex sourceIndex = mFilterModel->mapToSource( atIndex );

//add user-defined actions to context menu
if ( mLayerCache->layer()->actions()->size() != 0 )
{

0 comments on commit 3da460e

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