@@ -389,7 +389,8 @@ void QgsDualView::copyCellContent() const
389
389
QModelIndex index = action->data ().value <QModelIndex>();
390
390
391
391
QgsFeature f = masterModel ()->feature ( index );
392
- QVariant var = f.attributes ().at ( index.column () );
392
+ int attrIndex = mMasterModel ->fieldIdx ( index.column () );
393
+ QVariant var = f.attributes ().at ( attrIndex );
393
394
QApplication::clipboard ()->setText ( var.toString () );
394
395
}
395
396
}
@@ -401,8 +402,11 @@ void QgsDualView::viewWillShowContextMenu( QMenu* menu, const QModelIndex& atInd
401
402
return ;
402
403
}
403
404
405
+
406
+ QModelIndex sourceIndex = mFilterModel ->mapToSource ( atIndex );
407
+
404
408
QAction *copyContentAction = new QAction ( tr ( " Copy cell content" ), this );
405
- copyContentAction->setData ( QVariant::fromValue<QModelIndex>( atIndex ) );
409
+ copyContentAction->setData ( QVariant::fromValue<QModelIndex>( sourceIndex ) );
406
410
menu->addAction ( copyContentAction );
407
411
connect ( copyContentAction, SIGNAL ( triggered () ), this , SLOT ( copyCellContent () ) );
408
412
@@ -413,8 +417,6 @@ void QgsDualView::viewWillShowContextMenu( QMenu* menu, const QModelIndex& atInd
413
417
menu->addAction ( tr ( " Zoom to feature" ), this , SLOT ( zoomToCurrentFeature () ) );
414
418
}
415
419
416
- QModelIndex sourceIndex = mFilterModel ->mapToSource ( atIndex );
417
-
418
420
// add user-defined actions to context menu
419
421
if ( mLayerCache ->layer ()->actions ()->size () != 0 )
420
422
{
0 commit comments