diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2016-06-13 10:14:04 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2016-06-14 11:37:55 +0000 |
commit | af16128e059d51bc41dccafdbe52e8461572fb6e (patch) | |
tree | dfb4f1b8d61fc9292a7c620c689ea987c46c3778 /editorlib/src/editorsceneitemmodel.cpp | |
parent | 9b190770efe147d13df3eecfd1f725202d3f21c2 (diff) |
Multiselect refactoring
Now store multiselection status and list on c++ side only to
reduce problems from keeping them properly synchronized.
Change-Id: If3277bb1eca5ffc7a7749e300e0cc6de4ccf9df2
Reviewed-by: Titta Heikkala <titta.heikkala@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'editorlib/src/editorsceneitemmodel.cpp')
-rw-r--r-- | editorlib/src/editorsceneitemmodel.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/editorlib/src/editorsceneitemmodel.cpp b/editorlib/src/editorsceneitemmodel.cpp index b1cb8dd..5956c44 100644 --- a/editorlib/src/editorsceneitemmodel.cpp +++ b/editorlib/src/editorsceneitemmodel.cpp @@ -260,13 +260,13 @@ QHash<int, QByteArray> EditorSceneItemModel::roleNames() const void EditorSceneItemModel::resetModel() { - beginResetModel(); + QAbstractItemModel::beginResetModel(); // Reconnect all entities disconnectEntity(m_scene->sceneEntityItem()->entity()); connectEntity(m_scene->sceneEntityItem()->entity()); - endResetModel(); + QAbstractItemModel::endResetModel(); // Restore TreeView branch expansions, since resetting the model will collapse the branches QModelIndexList expandedIndexList; @@ -274,8 +274,9 @@ void EditorSceneItemModel::resetModel() expandedIndexList.append(getModelIndexByName(entityName)); emit expandItems(expandedIndexList); - // Select scene root after reset - emit selectIndex(sceneEntityIndex()); + // Select scene root after reset, unless multiselecting + if (!m_scene->multiSelection()) + emit selectIndex(sceneEntityIndex()); } EditorSceneItem *EditorSceneItemModel::editorSceneItemFromIndex(const QModelIndex &index) const @@ -464,11 +465,7 @@ const QString EditorSceneItemModel::setEntityName(const QModelIndex &index, cons setData(index, finalName, NameRole); - QStringList multiSelection = m_scene->multiSelection(); - if (multiSelection.removeOne(oldName)) { - multiSelection.append(finalName); - m_scene->setMultiSelection(multiSelection); - } + m_scene->renameEntityInMultiSelectionList(oldName, finalName); if (oldName == m_scene->clipboardContent()) m_scene->setClipboardContent(name); @@ -537,11 +534,13 @@ bool EditorSceneItemModel::canReparent(EditorSceneItem *newParentItem, EditorSceneItem *movedItem, bool allowSameParent) { // Dropping into camera is invalid. + // Reparenting camera is invalid. // Dropping into same parent is invalid. // Dropping item into its descendant is invalid. // If allowSameParent is true, "reparenting" under the same parent is allowed. This is useful // for entity tree copy & paste functionality. - bool reparentOk = !EditorUtils::entityCameraLens(newParentItem->entity()) + bool reparentOk = newParentItem->itemType() != EditorSceneItem::Camera + && movedItem->itemType() != EditorSceneItem::Camera && movedItem != newParentItem && !EditorUtils::isDescendant(movedItem, newParentItem); if (!allowSameParent) |