Skip to content
Permalink
Browse files
FieldExpressionWidget: add tooltip if expression is larger than widget
  • Loading branch information
3nids committed Jun 6, 2014
1 parent 63af881 commit f380df1cd76f2e0fa6fcafae75a9a49191f37f3c
Showing with 13 additions and 1 deletion.
  1. +1 −1 python/gui/qgsfieldexpressionwidget.sip
  2. +12 −0 src/gui/qgsfieldexpressionwidget.cpp
@@ -63,7 +63,7 @@ class QgsFieldExpressionWidget : QWidget
//! when expression has been edited (finished) it will be added to the model
void expressionEditingFinished();

void currentFieldChanged( int i = 0 );
void currentFieldChanged();

/**
* @brief updateLineEditStyle will re-style (color/font) the line edit depending on content and status
@@ -195,6 +195,18 @@ void QgsFieldExpressionWidget::currentFieldChanged( int i /* =0 */ )

bool isExpression, isValid;
QString fieldName = currentField( &isExpression, &isValid );

// display tooltip if widget is shorter than expression
QFontMetrics metrics( mCombo->lineEdit()->font() );
if ( metrics.width( fieldName ) > mCombo->lineEdit()->width() )
{
mCombo->setToolTip( fieldName );
}
else
{
mCombo->setToolTip( "" );
}

emit fieldChanged( fieldName );
emit fieldChanged( fieldName, isValid );
}

0 comments on commit f380df1

Please sign in to comment.