From ffbb0b6a46e84e8c39196ccd5d3cd6aa5551f07b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 2 Aug 2013 13:49:16 +0200 Subject: [PATCH] Use a special flag to indicate hidden children of a field. Added new method in PdmUiItem called isUiHideChildren() p4#: 22093 --- .../ProjectDataModel/RimResultSlot.cpp | 1 + cafProjectDataModel/cafPdmUiItem.cpp | 16 ++++++++++++++++ cafProjectDataModel/cafPdmUiItem.h | 12 ++++++++---- cafUserInterface/cafUiTreeModelPdm.cpp | 2 +- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimResultSlot.cpp index 90a990291f..a2acfb1d36 100644 --- a/ApplicationCode/ProjectDataModel/RimResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultSlot.cpp @@ -49,6 +49,7 @@ RimResultSlot::RimResultSlot() CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_legendConfigData, "ResultVarLegendDefinitionList", "", "", "", ""); m_legendConfigData.setUiHidden(true); + m_legendConfigData.setUiHideChildren(true); legendConfig = new RimLegendConfig(); } diff --git a/cafProjectDataModel/cafPdmUiItem.cpp b/cafProjectDataModel/cafPdmUiItem.cpp index f718777cf5..ba71f3ccdc 100644 --- a/cafProjectDataModel/cafPdmUiItem.cpp +++ b/cafProjectDataModel/cafPdmUiItem.cpp @@ -164,6 +164,22 @@ bool PdmUiItem::isUiHidden(QString uiConfigName) const return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiItem::isUiHideChildren(QString uiConfigName) const +{ + const PdmUiItemInfo* conInfo = configInfo(uiConfigName); + const PdmUiItemInfo* defInfo = defaultInfo(); + const PdmUiItemInfo* sttInfo = m_staticItemInfo; + + if (conInfo && !(conInfo->m_hideChildren == -1)) return conInfo->m_hideChildren; + if (defInfo && !(defInfo->m_hideChildren == -1)) return defInfo->m_hideChildren; + if (sttInfo && !(sttInfo->m_hideChildren == -1)) return sttInfo->m_hideChildren; + + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/cafProjectDataModel/cafPdmUiItem.h b/cafProjectDataModel/cafPdmUiItem.h index bbfbaa3abb..3b7b189669 100644 --- a/cafProjectDataModel/cafPdmUiItem.h +++ b/cafProjectDataModel/cafPdmUiItem.h @@ -35,12 +35,12 @@ class PdmUiItemInfo { public: PdmUiItemInfo() - : m_editorTypeName(""), m_isHidden(-1) , m_isReadOnly(-1) + : m_editorTypeName(""), m_isHidden(-1), m_hideChildren(-1), m_isReadOnly(-1) {} PdmUiItemInfo( QString uiName, QIcon icon = QIcon(), QString toolTip = "", QString whatsThis = "") : m_uiName(uiName), m_icon(icon), m_toolTip(toolTip), m_whatsThis(whatsThis), - m_editorTypeName(""), m_isHidden(false), m_isReadOnly(false), m_labelAlignment(LEFT) + m_editorTypeName(""), m_isHidden(false), m_hideChildren(false), m_isReadOnly(false), m_labelAlignment(LEFT) { } enum LabelPosType { LEFT, TOP, HIDDEN }; @@ -52,8 +52,9 @@ private: QString m_whatsThis; QIcon m_icon; QString m_editorTypeName; ///< Use this exact type of editor to edit this UiItem - int m_isHidden; ///< UiItem should be hidden. -1 means not set - int m_isReadOnly; ///< UiItem should be insensitive, or read only. -1 means not set. + int m_isHidden; ///< UiItem should be hidden. -1 means not set + int m_hideChildren; ///< Children of UiItem should be hidden. -1 means not set + int m_isReadOnly; ///< UiItem should be insensitive, or read only. -1 means not set. LabelPosType m_labelAlignment; }; @@ -115,6 +116,9 @@ public: bool isUiHidden(QString uiConfigName = "") const; void setUiHidden(bool isHidden, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isHidden = isHidden; } + bool isUiHideChildren(QString uiConfigName = "") const; + void setUiHideChildren(bool isHideChildren, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_hideChildren = isHideChildren; } + bool isUiReadOnly(QString uiConfigName = ""); void setUiReadOnly(bool isReadOnly, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isReadOnly = isReadOnly; } diff --git a/cafUserInterface/cafUiTreeModelPdm.cpp b/cafUserInterface/cafUiTreeModelPdm.cpp index 8b6b193ed7..ae48db6857 100644 --- a/cafUserInterface/cafUiTreeModelPdm.cpp +++ b/cafUserInterface/cafUiTreeModelPdm.cpp @@ -555,7 +555,7 @@ PdmUiTreeItem* UiTreeItemBuilderPdm::buildViewItems(PdmUiTreeItem* parentTreeIte // Fix for hidden legend definitions. There is only one visible legend definition, the others reside in a hidden container // Todo: This is a Hack. Must be rewritten when a more general ui tree building method is in place. // See comment at top of this method. - if (field->isUiHidden()) + if (field->isUiHideChildren()) { continue; }