X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetBoolValue.cpp;h=a019404f5dbf0d5346392a3cc716f229540cf342;hb=c8e35a67c60489a46aaf7c8ff75001511ac2635b;hp=2c5faadd25fdb9053aef8afb7bb9a9ca0d8213b2;hpb=5d3cd989dcae90a9981d0d874e6fd75676db03d8;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp index 2c5faadd2..a019404f5 100644 --- a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp @@ -1,8 +1,11 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: ModuleBase_Widgets.h // Created: 04 June 2014 // Author: Vitaly Smetannikov #include +#include #include #include @@ -17,16 +20,23 @@ #include #include -ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent, const Config_WidgetAPI* theData) - : ModuleBase_ModelWidget(theParent, theData) +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(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())); } @@ -35,27 +45,19 @@ ModuleBase_WidgetBoolValue::~ModuleBase_WidgetBoolValue() { } -QWidget* ModuleBase_WidgetBoolValue::getControl() const -{ - return myCheckBox; -} - -bool ModuleBase_WidgetBoolValue::storeValue(ObjectPtr theObject) const +bool ModuleBase_WidgetBoolValue::storeValueCustom() const { - DataPtr aData = theObject->data(); - boost::shared_ptr aBool = aData->boolean(attributeID()); - - if (aBool->value() != myCheckBox->isChecked()) { - aBool->setValue(myCheckBox->isChecked()); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); - } + DataPtr aData = myFeature->data(); + std::shared_ptr aBool = aData->boolean(attributeID()); + aBool->setValue(myCheckBox->isChecked()); + updateObject(myFeature); return true; } -bool ModuleBase_WidgetBoolValue::restoreValue(ObjectPtr theObject) +bool ModuleBase_WidgetBoolValue::restoreValue() { - DataPtr aData = theObject->data(); - boost::shared_ptr aRef = aData->boolean(attributeID()); + DataPtr aData = myFeature->data(); + std::shared_ptr aRef = aData->boolean(attributeID()); bool isBlocked = myCheckBox->blockSignals(true); myCheckBox->setChecked(aRef->value()); @@ -70,3 +72,8 @@ QList ModuleBase_WidgetBoolValue::getControls() const aList.append(myCheckBox); return aList; } + +void ModuleBase_WidgetBoolValue::setHighlighted(bool) +{ + return; +}