Skip to content
Permalink
Browse files

do not overwrite text entry on editing and model reloadings

  • Loading branch information
signedav committed Oct 4, 2018
1 parent 713192f commit 43f77fda5834d3d52707814f9d4019c7e8533c69
Showing with 9 additions and 1 deletion.
  1. +8 −1 src/gui/qgsfeaturelistcombobox.cpp
  2. +1 −0 src/gui/qgsfeaturelistcombobox.h
@@ -111,7 +111,8 @@ void QgsFeatureListComboBox::onItemSelected( const QModelIndex &index )

void QgsFeatureListComboBox::onCurrentIndexChanged( int i )
{
mIsCurrentlyEdited = false;
if ( !mHasStoredEditState )
mIsCurrentlyEdited = false;
QModelIndex modelIndex = mModel->index( i, 0, QModelIndex() );
mModel->setExtraIdentifierValue( mModel->data( modelIndex, QgsFeatureFilterModel::IdentifierValueRole ) );
mLineEdit->setText( mModel->data( modelIndex, QgsFeatureFilterModel::ValueRole ).toString() );
@@ -130,13 +131,19 @@ void QgsFeatureListComboBox::onActivated( QModelIndex modelIndex )
void QgsFeatureListComboBox::storeLineEditState()
{
if ( mIsCurrentlyEdited )
{
mHasStoredEditState = true;
mLineEditState.store( mLineEdit );
}
}

void QgsFeatureListComboBox::restoreLineEditState()
{
if ( mIsCurrentlyEdited )
{
mHasStoredEditState = false;
mLineEditState.restore( mLineEdit );
}
}

int QgsFeatureListComboBox::nullIndex() const
@@ -220,6 +220,7 @@ class GUI_EXPORT QgsFeatureListComboBox : public QComboBox
QgsFilterLineEdit *mLineEdit;
bool mPopupRequested = false;
bool mIsCurrentlyEdited = false;
bool mHasStoredEditState = false;
LineEditState mLineEditState;
};

0 comments on commit 43f77fd

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