From: nds Date: Fri, 8 Jul 2016 07:42:52 +0000 (+0300) Subject: Ability to have optional input fields in dialog panels (checkbox - page) X-Git-Tag: V_2.5.0~216 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c0bd44aa335296225a0cfd4eb6425a6c059fdc18;p=modules%2Fshaper.git Ability to have optional input fields in dialog panels (checkbox - page) --- diff --git a/src/Config/Config_Common.cpp b/src/Config/Config_Common.cpp index aaf1ed9cb..7d2a3ba87 100644 --- a/src/Config/Config_Common.cpp +++ b/src/Config/Config_Common.cpp @@ -73,7 +73,7 @@ bool isWidgetNode(xmlNodePtr theNode) if(!isElementNode(theNode)) return false; // it's parent is "feature" or "source" or a page ("box", "case") - if(!hasParent(theNode, NODE_FEATURE, NODE_SOURCE, WDG_GROUP, + if(!hasParent(theNode, NODE_FEATURE, NODE_SOURCE, WDG_GROUP, WDG_CHECK_GROUP, WDG_TOOLBOX_BOX, WDG_SWITCH_CASE, NULL)) return false; @@ -87,7 +87,7 @@ bool isCaseNode(xmlNodePtr theNode) if(!isElementNode(theNode)) return false; - return isNode(theNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, NULL); + return isNode(theNode, WDG_CHECK_GROUP, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, NULL); } bool hasChild(xmlNodePtr theNode) diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index 82ea91252..4f3b12cac 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -71,8 +71,14 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) aMessage->setAttributeId(anAttributeID); aMessage->setObligatory(getBooleanAttribute(theNode, ATTR_OBLIGATORY, true)); aMessage->setConcealment(getBooleanAttribute(theNode, ATTR_CONCEALMENT, false)); + if (hasParentRecursive(theNode, WDG_CHECK_GROUP, NULL)) { + const char* kWdgCase = WDG_CHECK_GROUP; + const char* kWdgSwitch = WDG_CHECK_GROUP; + aMessage->setCaseId(restoreAttribute(kWdgCase, _ID)); + aMessage->setSwitchId(restoreAttribute(kWdgSwitch, _ID)); + } // nested "paged" widgets are not allowed, this issue may be resolved here: - if (hasParentRecursive(theNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, NULL)) { + else if (hasParentRecursive(theNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, NULL)) { const char* kWdgCase = hasParentRecursive(theNode, WDG_SWITCH_CASE, NULL) ? WDG_SWITCH_CASE : WDG_TOOLBOX_BOX; @@ -85,7 +91,8 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) Events_Loop::loop()->send(aMessage); } // container pages, like "case" or "box" - } else if (isNode(theNode, WDG_SWITCH, WDG_SWITCH_CASE, WDG_TOOLBOX, WDG_TOOLBOX_BOX, NULL)) { + } else if (isNode(theNode, WDG_CHECK_GROUP, WDG_SWITCH, WDG_SWITCH_CASE, + WDG_TOOLBOX, WDG_TOOLBOX_BOX, NULL)) { storeAttribute(theNode, _ID); // save case:caseId (or box:boxId) } } @@ -95,7 +102,8 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) void Config_FeatureReader::cleanup(xmlNodePtr theNode) { - if (isNode(theNode, WDG_SWITCH, WDG_SWITCH_CASE, WDG_TOOLBOX, WDG_TOOLBOX_BOX, NULL)) { + if (isNode(theNode, WDG_CHECK_GROUP, WDG_SWITCH, WDG_SWITCH_CASE, + WDG_TOOLBOX, WDG_TOOLBOX_BOX, NULL)) { // cleanup id of cases when leave case node cleanupAttribute(theNode, _ID); } diff --git a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp index 116269485..05b0fc43f 100755 --- a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp +++ b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp @@ -5,7 +5,7 @@ // Author: Natalia ERMOLAEVA #include -#include +#include #include #include @@ -106,8 +106,9 @@ QLayout* ModuleBase_WidgetCheckGroupBox::pageLayout() bool ModuleBase_WidgetCheckGroupBox::storeValueCustom() { DataPtr aData = myFeature->data(); - std::shared_ptr aBool = aData->boolean(attributeID()); - aBool->setValue(myGroupBox->isChecked()); + AttributeStringPtr aStringAttr = aData->string(attributeID()); + aStringAttr->setValue(myGroupBox->isChecked() ? attributeID() : ""); + updateObject(myFeature); return true; @@ -116,10 +117,10 @@ bool ModuleBase_WidgetCheckGroupBox::storeValueCustom() bool ModuleBase_WidgetCheckGroupBox::restoreValueCustom() { DataPtr aData = myFeature->data(); - std::shared_ptr aRef = aData->boolean(attributeID()); + AttributeStringPtr aStringAttr = aData->string(attributeID()); bool isBlocked = myGroupBox->blockSignals(true); - myGroupBox->setChecked(aRef->value()); + myGroupBox->setChecked(!aStringAttr->value().empty()); myGroupBox->blockSignals(isBlocked); return true; diff --git a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h index 7bc9b041d..4e0dd3983 100755 --- a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h +++ b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h @@ -29,6 +29,10 @@ public: ModuleBase_WidgetCheckGroupBox(QWidget* theParent, const Config_WidgetAPI* theData); virtual ~ModuleBase_WidgetCheckGroupBox(); + /// Defines if it is supported to set the value in this widget + /// \return false because this is an info widget + virtual bool canAcceptFocus() const { return false; }; + /// Set the title of the group box /// \param theTitle the text of the title void setTitle(const QString& theTitle);