From 0998331303ddb079868e4c347f9b22fc9af9262d Mon Sep 17 00:00:00 2001 From: Janne Kangas Date: Wed, 12 Jun 2019 15:55:46 +0300 Subject: Reconstruct inspector group on property group change Reconstruct the inspector group when the property list within group changes. This can happen when a property becomes conditionally (in)visible when another property changes. Change-Id: I6fad26b13401ed8d31efe91f4ecfefeb0ea16910 Task-id: QT3DS-3683 Reviewed-by: Mahmoud Badri Reviewed-by: Jari Karppinen Reviewed-by: Miikka Heikkinen --- .../Palettes/Inspector/Qt3DSDMInspectable.cpp | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.cpp index c42840a4..a4a484fe 100644 --- a/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.cpp +++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.cpp @@ -29,6 +29,7 @@ #include "Qt3DSDMInspectable.h" #include "Qt3DSDMInspectorGroup.h" +#include "Qt3DSDMInspectorRow.h" #include "StudioApp.h" #include "Core.h" #include "Doc.h" @@ -96,14 +97,30 @@ long Qt3DSDMInspectable::getGroupCount() const // Return the property group for display CInspectorGroup *Qt3DSDMInspectable::getGroup(long index) { - if (m_groups.contains(index)) - return m_groups[index]; + TMetaDataPropertyHandleList properties = GetGroupProperties(index); + if (m_groups.contains(index)) { + // Check if the group properties have changed. This can f.ex happen if property + // filter status changed and it became visible. + std::vector rows + = static_cast(m_groups[index])->GetRows(); + TMetaDataPropertyHandleList rowProps; + + for (uint i = 0; i < rows.size(); ++i) + rowProps.push_back(rows[i]->GetMetaDataProperty()); + + // No need to sort; if ordering has changed for some reason, group also needs to be + // reconstructed. (Assume that the default case is that row ordering is derived from + // property ordering, so we can use direct == operator to see if properties match the + // inspector rows.) + if (properties == rowProps) + return m_groups[index]; + + delete m_groups[index]; + } Qt3DSDMInspectorGroup *group = new Qt3DSDMInspectorGroup(GetGroupName(index)); m_groups[index] = group; - TMetaDataPropertyHandleList properties = GetGroupProperties(index); - for (auto &prop : properties) group->CreateRow(getDoc(), prop); -- cgit v1.2.3