Skip to content

Commit

Permalink
Use expression preview for variable values in variable editor widget
Browse files Browse the repository at this point in the history
Means that values which are non-text, e.g. points, geometries,
lists, maps, etc show a value in the widget
  • Loading branch information
nyalldawson committed Aug 27, 2018
1 parent 05a311b commit 0ad341a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/gui/qgsvariableeditorwidget.cpp
Expand Up @@ -360,8 +360,9 @@ void QgsVariableEditorTree::refreshScopeVariables( QgsExpressionContextScope *sc

item->setFlags( item->flags() | Qt::ItemIsEnabled );
item->setText( 0, name );
QString value = scope->variable( name ).toString();
item->setText( 1, value );
const QVariant value = scope->variable( name );
const QString previewString = QgsExpression::formatPreviewString( value, false );
item->setText( 1, previewString );
QFont font = item->font( 0 );
if ( readOnly || !isCurrent )
{
Expand All @@ -385,7 +386,7 @@ void QgsVariableEditorTree::refreshScopeVariables( QgsExpressionContextScope *sc
{
font.setStrikeOut( false );
item->setToolTip( 0, name );
item->setToolTip( 1, value );
item->setToolTip( 1, previewString );
}
item->setFont( 0, font );
item->setFont( 1, font );
Expand Down

0 comments on commit 0ad341a

Please sign in to comment.