Skip to content

Commit

Permalink
FieldExpressionWidget: add tooltip if expression is larger than widget
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jun 6, 2014
1 parent 63af881 commit f380df1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/gui/qgsfieldexpressionwidget.sip
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/gui/qgsfieldexpressionwidget.cpp
Expand Up @@ -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 );
}
Expand Down

0 comments on commit f380df1

Please sign in to comment.