]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Ability to have optional input fields in dialog panels (checkbox - page)
authornds <nds@opencascade.com>
Fri, 8 Jul 2016 07:42:52 +0000 (10:42 +0300)
committernds <nds@opencascade.com>
Fri, 8 Jul 2016 07:43:18 +0000 (10:43 +0300)
src/Config/Config_Common.cpp
src/Config/Config_FeatureReader.cpp
src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp
src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h

index aaf1ed9cbc1e24d641f5d55303e3eb15a48aaef8..7d2a3ba874e08e43ea979d924ece85027e53f225 100644 (file)
@@ -73,7 +73,7 @@ bool isWidgetNode(xmlNodePtr theNode)
   if(!isElementNode(theNode))\r
     return false;\r
   // it's parent is "feature" or "source" or a page ("box", "case")\r
-  if(!hasParent(theNode, NODE_FEATURE, NODE_SOURCE, WDG_GROUP,\r
+  if(!hasParent(theNode, NODE_FEATURE, NODE_SOURCE, WDG_GROUP, WDG_CHECK_GROUP,\r
                          WDG_TOOLBOX_BOX, WDG_SWITCH_CASE, NULL))\r
     return false;\r
 \r
@@ -87,7 +87,7 @@ bool isCaseNode(xmlNodePtr theNode)
   if(!isElementNode(theNode))\r
     return false;\r
 \r
-  return isNode(theNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, NULL);\r
+  return isNode(theNode, WDG_CHECK_GROUP, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, NULL);\r
 }\r
 \r
 bool hasChild(xmlNodePtr theNode)\r
index 82ea91252b26412e27871c7e79a97e3d580b4dd3..4f3b12cacaa5a042fad1abffc5c643ba77f65071 100644 (file)
@@ -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);
   }
index 11626948590b3661591766cb89230a94f2fb7638..05b0fc43f7dbec5e94218b5f0bb7f6bb25c55ad2 100755 (executable)
@@ -5,7 +5,7 @@
 // Author:      Natalia ERMOLAEVA
 
 #include <ModuleBase_WidgetCheckGroupBox.h>
-#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeString.h>
 
 #include <Config_WidgetAPI.h>
 #include <Config_Keywords.h>
@@ -106,8 +106,9 @@ QLayout* ModuleBase_WidgetCheckGroupBox::pageLayout()
 bool ModuleBase_WidgetCheckGroupBox::storeValueCustom()
 {
   DataPtr aData = myFeature->data();
-  std::shared_ptr<ModelAPI_AttributeBoolean> 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<ModelAPI_AttributeBoolean> 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;
index 7bc9b041dba32966890a0e1dbde7ac56e59408f5..4e0dd398362471456d151be14ad09670d0ac128a 100755 (executable)
@@ -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);