1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: ModuleBase_WidgetCheckGroupBox.cpp
4 // Created: 13 Dec 2015
5 // Author: Natalia ERMOLAEVA
7 #include <ModuleBase_WidgetCheckGroupBox.h>
8 #include <ModelAPI_AttributeBoolean.h>
10 #include <Config_WidgetAPI.h>
11 #include <Config_Keywords.h>
15 #include <QGridLayout>
16 #include <QVBoxLayout>
20 ModuleBase_WidgetCheckGroupBox::ModuleBase_WidgetCheckGroupBox(QWidget* theParent,
21 const Config_WidgetAPI* theData)
22 : ModuleBase_ModelWidget(theParent, theData),
25 QString aToolTip = QString::fromStdString(theData->widgetTooltip());
26 bool isChecked = theData->getBooleanAttribute(ATTR_DEFAULT, false);
28 QVBoxLayout* aMainLayout = new QVBoxLayout(this);
29 ModuleBase_Tools::zeroMargins(aMainLayout);
30 myGroupBox = new QGroupBox(this);
31 myGroupBox->setCheckable(true);
32 myGroupBox->setToolTip(aToolTip);
33 myGroupBox->setChecked(isChecked);
35 myMainLayout = new QGridLayout(myGroupBox);
36 ModuleBase_Tools::adjustMargins(myMainLayout);
37 myGroupBox->setLayout(myMainLayout);
39 // default vertical size policy is preferred
40 aMainLayout->addWidget(myGroupBox);
41 connect(myGroupBox, SIGNAL(clicked(bool)), this, SLOT(onPageClicked()));
44 ModuleBase_WidgetCheckGroupBox::~ModuleBase_WidgetCheckGroupBox()
48 void ModuleBase_WidgetCheckGroupBox::setTitle(const QString& theTitle)
50 myGroupBox->setTitle(theTitle);
53 QWidget* ModuleBase_WidgetCheckGroupBox::pageWidget()
58 QList<QWidget*> ModuleBase_WidgetCheckGroupBox::getControls() const
60 QList<QWidget*> aControls;
61 aControls.append(myGroupBox);
66 void ModuleBase_WidgetCheckGroupBox::onPageClicked()
71 void ModuleBase_WidgetCheckGroupBox::addPageStretch()
75 void ModuleBase_WidgetCheckGroupBox::placeModelWidget(ModuleBase_ModelWidget* theWidget)
78 const int kRow = myMainLayout->count();
79 // it seems, that the align on left is not necessary here, but leads to widgets, which are
80 // not extended on full width of the parent page. The case is grouped widgets in
81 // the sketch translation operation
82 myMainLayout->addWidget(theWidget, kRow, kCol, Qt::AlignTop);// | Qt::AlignLeft);
83 myMainLayout->setRowStretch(kRow, 0);
87 void ModuleBase_WidgetCheckGroupBox::placeWidget(QWidget* theWidget)
91 std::cout << "ModuleBase_PageGroupBox::placePageWidget: can not cast page" << std::endl;
96 const int kRow = myMainLayout->count();
97 myMainLayout->addWidget(theWidget, kRow, kCol);
98 myMainLayout->setRowStretch(kRow, 0);
101 QLayout* ModuleBase_WidgetCheckGroupBox::pageLayout()
106 bool ModuleBase_WidgetCheckGroupBox::storeValueCustom() const
108 DataPtr aData = myFeature->data();
109 std::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
110 aBool->setValue(myGroupBox->isChecked());
111 updateObject(myFeature);
116 bool ModuleBase_WidgetCheckGroupBox::restoreValueCustom()
118 DataPtr aData = myFeature->data();
119 std::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(attributeID());
121 bool isBlocked = myGroupBox->blockSignals(true);
122 myGroupBox->setChecked(aRef->value());
123 myGroupBox->blockSignals(isBlocked);