FieldExpressionWidget: add tooltip if expression is larger than widget

This commit is contained in:
Denis Rouzaud 2014-06-06 08:45:03 +02:00
parent 63af881a38
commit f380df1cd7
2 changed files with 13 additions and 1 deletions

View File

@ -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

View File

@ -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 );
}