#include <QLayout>
#include <QCheckBox>
-ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent,
- const Config_WidgetAPI* theData,
- const std::string& theParentId)
- : ModuleBase_ModelWidget(theParent, theData, theParentId)
+ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+ : ModuleBase_ModelWidget(theParent, theData, theParentId)
{
QString aText = QString::fromStdString(theData->widgetLabel());
QString aToolTip = QString::fromStdString(theData->widgetTooltip());
- QString aDefault = QString::fromStdString(theData->getProperty("default"));
+ bool isChecked = theData->getBooleanAttribute(ANY_WDG_DEFAULT, false);
myCheckBox = new QCheckBox(aText, theParent);
myCheckBox->setToolTip(aToolTip);
- myCheckBox->setChecked(aDefault == "true");
+ myCheckBox->setChecked(isChecked);
connect(myCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(valuesChanged()));
}
{
}
-QWidget* ModuleBase_WidgetBoolValue::getControl() const
-{
- return myCheckBox;
+QWidget* ModuleBase_WidgetBoolValue::getControl() const
+{
+ return myCheckBox;
}
-bool ModuleBase_WidgetBoolValue::storeValue(ObjectPtr theObject) const
+bool ModuleBase_WidgetBoolValue::storeValue() const
{
- DataPtr aData = theObject->data();
+ DataPtr aData = myFeature->data();
boost::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
-
- if (aBool->value() != myCheckBox->isChecked()) {
- aBool->setValue(myCheckBox->isChecked());
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- }
+ aBool->setValue(myCheckBox->isChecked());
+ updateObject(myFeature);
return true;
}
-bool ModuleBase_WidgetBoolValue::restoreValue(ObjectPtr theObject)
+bool ModuleBase_WidgetBoolValue::restoreValue()
{
- DataPtr aData = theObject->data();
+ DataPtr aData = myFeature->data();
boost::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(attributeID());
bool isBlocked = myCheckBox->blockSignals(true);