summaryrefslogtreecommitdiffstats
path: root/editorlib/src/undohandler/resetentitycommand.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2016-06-20 14:05:23 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2016-06-20 12:26:00 +0000
commit9a3e96a6a90400c39bcc11c0f6e7e1e9ffed8616 (patch)
tree38705ae2dfd591324848efba65b6345a99ae11e6 /editorlib/src/undohandler/resetentitycommand.cpp
parent2fd6f64f35f30b5776a3b67217634598a905409a (diff)
Properly update group selection box in various undo/redo situations
Change-Id: I1e950465c4e0fb0e2dd79d6eed5047266fd525d2 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'editorlib/src/undohandler/resetentitycommand.cpp')
-rw-r--r--editorlib/src/undohandler/resetentitycommand.cpp9
1 files changed, 7 insertions, 2 deletions
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);
}