Skip to content
Permalink
Browse files

use lambda to set value to null

cherry-picked from fbbb320
  • Loading branch information
signedav committed Oct 8, 2018
1 parent 11ebdee commit a5981f307c5bf34f46bf016934ae6cba795974a7
Showing with 3 additions and 8 deletions.
  1. +3 −7 src/gui/qgsfeaturelistcombobox.cpp
  2. +0 −1 src/gui/qgsfeaturelistcombobox.h
@@ -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 );
@@ -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() );
}
@@ -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

0 comments on commit a5981f3

Please sign in to comment.
You can’t perform that action at this time.