summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2019-03-25 15:24:45 +0200
committerTomi Korpipää <tomi.korpipaa@qt.io>2019-03-26 10:20:16 +0000
commit472c6076b31c7932fb54a2faf4402b29a04f0661 (patch)
tree3ae0bfdb44808c5d8c3cf7cbce1730adf2c41009
parent0c44c1066c4ecc67fff587fbb6b6c083f794bddd (diff)
Disallow grouping of ungroupable items
Change-Id: Ifdcfb6020fd2f712ea3f9a35785755bd47f42c41 Fixes: QT3DS-3220 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Kaj Grönholm <kaj.gronholm@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Studio/Application/StudioApp.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp
index c49aec65..5dc9fbe5 100644
--- a/src/Authoring/Studio/Application/StudioApp.cpp
+++ b/src/Authoring/Studio/Application/StudioApp.cpp
@@ -1045,7 +1045,34 @@ bool CStudioApp::canGroupSelectedObjects() const
// Grouping is allowed for single and for multiple selected items.
qt3dsdm::TInstanceHandleList selected = m_core->GetDoc()
->GetSelectedValue().GetSelectedInstances();
- return (selected.size() >= 1);
+ if (selected.size() >= 1) {
+ // Scene objects, any direct children of scene objects (layers and behaviors), effects,
+ // root components, images, and materials are not groupable. Anything that can be
+ // multiselected can be grouped, so its enough to check the first selected object's type.
+ // Behavior that is not direct child of scene could technically be grouped, but since it
+ // cannot be multiselected, we treat it as ungroupable.
+ qt3dsdm::Qt3DSDMInstanceHandle first = selected[0];
+ if (first.Valid()) {
+ EStudioObjectType type = m_core->GetDoc()->GetStudioSystem()->GetClientDataModelBridge()
+ ->GetObjectType(first);
+
+ const int ungroupableTypes = OBJTYPE_SCENE | OBJTYPE_LAYER | OBJTYPE_MATERIAL
+ | OBJTYPE_CUSTOMMATERIAL | OBJTYPE_REFERENCEDMATERIAL | OBJTYPE_BEHAVIOR
+ | OBJTYPE_EFFECT | OBJTYPE_IMAGE;
+
+ if (type & ungroupableTypes)
+ return false;
+
+ if (type == OBJTYPE_COMPONENT) {
+ // Components can't be grouped if they are the root of currently active time context
+ auto bridge = m_core->GetDoc()->GetStudioSystem()->GetClientDataModelBridge();
+ if (bridge->IsActiveComponent(first))
+ return false;
+ }
+ return true;
+ }
+ }
+ return false;
}
bool CStudioApp::canUngroupSelectedObjects() const