From 9a3e96a6a90400c39bcc11c0f6e7e1e9ffed8616 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 20 Jun 2016 14:05:23 +0300 Subject: Properly update group selection box in various undo/redo situations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1e950465c4e0fb0e2dd79d6eed5047266fd525d2 Reviewed-by: Tomi Korpipää --- editorlib/src/undohandler/resetentitycommand.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'editorlib/src/undohandler/resetentitycommand.cpp') diff --git a/editorlib/src/undohandler/resetentitycommand.cpp b/editorlib/src/undohandler/resetentitycommand.cpp index a7fb755..bb3a6c3 100644 --- a/editorlib/src/undohandler/resetentitycommand.cpp +++ b/editorlib/src/undohandler/resetentitycommand.cpp @@ -55,12 +55,15 @@ void ResetEntityCommand::undo() if (m_removedEntity) { // Remove the new entity with default values QModelIndex index = m_sceneModel->getModelIndexByName(m_entityName); + EditorSceneItem *item = m_sceneModel->editorSceneItemFromIndex(index); + bool reselect = item->entity() == m_sceneModel->scene()->selection(); m_sceneModel->removeEntity(index); // Insert the old entity back QModelIndex parentIndex = m_sceneModel->getModelIndexByName(m_parentEntityName); m_sceneModel->insertExistingEntity(m_removedEntity, m_row, parentIndex); - m_sceneModel->scene()->setSelection(m_removedEntity); + if (reselect) + m_sceneModel->scene()->setSelection(m_removedEntity); m_removedEntity = nullptr; } } @@ -73,6 +76,7 @@ void ResetEntityCommand::redo() m_row = index.row(); EditorSceneItem *item = m_sceneModel->editorSceneItemFromIndex(index); m_type = EditorUtils::insertableEntityType(item->entity()); + bool reselect = item->entity() == m_sceneModel->scene()->selection(); // Insert a new entity with default values Qt3DCore::QEntity *entity = m_sceneModel->createEntity(m_type, QVector3D(), parentIndex); @@ -94,5 +98,6 @@ void ResetEntityCommand::redo() break; } } - m_sceneModel->scene()->setSelection(entity); + if (reselect) + m_sceneModel->scene()->setSelection(entity); } -- cgit v1.2.3