Skip to content

Commit

Permalink
use lambda to set value to null
Browse files Browse the repository at this point in the history
cherry-picked from fbbb320
  • Loading branch information
signedav committed Oct 30, 2018
1 parent 11ebdee commit a5981f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/gui/qgsfeaturelistcombobox.cpp
Expand Up @@ -53,7 +53,9 @@ QgsFeatureListComboBox::QgsFeatureListComboBox( QWidget *parent )

mLineEdit = new QgsFilterLineEdit();
mLineEdit->setSelectOnFocus( true );
connect( mLineEdit, &QgsFilterLineEdit::cleared, this, &QgsFeatureListComboBox::setValueToNull );
//set value of combo to null if delete button is pressed
connect( mLineEdit, &QgsFilterLineEdit::cleared, this, [ = ] { if ( allowNull() ) setCurrentIndex( nullIndex() ); } );

setEditable( true );
setLineEdit( mLineEdit );
setModel( mModel );
Expand Down Expand Up @@ -256,9 +258,3 @@ void QgsFeatureListComboBox::LineEditState::restore( QLineEdit *lineEdit ) const
if ( selectionStart > -1 )
lineEdit->setSelection( selectionStart, selectionLength );
}

void QgsFeatureListComboBox::setValueToNull()
{
if ( allowNull() )
setCurrentIndex( nullIndex() );
}
1 change: 0 additions & 1 deletion src/gui/qgsfeaturelistcombobox.h
Expand Up @@ -200,7 +200,6 @@ class GUI_EXPORT QgsFeatureListComboBox : public QComboBox
void storeLineEditState();
void restoreLineEditState();
void onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>() );
void setValueToNull();

private:
struct LineEditState
Expand Down

0 comments on commit a5981f3

Please sign in to comment.