1
0
mirror of https://github.com/qgis/QGIS.git synced 2025-04-24 00:04:42 -04:00

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

@ -63,7 +63,7 @@ class QgsFieldExpressionWidget : QWidget
//! when expression has been edited (finished) it will be added to the model //! when expression has been edited (finished) it will be added to the model
void expressionEditingFinished(); void expressionEditingFinished();
void currentFieldChanged( int i = 0 ); void currentFieldChanged();
/** /**
* @brief updateLineEditStyle will re-style (color/font) the line edit depending on content and status * @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; bool isExpression, isValid;
QString fieldName = currentField( &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 );
emit fieldChanged( fieldName, isValid ); emit fieldChanged( fieldName, isValid );
} }