summaryrefslogtreecommitdiffstats
path: root/editorlib
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2016-06-09 14:31:17 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2016-06-09 11:48:43 +0000
commita50d0b976bd26ced679c742f612314ace4f7a624 (patch)
tree81e4aab3ee66895cf4c08eb4a2e4f273e61e386a /editorlib
parent4cecefdd612a028e4eab13497abb9ea7ce7befb8 (diff)
Make grouping work correctly with multiselected parents and children
Change-Id: Ie0a933d4ab2adf699ea2b343aa744e1b6d7a677c Reviewed-by: Titta Heikkala <titta.heikkala@qt.io>
Diffstat (limited to 'editorlib')
-rw-r--r--editorlib/qml/ComponentMenu.qml19
-rw-r--r--editorlib/src/editorsceneitem.h2
2 files changed, 16 insertions, 5 deletions
diff --git a/editorlib/qml/ComponentMenu.qml b/editorlib/qml/ComponentMenu.qml
index 8a9f759..5a993ab 100644
--- a/editorlib/qml/ComponentMenu.qml
+++ b/editorlib/qml/ComponentMenu.qml
@@ -168,15 +168,26 @@ Menu {
}
MenuItem {
text: qsTr("Group Selected") + editorScene.emptyString
- enabled: multiSelect && !multiSelectedCamera
+ enabled: !entityTreeView.sceneRootSelected
iconSource: "images/group.png"
onTriggered: {
editorScene.undoHandler.beginMacro(text)
- var reparentList = selectionList // Copy list, as the original is emptied on insertEntity
+ // Copy list, as the original is emptied on insertEntity
+ var reparentList = []
+ var groupCenter
+ if (entityTree.multiSelect) {
+ reparentList = editorScene.sceneModel.parentList(selectionList)
+ groupCenter = editorScene.getMultiSelectionCenter()
+ } else {
+ reparentList[0] = selectedEntityName
+ groupCenter = selectedEntity.selectionBoxCenter()
+ }
+
// TODO: Allow creating groups under other entities?
- // Center the new group on the grouped items
- var groupCenter = editorScene.getMultiSelectionCenter()
+ // Select scene root before doing reparenting to avoid having selection changes
+ // while removing, as indexes can be corrupt during the removal
+ entityTree.selectSceneRoot()
// Add new group
editorScene.undoHandler.createInsertEntityCommand(1, editorScene.sceneRootName(),
diff --git a/editorlib/src/editorsceneitem.h b/editorlib/src/editorsceneitem.h
index 9337c14..ecb9d17 100644
--- a/editorlib/src/editorsceneitem.h
+++ b/editorlib/src/editorsceneitem.h
@@ -97,7 +97,7 @@ public:
Qt3DCore::QTransform *entityTransform() const { return m_entityTransform; }
QVector3D selectionBoxExtents() const { return m_selectionBoxExtents; }
QVector3D entityMeshExtents() const { return m_entityMeshExtents; }
- QVector3D selectionBoxCenter() const { return m_selectionBoxCenter; }
+ Q_INVOKABLE QVector3D selectionBoxCenter() const { return m_selectionBoxCenter; }
QVector3D entityMeshCenter() const { return m_entityMeshCenter; }
bool canRotate() const { return m_canRotate; }