From aeff2c65984b63ed02a0e569511f18e83899274e Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 14 Jul 2016 10:46:44 +0300 Subject: [PATCH] Issue #1659 New widget for supporting optional inputs : rename CheckGroupBox to OptionalBox as it shows usual check box for singular widget. --- src/Config/Config_Common.cpp | 8 ++-- src/Config/Config_FeatureReader.cpp | 12 +++--- src/Config/Config_Keywords.h | 2 +- src/Config/Config_WidgetAPI.cpp | 2 +- src/ModuleBase/CMakeLists.txt | 4 +- src/ModuleBase/ModuleBase_WidgetFactory.cpp | 6 +-- ...x.cpp => ModuleBase_WidgetOptionalBox.cpp} | 40 +++++++++---------- ...upBox.h => ModuleBase_WidgetOptionalBox.h} | 14 +++---- 8 files changed, 44 insertions(+), 44 deletions(-) rename src/ModuleBase/{ModuleBase_WidgetCheckGroupBox.cpp => ModuleBase_WidgetOptionalBox.cpp} (81%) rename src/ModuleBase/{ModuleBase_WidgetCheckGroupBox.h => ModuleBase_WidgetOptionalBox.h} (90%) diff --git a/src/Config/Config_Common.cpp b/src/Config/Config_Common.cpp index ac274ada8..6d89535e7 100644 --- a/src/Config/Config_Common.cpp +++ b/src/Config/Config_Common.cpp @@ -56,14 +56,14 @@ bool isAttributeNode(xmlNodePtr theNode) return false; // it's parent is "feature" or "source" or page ("case" or "box") if(!hasParent(theNode, NODE_FEATURE, NODE_SOURCE, - WDG_GROUP, WDG_CHECK_GROUP, + WDG_GROUP, WDG_OPTIONALBOX, WDG_TOOLBOX_BOX, WDG_SWITCH_CASE, NULL)) return false; //it should not be a "source" or a "validator" node bool isLogical = isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NODE_SELFILTER, NULL); bool isPagedContainer = isNode(theNode, WDG_TOOLBOX, WDG_TOOLBOX_BOX, - WDG_GROUP, WDG_CHECK_GROUP, + WDG_GROUP, WDG_OPTIONALBOX, WDG_SWITCH, WDG_SWITCH_CASE, NULL); return !isLogical && !isPagedContainer; } @@ -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, WDG_CHECK_GROUP, + if(!hasParent(theNode, NODE_FEATURE, NODE_SOURCE, WDG_GROUP, WDG_OPTIONALBOX, 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_CHECK_GROUP, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, NULL); + return isNode(theNode, WDG_OPTIONALBOX, 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 4797d9d4a..5fdd12f6a 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -73,7 +73,7 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) aMessage->setConcealment(getBooleanAttribute(theNode, ATTR_CONCEALMENT, false)); std::list > aCases; - xmlNodePtr aCaseNode = hasParentRecursive(theNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, WDG_CHECK_GROUP, NULL); + xmlNodePtr aCaseNode = hasParentRecursive(theNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, WDG_OPTIONALBOX, NULL); while(aCaseNode) { std::string aCaseNodeID = getProperty(aCaseNode, _ID); std::string aSwitchNodeID = ""; @@ -85,7 +85,7 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) else if (!xmlStrcmp(aName, (const xmlChar *) WDG_TOOLBOX_BOX)) { aSwitchNode = hasParentRecursive(aCaseNode, WDG_TOOLBOX, NULL); } - if (!xmlStrcmp(aName, (const xmlChar *) WDG_CHECK_GROUP)) { + if (!xmlStrcmp(aName, (const xmlChar *) WDG_OPTIONALBOX)) { /// the box is optional, attribute is in case if the optional attribute value is not empty aSwitchNode = aCaseNode; } @@ -93,13 +93,13 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) aSwitchNodeID = getProperty(aSwitchNode, _ID); aCases.push_back(std::make_pair(aSwitchNodeID, aCaseNodeID)); - aCaseNode = hasParentRecursive(aSwitchNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, WDG_CHECK_GROUP, NULL); + aCaseNode = hasParentRecursive(aSwitchNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, WDG_OPTIONALBOX, NULL); } aMessage->setCases(aCases); Events_Loop::loop()->send(aMessage); } // container pages, like "case" or "box" - } else if (isNode(theNode, WDG_CHECK_GROUP, WDG_SWITCH, WDG_SWITCH_CASE, + } else if (isNode(theNode, WDG_OPTIONALBOX, WDG_SWITCH, WDG_SWITCH_CASE, WDG_TOOLBOX, WDG_TOOLBOX_BOX, NULL)) { storeAttribute(theNode, _ID); // save case:caseId (or box:boxId) } @@ -110,7 +110,7 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) void Config_FeatureReader::cleanup(xmlNodePtr theNode) { - if (isNode(theNode, WDG_CHECK_GROUP, WDG_SWITCH, WDG_SWITCH_CASE, + if (isNode(theNode, WDG_OPTIONALBOX, WDG_SWITCH, WDG_SWITCH_CASE, WDG_TOOLBOX, WDG_TOOLBOX_BOX, NULL)) { // cleanup id of cases when leave case node cleanupAttribute(theNode, _ID); @@ -122,7 +122,7 @@ bool Config_FeatureReader::processChildren(xmlNodePtr theNode) bool result = isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL); if(!result && myIsProcessWidgets) { result = isNode(theNode, NODE_FEATURE, - WDG_GROUP, WDG_CHECK_GROUP, + WDG_GROUP, WDG_OPTIONALBOX, WDG_TOOLBOX, WDG_TOOLBOX_BOX, WDG_SWITCH, WDG_SWITCH_CASE, NULL); } diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index 0fc75262d..43227a571 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -41,7 +41,7 @@ const static char* WDG_ACTION = "action"; // Containers const static char* WDG_GROUP = "groupbox"; -const static char* WDG_CHECK_GROUP = "check_groupbox"; +const static char* WDG_OPTIONALBOX = "optionalbox"; const static char* WDG_TOOLBOX = "toolbox"; const static char* WDG_TOOLBOX_BOX = "box"; const static char* WDG_SWITCH = "switch"; diff --git a/src/Config/Config_WidgetAPI.cpp b/src/Config/Config_WidgetAPI.cpp index 2b74277a1..e8dcbf4be 100644 --- a/src/Config/Config_WidgetAPI.cpp +++ b/src/Config/Config_WidgetAPI.cpp @@ -81,7 +81,7 @@ std::string Config_WidgetAPI::widgetType() const bool Config_WidgetAPI::isGroupBoxWidget() const { - return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP, + return isNode(myCurrentNode, WDG_GROUP, WDG_OPTIONALBOX, NULL); } diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index c4fe31943..8dd3b5de7 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -42,7 +42,6 @@ SET(PROJECT_HEADERS ModuleBase_ViewerPrs.h ModuleBase_WidgetAction.h ModuleBase_WidgetBoolValue.h - ModuleBase_WidgetCheckGroupBox.h ModuleBase_WidgetChoice.h ModuleBase_WidgetCreatorFactory.h ModuleBase_WidgetDoubleValue.h @@ -54,6 +53,7 @@ SET(PROJECT_HEADERS ModuleBase_WidgetLabel.h ModuleBase_WidgetLineEdit.h ModuleBase_WidgetMultiSelector.h + ModuleBase_WidgetOptionalBox.h ModuleBase_WidgetSelector.h ModuleBase_WidgetSelectorStore.h ModuleBase_WidgetShapeSelector.h @@ -101,7 +101,6 @@ SET(PROJECT_SOURCES ModuleBase_ViewerPrs.cpp ModuleBase_WidgetAction.cpp ModuleBase_WidgetBoolValue.cpp - ModuleBase_WidgetCheckGroupBox.cpp ModuleBase_WidgetChoice.cpp ModuleBase_WidgetCreatorFactory.cpp ModuleBase_WidgetDoubleValue.cpp @@ -113,6 +112,7 @@ SET(PROJECT_SOURCES ModuleBase_WidgetLabel.cpp ModuleBase_WidgetLineEdit.cpp ModuleBase_WidgetMultiSelector.cpp + ModuleBase_WidgetOptionalBox.cpp ModuleBase_WidgetSelector.cpp ModuleBase_WidgetSelectorStore.cpp ModuleBase_WidgetShapeSelector.cpp diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 8016ab6ea..a33522dee 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -257,8 +257,8 @@ ModuleBase_PageBase* ModuleBase_WidgetFactory::createPageByType(const std::strin aPage->setTitle(aGroupName); aResult = aPage; } - else if (theType == WDG_CHECK_GROUP) { - ModuleBase_WidgetCheckGroupBox* aPage = new ModuleBase_WidgetCheckGroupBox(theParent, + else if (theType == WDG_OPTIONALBOX) { + ModuleBase_WidgetOptionalBox* aPage = new ModuleBase_WidgetOptionalBox(theParent, myWidgetApi); aResult = aPage; } diff --git a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp b/src/ModuleBase/ModuleBase_WidgetOptionalBox.cpp similarity index 81% rename from src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp rename to src/ModuleBase/ModuleBase_WidgetOptionalBox.cpp index 6ca136d04..b2e6ad5a4 100755 --- a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp +++ b/src/ModuleBase/ModuleBase_WidgetOptionalBox.cpp @@ -1,10 +1,10 @@ // Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> -// File: ModuleBase_WidgetCheckGroupBox.cpp +// File: ModuleBase_WidgetOptionalBox.cpp // Created: 13 Dec 2015 // Author: Natalia ERMOLAEVA -#include +#include #include #include @@ -18,7 +18,7 @@ #include -ModuleBase_WidgetCheckGroupBox::ModuleBase_WidgetCheckGroupBox(QWidget* theParent, +ModuleBase_WidgetOptionalBox::ModuleBase_WidgetOptionalBox(QWidget* theParent, const Config_WidgetAPI* theData) : ModuleBase_ModelWidget(theParent, theData), ModuleBase_PageBase(), @@ -40,16 +40,16 @@ ModuleBase_WidgetCheckGroupBox::ModuleBase_WidgetCheckGroupBox(QWidget* theParen ModuleBase_Tools::adjustMargins(myMainLayout); } -ModuleBase_WidgetCheckGroupBox::~ModuleBase_WidgetCheckGroupBox() +ModuleBase_WidgetOptionalBox::~ModuleBase_WidgetOptionalBox() { } -QWidget* ModuleBase_WidgetCheckGroupBox::pageWidget() +QWidget* ModuleBase_WidgetOptionalBox::pageWidget() { return myOptionType == GroupBox ? myGroupBox : (QWidget*)myCheckBoxFrame; } -QList ModuleBase_WidgetCheckGroupBox::getControls() const +QList ModuleBase_WidgetOptionalBox::getControls() const { QList aControls; if (myOptionType == GroupBox) @@ -60,7 +60,7 @@ QList ModuleBase_WidgetCheckGroupBox::getControls() const return aControls; } -void ModuleBase_WidgetCheckGroupBox::onPageClicked() +void ModuleBase_WidgetOptionalBox::onPageClicked() { storeValue(); updateControlsVisibility(); @@ -69,11 +69,11 @@ void ModuleBase_WidgetCheckGroupBox::onPageClicked() emit focusOutWidget(this); } -void ModuleBase_WidgetCheckGroupBox::addPageStretch() +void ModuleBase_WidgetOptionalBox::addPageStretch() { } -void ModuleBase_WidgetCheckGroupBox::placeModelWidget(ModuleBase_ModelWidget* theWidget) +void ModuleBase_WidgetOptionalBox::placeModelWidget(ModuleBase_ModelWidget* theWidget) { if(!isCheckBoxFilled() && myOptionType == CheckBox) { createControl(CheckBox); @@ -101,7 +101,7 @@ void ModuleBase_WidgetCheckGroupBox::placeModelWidget(ModuleBase_ModelWidget* th } } -void ModuleBase_WidgetCheckGroupBox::placeWidget(QWidget* theWidget) +void ModuleBase_WidgetOptionalBox::placeWidget(QWidget* theWidget) { createControl(GroupBox); setOptionType(GroupBox); @@ -121,12 +121,12 @@ void ModuleBase_WidgetCheckGroupBox::placeWidget(QWidget* theWidget) myGroupBoxLayout->setRowStretch(kRow, 0); } -QLayout* ModuleBase_WidgetCheckGroupBox::pageLayout() +QLayout* ModuleBase_WidgetOptionalBox::pageLayout() { return myOptionType == GroupBox ? myGroupBoxLayout : (QLayout*)myCheckBoxLayout; } -void ModuleBase_WidgetCheckGroupBox::createControl(const OptionType& theType) +void ModuleBase_WidgetOptionalBox::createControl(const OptionType& theType) { if (theType == GroupBox && !myGroupBox) { // group box: more than one model widget is inside @@ -159,7 +159,7 @@ void ModuleBase_WidgetCheckGroupBox::createControl(const OptionType& theType) } } -bool ModuleBase_WidgetCheckGroupBox::storeValueCustom() +bool ModuleBase_WidgetOptionalBox::storeValueCustom() { DataPtr aData = myFeature->data(); AttributeStringPtr aStringAttr = aData->string(attributeID()); @@ -170,7 +170,7 @@ bool ModuleBase_WidgetCheckGroupBox::storeValueCustom() return true; } -bool ModuleBase_WidgetCheckGroupBox::restoreValueCustom() +bool ModuleBase_WidgetOptionalBox::restoreValueCustom() { DataPtr aData = myFeature->data(); AttributeStringPtr aStringAttr = aData->string(attributeID()); @@ -179,8 +179,8 @@ bool ModuleBase_WidgetCheckGroupBox::restoreValueCustom() return true; } -void ModuleBase_WidgetCheckGroupBox::setOptionType( - const ModuleBase_WidgetCheckGroupBox::OptionType& theType) +void ModuleBase_WidgetOptionalBox::setOptionType( + const ModuleBase_WidgetOptionalBox::OptionType& theType) { myOptionType = theType; @@ -191,18 +191,18 @@ void ModuleBase_WidgetCheckGroupBox::setOptionType( myGroupBox->setVisible(isGroupBox); } -bool ModuleBase_WidgetCheckGroupBox::isCheckBoxFilled() const +bool ModuleBase_WidgetOptionalBox::isCheckBoxFilled() const { return myCheckBoxWidget != 0; } -bool ModuleBase_WidgetCheckGroupBox::getCurrentValue() const +bool ModuleBase_WidgetOptionalBox::getCurrentValue() const { bool isGroupBox = myOptionType == GroupBox; return isGroupBox ? myGroupBox->isChecked() : myCheckBox->isChecked(); } -void ModuleBase_WidgetCheckGroupBox::setCurrentValue(const bool& theValue) +void ModuleBase_WidgetOptionalBox::setCurrentValue(const bool& theValue) { bool isGroupBox = myOptionType == GroupBox; if (isGroupBox) { @@ -218,7 +218,7 @@ void ModuleBase_WidgetCheckGroupBox::setCurrentValue(const bool& theValue) updateControlsVisibility(); } -void ModuleBase_WidgetCheckGroupBox::updateControlsVisibility() +void ModuleBase_WidgetOptionalBox::updateControlsVisibility() { if (myOptionType == GroupBox) { bool aChecked = myGroupBox->isChecked(); diff --git a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h b/src/ModuleBase/ModuleBase_WidgetOptionalBox.h similarity index 90% rename from src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h rename to src/ModuleBase/ModuleBase_WidgetOptionalBox.h index 8db7491d7..63027a9e9 100755 --- a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h +++ b/src/ModuleBase/ModuleBase_WidgetOptionalBox.h @@ -1,11 +1,11 @@ // Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> -// File: ModuleBase_WidgetCheckGroupBox.h +// File: ModuleBase_WidgetOptionalBox.h // Created: 13 Dec 2015 // Author: Natalia ERMOLAEVA -#ifndef ModuleBase_WidgetCheckGroupBox_H_ -#define ModuleBase_WidgetCheckGroupBox_H_ +#ifndef ModuleBase_WidgetOptionalBox_H_ +#define ModuleBase_WidgetOptionalBox_H_ #include #include @@ -22,7 +22,7 @@ class QGridLayout; * \ingroup GUI * Implements a model widget for switch as a container widget. It can be defined in XML with "toolbox" keyword */ -class MODULEBASE_EXPORT ModuleBase_WidgetCheckGroupBox : public ModuleBase_ModelWidget, +class MODULEBASE_EXPORT ModuleBase_WidgetOptionalBox : public ModuleBase_ModelWidget, public ModuleBase_PageBase { Q_OBJECT @@ -32,8 +32,8 @@ public: /// Constructor /// \param theParent the parent object /// \param theData the widget configuration. The attribute of the model widget is obtained from - ModuleBase_WidgetCheckGroupBox(QWidget* theParent, const Config_WidgetAPI* theData); - virtual ~ModuleBase_WidgetCheckGroupBox(); + ModuleBase_WidgetOptionalBox(QWidget* theParent, const Config_WidgetAPI* theData); + virtual ~ModuleBase_WidgetOptionalBox(); /// Defines if it is supported to set the value in this widget /// \return false because this is an info widget @@ -115,4 +115,4 @@ private: QGridLayout* myGroupBoxLayout; ///< page's layout }; -#endif /* ModuleBase_WidgetCheckGroupBox_H_ */ +#endif /* ModuleBase_WidgetOptionalBox_H_ */ -- 2.39.2