Skip to content

Commit

Permalink
add signal with expression validity
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed May 2, 2014
1 parent d828f6b commit 778fb62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/gui/qgsfieldexpressionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ void QgsFieldExpressionWidget::indexChanged( int i )
Q_UNUSED( i );
bool isExpression;
QString fieldName = currentField( &isExpression );
bool isValid = true;

QFont font = mCombo->lineEdit()->font();
font.setItalic( isExpression );
Expand All @@ -159,7 +160,7 @@ void QgsFieldExpressionWidget::indexChanged( int i )
QModelIndex idx = mFieldModel->indexFromName( fieldName );
if ( idx.isValid() )
{
bool isValid = mFieldModel->data( idx, QgsFieldModel::ExpressionValidityRole ).toBool();
isValid = mFieldModel->data( idx, QgsFieldModel::ExpressionValidityRole ).toBool();
if ( !isValid )
{
palette.setColor( QPalette::Text, Qt::red );
Expand All @@ -169,4 +170,5 @@ void QgsFieldExpressionWidget::indexChanged( int i )
mCombo->lineEdit()->setPalette( palette );

emit fieldChanged( fieldName );
emit fieldChanged( fieldName, isValid );
}
3 changes: 3 additions & 0 deletions src/gui/qgsfieldexpressionwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget
//! the signal is emitted when the currently selected field changes
void fieldChanged( QString fieldName );

//! fieldChanged signal with indication of the validity of the expression
void fieldChanged( QString fieldName, bool isValid );

public slots:
//! set the layer used to display the fields and expression
void setLayer( QgsVectorLayer* layer );
Expand Down

0 comments on commit 778fb62

Please sign in to comment.