forked from qt-creator/qt-creator
Utils: Fix StringSelectionAspect
Previously the undo state was not updated when the value was set from the outside before the gui model was setup. Change-Id: I380916f888edd120f512089bdb94762977c11978 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -3286,8 +3286,10 @@ QStandardItem *StringSelectionAspect::itemById(const QString &id)
|
|||||||
|
|
||||||
void StringSelectionAspect::bufferToGui()
|
void StringSelectionAspect::bufferToGui()
|
||||||
{
|
{
|
||||||
if (!m_model)
|
if (!m_model) {
|
||||||
|
m_undoable.setSilently(m_buffer);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto selected = itemById(m_buffer);
|
auto selected = itemById(m_buffer);
|
||||||
if (selected) {
|
if (selected) {
|
||||||
@@ -3302,8 +3304,10 @@ void StringSelectionAspect::bufferToGui()
|
|||||||
m_selectionModel->setCurrentIndex(m_model->item(0)->index(),
|
m_selectionModel->setCurrentIndex(m_model->item(0)->index(),
|
||||||
QItemSelectionModel::SelectionFlag::ClearAndSelect);
|
QItemSelectionModel::SelectionFlag::ClearAndSelect);
|
||||||
} else {
|
} else {
|
||||||
|
m_undoable.setSilently(m_buffer);
|
||||||
m_selectionModel->setCurrentIndex(QModelIndex(), QItemSelectionModel::SelectionFlag::Clear);
|
m_selectionModel->setCurrentIndex(QModelIndex(), QItemSelectionModel::SelectionFlag::Clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleGuiChanged();
|
handleGuiChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user