Skip to content

Commit

Permalink
do not overwrite text entry on editing and model reloadings
Browse files Browse the repository at this point in the history
cherry-picked from 43f77fd
  • Loading branch information
signedav committed Oct 30, 2018
1 parent 1276671 commit 374862c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/gui/qgsfeaturelistcombobox.cpp
Expand Up @@ -111,7 +111,8 @@ void QgsFeatureListComboBox::onItemSelected( const QModelIndex &index )


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


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


int QgsFeatureListComboBox::nullIndex() const int QgsFeatureListComboBox::nullIndex() const
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsfeaturelistcombobox.h
Expand Up @@ -220,6 +220,7 @@ class GUI_EXPORT QgsFeatureListComboBox : public QComboBox
QgsFilterLineEdit *mLineEdit; QgsFilterLineEdit *mLineEdit;
bool mPopupRequested = false; bool mPopupRequested = false;
bool mIsCurrentlyEdited = false; bool mIsCurrentlyEdited = false;
bool mHasStoredEditState = false;
LineEditState mLineEditState; LineEditState mLineEditState;
}; };


Expand Down

0 comments on commit 374862c

Please sign in to comment.