X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetBoolValue.cpp;h=7d5e2855b374980f097d019acf159c0869bb8121;hb=4637d06f671c4748c8af8318bb50065c6f66860e;hp=d55bd18e05620013e0f3c6abd7c8b3df079ef6c2;hpb=759a12660edd93a3c402e36c67409d391ca04ad2;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp index d55bd18e0..7d5e2855b 100644 --- a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp @@ -1,10 +1,12 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: ModuleBase_Widgets.h // Created: 04 June 2014 // Author: Vitaly Smetannikov #include +#include -#include #include #include @@ -12,25 +14,29 @@ #include #include -#include +#include #include #include -#include -#include #include -ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent, const Config_WidgetAPI* theData) - : ModuleBase_ModelWidget(theParent) +ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent, + const Config_WidgetAPI* theData, + const std::string& theParentId) + : ModuleBase_ModelWidget(theParent, theData, theParentId) { - myAttributeID = theData->widgetId(); QString aText = QString::fromStdString(theData->widgetLabel()); QString aToolTip = QString::fromStdString(theData->widgetTooltip()); - QString aDefault = QString::fromStdString(theData->getProperty("default")); + bool isChecked = theData->getBooleanAttribute(ATTR_DEFAULT, false); - myCheckBox = new QCheckBox(aText, theParent); + myCheckBox = new QCheckBox(aText, this); myCheckBox->setToolTip(aToolTip); - myCheckBox->setChecked(aDefault == "true"); + 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())); } @@ -39,27 +45,19 @@ ModuleBase_WidgetBoolValue::~ModuleBase_WidgetBoolValue() { } -QWidget* ModuleBase_WidgetBoolValue::getControl() const -{ - return myCheckBox; -} - -bool ModuleBase_WidgetBoolValue::storeValue(FeaturePtr theFeature) const +bool ModuleBase_WidgetBoolValue::storeValueCustom() const { - DataPtr aData = theFeature->data(); - boost::shared_ptr aBool = aData->boolean(myAttributeID); - - if (aBool->value() != myCheckBox->isChecked()) { - aBool->setValue(myCheckBox->isChecked()); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); - } + DataPtr aData = myFeature->data(); + std::shared_ptr aBool = aData->boolean(attributeID()); + aBool->setValue(myCheckBox->isChecked()); + updateObject(myFeature); return true; } -bool ModuleBase_WidgetBoolValue::restoreValue(FeaturePtr theFeature) +bool ModuleBase_WidgetBoolValue::restoreValue() { - DataPtr aData = theFeature->data(); - boost::shared_ptr aRef = aData->boolean(myAttributeID); + DataPtr aData = myFeature->data(); + std::shared_ptr aRef = aData->boolean(attributeID()); bool isBlocked = myCheckBox->blockSignals(true); myCheckBox->setChecked(aRef->value());