diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiOrdering.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiOrdering.h index 3719fb3863..0d395d0313 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiOrdering.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiOrdering.h @@ -81,12 +81,30 @@ private: }; //================================================================================================== -/// Class representing a group of fields +/// Class representing a group of fields communicated to the Gui //================================================================================================== class PdmUiGroup : public PdmUiItem, public PdmUiOrdering { +public: + PdmUiGroup() { m_isCollapsedByDefault = false; m_hasForcedExpandedState = false; m_forcedCollapseState = false;} + virtual bool isUiGroup() { return true; } + + /// Set this group to be collapsed by default. When the user expands the group, the default no longer has any effect. + void setCollapsedByDefault(bool doCollapse) { m_isCollapsedByDefault = doCollapse;} + /// Forcifully set the collapsed state of the group, overriding the previous user actions and the default + void setCollapsed(bool doCollapse) { m_hasForcedExpandedState = true; m_forcedCollapseState = doCollapse;} + + // Internal use + bool isExpandedByDefault() const { return !m_isCollapsedByDefault;} + bool hasForcedExpandedState() const { return m_hasForcedExpandedState;} + bool forcedExpandedState() const { return !m_forcedCollapseState;} + +private: + bool m_isCollapsedByDefault; + bool m_hasForcedExpandedState; + bool m_forcedCollapseState; }; diff --git a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt index 4f62ae0f67..23148be42c 100644 --- a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt +++ b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt @@ -23,6 +23,7 @@ set( QOBJECT_HEADERS cafPdmUiCheckBoxTristateEditor.h cafPdmUiColorEditor.h cafPdmUiComboBoxEditor.h + cafPdmUiDefaultObjectEditor.h cafPdmUiDoubleSliderEditor.h cafPdmUiFilePathEditor.h cafPdmUiLineEditor.h diff --git a/Fwk/AppFwk/cafUserInterface/QMinimizePanel.cpp b/Fwk/AppFwk/cafUserInterface/QMinimizePanel.cpp index 2547762931..893fdb0c53 100644 --- a/Fwk/AppFwk/cafUserInterface/QMinimizePanel.cpp +++ b/Fwk/AppFwk/cafUserInterface/QMinimizePanel.cpp @@ -181,14 +181,26 @@ void QMinimizePanel::setTitle(const QString& title) m_titleLabel->setText(title); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString QMinimizePanel::title() const +{ + return m_titleLabel->text(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void QMinimizePanel::setExpanded(bool isExpanded) { + if (m_contentFrame->isHidden() != isExpanded) return; + m_contentFrame->setVisible(isExpanded); isExpanded ? m_collapseButton->setIcon(expandUpIcon()) : m_collapseButton->setIcon(expandDownIcon()); this->QWidget::updateGeometry(); + + emit expandedChanged(isExpanded); } //-------------------------------------------------------------------------------------------------- @@ -196,7 +208,7 @@ void QMinimizePanel::setExpanded(bool isExpanded) //-------------------------------------------------------------------------------------------------- void QMinimizePanel::toggleExpanded() { - setExpanded(!m_contentFrame->isVisible()); + setExpanded(m_contentFrame->isHidden()); } //-------------------------------------------------------------------------------------------------- @@ -207,7 +219,7 @@ QSize QMinimizePanel::minimumSizeHint() const QSize labelSize = m_titleLabel->sizeHint(); QSize titleBarHint = labelSize + QSize(4 + labelSize.height() + 8 - 2 + 1, 8); - if (m_contentFrame->isVisible()) + if (!m_contentFrame->isHidden()) { QSize titleBarMin(0, labelSize.height() + 8 ); QSize contentsMin(m_contentFrame->minimumSizeHint()); @@ -236,10 +248,10 @@ void QMinimizePanel::resizeEvent(QResizeEvent *resizeEv ) int buttonSize = titleHeight - 2; m_titleFrame->setGeometry(0,0,width, titleHeight); - m_titleLabel->setGeometry( 4, titleHeight - labelHeight - 4, width - buttonSize - 1, labelHeight); + m_titleLabel->setGeometry( 4, titleHeight - labelHeight - 4, width - 4 - buttonSize - 1, labelHeight); m_collapseButton->setGeometry(width - buttonSize - 1, 1, buttonSize, buttonSize); - m_contentFrame->setGeometry(0, titleHeight-1, width, heigth - titleHeight-1); + m_contentFrame->setGeometry(0, titleHeight-1, width, heigth - (titleHeight-1)); } bool QMinimizePanel::event(QEvent* event) diff --git a/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h b/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h index 08d330139a..22d58c7069 100644 --- a/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h +++ b/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h @@ -52,10 +52,15 @@ public: QFrame * contentFrame() { return m_contentFrame; } void setTitle (const QString& title); + QString title() const; public slots: void setExpanded(bool isExpanded); void toggleExpanded(); + +signals: + void expandedChanged(bool isExpanded); + public: virtual QSize minimumSizeHint() const override; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp index f7638677f9..e1caef3c5a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp @@ -227,6 +227,7 @@ void PdmUiDefaultObjectEditor::recursiveSetupFieldsAndGroups(const std::vector
setTitle(uiItems[i]->uiName()); groupBoxLayout = new QGridLayout(); groupBox->contentFrame()->setLayout(groupBoxLayout); + connect(groupBox, SIGNAL(expandedChanged(bool)), this, SLOT(groupBoxExpandedStateToggled(bool))); m_newGroupBoxes[groupBoxKey] = groupBox; } @@ -244,6 +245,11 @@ void PdmUiDefaultObjectEditor::recursiveSetupFieldsAndGroups(const std::vector
addWidget(groupBox, currentRowIndex, 0, 1, 2); + + // Set Expanded state + bool isExpanded = isUiGroupExpanded(group); + groupBox->setExpanded(isExpanded); + recursiveSetupFieldsAndGroups(groupChildren, groupBox->contentFrame(), groupBoxLayout, uiConfigName); currentRowIndex++; } @@ -358,6 +364,28 @@ void PdmUiDefaultObjectEditor::recursiveSetupFieldsAndGroups(const std::vector
hasForcedExpandedState()) return uiGroup->forcedExpandedState();
+
+ auto kwMapPair = m_objectKeywordGroupUiNameExpandedState.find(pdmObject()->xmlCapability()->classKeyword());
+ if ( kwMapPair != m_objectKeywordGroupUiNameExpandedState.end() )
+ {
+ QString uiName = uiGroup->uiName();
+
+ auto uiNameExpStatePair = kwMapPair->second.find(uiName);
+ if ( uiNameExpStatePair != kwMapPair->second.end() )
+ {
+ return uiNameExpStatePair->second;
+ }
+ }
+
+ return uiGroup->isExpandedByDefault();
+}
+
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -447,4 +475,20 @@ caf::PdmUiFieldEditorHandle* PdmUiFieldEditorHelper::fieldEditorForField(PdmUiFi
return fieldEditor;
}
+//--------------------------------------------------------------------------------------------------
+///
+//--------------------------------------------------------------------------------------------------
+void PdmUiDefaultObjectEditor::groupBoxExpandedStateToggled(bool isExpanded)
+{
+ if (!this->pdmObject()->xmlCapability()) return;
+
+ QString objKeyword = this->pdmObject()->xmlCapability()->classKeyword();
+ QMinimizePanel* panel = dynamic_cast