1 // File: ModuleBase_Widgets.h
2 // Created: 04 June 2014
3 // Author: Vitaly Smetannikov
5 #include <ModuleBase_WidgetBoolValue.h>
7 #include <ModelAPI_AttributeBoolean.h>
8 #include <ModelAPI_Data.h>
10 #include <Config_Keywords.h>
11 #include <Config_WidgetAPI.h>
13 #include <Events_Loop.h>
14 #include <ModelAPI_Events.h>
20 ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent,
21 const Config_WidgetAPI* theData,
22 const std::string& theParentId)
23 : ModuleBase_ModelWidget(theParent, theData, theParentId)
25 QString aText = QString::fromStdString(theData->widgetLabel());
26 QString aToolTip = QString::fromStdString(theData->widgetTooltip());
27 bool isChecked = theData->getBooleanAttribute(ANY_WDG_DEFAULT, false);
29 myCheckBox = new QCheckBox(aText, theParent);
30 myCheckBox->setToolTip(aToolTip);
31 myCheckBox->setChecked(isChecked);
33 connect(myCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(valuesChanged()));
36 ModuleBase_WidgetBoolValue::~ModuleBase_WidgetBoolValue()
40 QWidget* ModuleBase_WidgetBoolValue::getControl() const
45 bool ModuleBase_WidgetBoolValue::storeValue() const
47 DataPtr aData = myFeature->data();
48 std::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
49 aBool->setValue(myCheckBox->isChecked());
50 updateObject(myFeature);
54 bool ModuleBase_WidgetBoolValue::restoreValue()
56 DataPtr aData = myFeature->data();
57 std::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(attributeID());
59 bool isBlocked = myCheckBox->blockSignals(true);
60 myCheckBox->setChecked(aRef->value());
61 myCheckBox->blockSignals(isBlocked);
66 QList<QWidget*> ModuleBase_WidgetBoolValue::getControls() const
68 QList<QWidget*> aList;
69 aList.append(myCheckBox);