diff --git a/src/gui/qgsvariableeditorwidget.cpp b/src/gui/qgsvariableeditorwidget.cpp index 3299681c72c..62883af1bed 100644 --- a/src/gui/qgsvariableeditorwidget.cpp +++ b/src/gui/qgsvariableeditorwidget.cpp @@ -28,7 +28,7 @@ #include #include #include - +#include // // QgsVariableEditorWidget @@ -627,6 +627,25 @@ void QgsVariableEditorTree::keyPressEvent( QKeyEvent *event ) default: break; } + + if ( event == QKeySequence::Copy ) + { + QList selected = selectedItems(); + if ( selected.size() > 0 ) + { + QString text = selected.at( 0 )->text( 0 ); + QString varName = variableNameFromItem( selected.at( 0 ) ); + QgsExpressionContextScope *scope = scopeFromItem( selected.at( 0 ) ); + if ( !varName.isEmpty() && scope ) + text = scope->variable( varName ).toString(); + + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText( text ); + event->accept(); + return; + } + } + QTreeWidget::keyPressEvent( event ); }