Skip to content

Commit f380df1

Browse files
committedJun 6, 2014
FieldExpressionWidget: add tooltip if expression is larger than widget
1 parent 63af881 commit f380df1

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
 

‎python/gui/qgsfieldexpressionwidget.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class QgsFieldExpressionWidget : QWidget
6363
//! when expression has been edited (finished) it will be added to the model
6464
void expressionEditingFinished();
6565

66-
void currentFieldChanged( int i = 0 );
66+
void currentFieldChanged();
6767

6868
/**
6969
* @brief updateLineEditStyle will re-style (color/font) the line edit depending on content and status

‎src/gui/qgsfieldexpressionwidget.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ void QgsFieldExpressionWidget::currentFieldChanged( int i /* =0 */ )
195195

196196
bool isExpression, isValid;
197197
QString fieldName = currentField( &isExpression, &isValid );
198+
199+
// display tooltip if widget is shorter than expression
200+
QFontMetrics metrics( mCombo->lineEdit()->font() );
201+
if ( metrics.width( fieldName ) > mCombo->lineEdit()->width() )
202+
{
203+
mCombo->setToolTip( fieldName );
204+
}
205+
else
206+
{
207+
mCombo->setToolTip( "" );
208+
}
209+
198210
emit fieldChanged( fieldName );
199211
emit fieldChanged( fieldName, isValid );
200212
}

0 commit comments

Comments
 (0)
Please sign in to comment.