Skip to content

Commit 374862c

Browse files
committed
do not overwrite text entry on editing and model reloadings
cherry-picked from 43f77fd
1 parent 1276671 commit 374862c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/gui/qgsfeaturelistcombobox.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ void QgsFeatureListComboBox::onItemSelected( const QModelIndex &index )
111111

112112
void QgsFeatureListComboBox::onCurrentIndexChanged( int i )
113113
{
114-
mIsCurrentlyEdited = false;
114+
if ( !mHasStoredEditState )
115+
mIsCurrentlyEdited = false;
115116
QModelIndex modelIndex = mModel->index( i, 0, QModelIndex() );
116117
mModel->setExtraIdentifierValue( mModel->data( modelIndex, QgsFeatureFilterModel::IdentifierValueRole ) );
117118
mLineEdit->setText( mModel->data( modelIndex, QgsFeatureFilterModel::ValueRole ).toString() );
@@ -130,13 +131,19 @@ void QgsFeatureListComboBox::onActivated( QModelIndex modelIndex )
130131
void QgsFeatureListComboBox::storeLineEditState()
131132
{
132133
if ( mIsCurrentlyEdited )
134+
{
135+
mHasStoredEditState = true;
133136
mLineEditState.store( mLineEdit );
137+
}
134138
}
135139

136140
void QgsFeatureListComboBox::restoreLineEditState()
137141
{
138142
if ( mIsCurrentlyEdited )
143+
{
144+
mHasStoredEditState = false;
139145
mLineEditState.restore( mLineEdit );
146+
}
140147
}
141148

142149
int QgsFeatureListComboBox::nullIndex() const

src/gui/qgsfeaturelistcombobox.h

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ class GUI_EXPORT QgsFeatureListComboBox : public QComboBox
220220
QgsFilterLineEdit *mLineEdit;
221221
bool mPopupRequested = false;
222222
bool mIsCurrentlyEdited = false;
223+
bool mHasStoredEditState = false;
223224
LineEditState mLineEditState;
224225
};
225226

0 commit comments

Comments
 (0)