1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include <ModuleBase_WidgetBoolValue.h>
22 #include <ModuleBase_Tools.h>
24 #include <ModelAPI_AttributeBoolean.h>
25 #include <ModelAPI_Data.h>
27 #include <Config_Keywords.h>
28 #include <Config_WidgetAPI.h>
30 #include <Events_Loop.h>
31 #include <ModelAPI_Events.h>
37 ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent,
38 const Config_WidgetAPI* theData)
39 : ModuleBase_ModelWidget(theParent, theData)
41 QString aText = translate(theData->widgetLabel());
42 QString aToolTip = translate(theData->widgetTooltip());
43 bool isChecked = theData->getBooleanAttribute(ATTR_DEFAULT, false);
45 myCheckBox = new QCheckBox(aText, this);
46 myCheckBox->setToolTip(aToolTip);
47 myCheckBox->setChecked(isChecked);
49 QVBoxLayout* aMainLayout = new QVBoxLayout(this);
50 ModuleBase_Tools::adjustMargins(aMainLayout);
51 aMainLayout->addWidget(myCheckBox);
52 setLayout(aMainLayout);
54 connect(myCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(valuesChanged()));
57 ModuleBase_WidgetBoolValue::~ModuleBase_WidgetBoolValue()
61 bool ModuleBase_WidgetBoolValue::storeValueCustom()
63 DataPtr aData = myFeature->data();
64 std::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
65 aBool->setValue(myCheckBox->isChecked());
66 updateObject(myFeature);
70 bool ModuleBase_WidgetBoolValue::restoreValueCustom()
72 DataPtr aData = myFeature->data();
73 std::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(attributeID());
75 bool isBlocked = myCheckBox->blockSignals(true);
76 myCheckBox->setChecked(aRef->value());
77 myCheckBox->blockSignals(isBlocked);
82 QList<QWidget*> ModuleBase_WidgetBoolValue::getControls() const
84 QList<QWidget*> aList;
85 aList.append(myCheckBox);
89 void ModuleBase_WidgetBoolValue::setHighlighted(bool)