Salome HOME
Update SketchPlugin_Projection feature (issue #1459)
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetBoolValue.cpp
index 4e0ceee4c1dfb7e405798432d9882c7b3b5ebcd3..b0ff0d2a10343f2a15d929598b7824557acb5f62 100644 (file)
@@ -1,8 +1,11 @@
-// File:        ModuleBase_Widgets.h
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_WidgetBoolValue.cpp
 // Created:     04 June 2014
 // Author:      Vitaly Smetannikov
 
 #include <ModuleBase_WidgetBoolValue.h>
+#include <ModuleBase_Tools.h>
 
 #include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_Data.h>
 #include <QCheckBox>
 
 ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent,
-                                                       const Config_WidgetAPI* theData,
-                                                       const std::string& theParentId)
-    : ModuleBase_ModelWidget(theParent, theData, theParentId)
+                                                       const Config_WidgetAPI* theData)
+: ModuleBase_ModelWidget(theParent, theData)
 {
   QString aText = QString::fromStdString(theData->widgetLabel());
   QString aToolTip = QString::fromStdString(theData->widgetTooltip());
-  bool isChecked = theData->getBooleanAttribute(ANY_WDG_DEFAULT, false);
+  bool isChecked = theData->getBooleanAttribute(ATTR_DEFAULT, false);
 
-  myCheckBox = new QCheckBox(aText, theParent);
+  myCheckBox = new QCheckBox(aText, this);
   myCheckBox->setToolTip(aToolTip);
   myCheckBox->setChecked(isChecked);
 
+  QVBoxLayout* aMainLayout = new QVBoxLayout(this);
+  ModuleBase_Tools::adjustMargins(aMainLayout);
+  aMainLayout->addWidget(myCheckBox);
+  setLayout(aMainLayout);
+
   connect(myCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(valuesChanged()));
 }
 
@@ -37,12 +44,7 @@ ModuleBase_WidgetBoolValue::~ModuleBase_WidgetBoolValue()
 {
 }
 
-QWidget* ModuleBase_WidgetBoolValue::getControl() const
-{
-  return myCheckBox;
-}
-
-bool ModuleBase_WidgetBoolValue::storeValue() const
+bool ModuleBase_WidgetBoolValue::storeValueCustom()
 {
   DataPtr aData = myFeature->data();
   std::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
@@ -51,7 +53,7 @@ bool ModuleBase_WidgetBoolValue::storeValue() const
   return true;
 }
 
-bool ModuleBase_WidgetBoolValue::restoreValue()
+bool ModuleBase_WidgetBoolValue::restoreValueCustom()
 {
   DataPtr aData = myFeature->data();
   std::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(attributeID());
@@ -69,3 +71,8 @@ QList<QWidget*> ModuleBase_WidgetBoolValue::getControls() const
   aList.append(myCheckBox);
   return aList;
 }
+
+void ModuleBase_WidgetBoolValue::setHighlighted(bool)
+{
+  return;
+}