Skip to content
Permalink
Browse files

Merge pull request #36554 from alexbruy/copy-variable

use value from context when copying variables from the editor widget (fix #30641)
  • Loading branch information
alexbruy committed May 20, 2020
2 parents 9a0a129 + f16ee3e commit 7053b78ac6a793379fc99fa7821154a2a3a76d13
Showing with 20 additions and 1 deletion.
  1. +20 −1 src/gui/qgsvariableeditorwidget.cpp
@@ -28,7 +28,7 @@
#include <QPushButton>
#include <QHeaderView>
#include <QMessageBox>

#include <QClipboard>

//
// QgsVariableEditorWidget
@@ -627,6 +627,25 @@ void QgsVariableEditorTree::keyPressEvent( QKeyEvent *event )
default:
break;
}

if ( event == QKeySequence::Copy )
{
QList<QTreeWidgetItem *> 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 );
}

0 comments on commit 7053b78

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