1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_WidgetBoolValue.cpp
4 // Created: 04 June 2014
5 // Author: Vitaly Smetannikov
7 #include <ModuleBase_WidgetBoolValue.h>
8 #include <ModuleBase_Tools.h>
10 #include <ModelAPI_AttributeBoolean.h>
11 #include <ModelAPI_Data.h>
13 #include <Config_Keywords.h>
14 #include <Config_WidgetAPI.h>
16 #include <Events_Loop.h>
17 #include <ModelAPI_Events.h>
23 ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent,
24 const Config_WidgetAPI* theData)
25 : ModuleBase_ModelWidget(theParent, theData)
27 QString aText = translate(theData->widgetLabel());
28 QString aToolTip = translate(theData->widgetTooltip());
29 bool isChecked = theData->getBooleanAttribute(ATTR_DEFAULT, false);
31 myCheckBox = new QCheckBox(aText, this);
32 myCheckBox->setToolTip(aToolTip);
33 myCheckBox->setChecked(isChecked);
35 QVBoxLayout* aMainLayout = new QVBoxLayout(this);
36 ModuleBase_Tools::adjustMargins(aMainLayout);
37 aMainLayout->addWidget(myCheckBox);
38 setLayout(aMainLayout);
40 connect(myCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(valuesChanged()));
43 ModuleBase_WidgetBoolValue::~ModuleBase_WidgetBoolValue()
47 bool ModuleBase_WidgetBoolValue::storeValueCustom()
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::restoreValueCustom()
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);
75 void ModuleBase_WidgetBoolValue::setHighlighted(bool)