mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
use value from context when copying variables from the editor widget
(fix #30641)
This commit is contained in:
parent
8499e09e28
commit
f16ee3ed9f
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user