1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_Widgets.h
4 // Created: 04 June 2014
5 // Author: Vitaly Smetannikov
7 #include <ModuleBase_WidgetBoolValue.h>
9 #include <ModelAPI_AttributeBoolean.h>
10 #include <ModelAPI_Data.h>
12 #include <Config_Keywords.h>
13 #include <Config_WidgetAPI.h>
15 #include <Events_Loop.h>
16 #include <ModelAPI_Events.h>
22 ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent,
23 const Config_WidgetAPI* theData,
24 const std::string& theParentId)
25 : ModuleBase_ModelWidget(theParent, theData, theParentId)
27 QString aText = QString::fromStdString(theData->widgetLabel());
28 QString aToolTip = QString::fromStdString(theData->widgetTooltip());
29 bool isChecked = theData->getBooleanAttribute(ATTR_DEFAULT, false);
31 myCheckBox = new QCheckBox(aText, theParent);
32 myCheckBox->setToolTip(aToolTip);
33 myCheckBox->setChecked(isChecked);
35 connect(myCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(valuesChanged()));
38 ModuleBase_WidgetBoolValue::~ModuleBase_WidgetBoolValue()
42 QWidget* ModuleBase_WidgetBoolValue::getControl() const
47 bool ModuleBase_WidgetBoolValue::storeValue() const
49 DataPtr aData = myFeature->data();
50 std::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
51 aBool->setValue(myCheckBox->isChecked());
52 updateObject(myFeature);
56 bool ModuleBase_WidgetBoolValue::restoreValue()
58 DataPtr aData = myFeature->data();
59 std::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(attributeID());
61 bool isBlocked = myCheckBox->blockSignals(true);
62 myCheckBox->setChecked(aRef->value());
63 myCheckBox->blockSignals(isBlocked);
68 QList<QWidget*> ModuleBase_WidgetBoolValue::getControls() const
70 QList<QWidget*> aList;
71 aList.append(myCheckBox);