diff options
author | Janne Kangas <janne.kangas@qt.io> | 2019-06-12 15:55:46 +0300 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2019-06-20 11:30:25 +0300 |
commit | 0998331303ddb079868e4c347f9b22fc9af9262d (patch) | |
tree | 889598530b44a63f050ef62d3ce502bf3e3fbbcb | |
parent | 53224e268c56749e51ea98e105b2d8875dc84900 (diff) |
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 <mahmoud.badri@qt.io>
Reviewed-by: Jari Karppinen <jari.karppinen@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r-- | src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.cpp | 25 |
1 files 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<Q3DStudio::Qt3DSDMInspectorRow *> rows + = static_cast<const Qt3DSDMInspectorGroup *>(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); |