Mantid
Loading...
Searching...
No Matches
BoolPropertyWidget.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8
9using namespace Mantid::Kernel;
10
11namespace MantidQt::API {
12
13//----------------------------------------------------------------------------------------------
17 QGridLayout *layout, int row)
18 : PropertyWidget(prop, parent, layout, row) {
19 m_checkBox = new QCheckBox(QString::fromStdString(prop->name()), m_parent);
20 m_checkBox->setToolTip(m_doc);
21 // Make current value visible
22 this->setValue(QString::fromStdString(m_prop->value()));
23
24 // Make sure the connection comes after updating any values
25 connect(m_checkBox, SIGNAL(stateChanged(int)), this, SLOT(userEditedProperty()));
26 m_widgets.push_back(m_checkBox);
27
28 // Add the checkbox at column 1
29 m_gridLayout->addWidget(m_checkBox, m_row, 1);
30}
31
32//----------------------------------------------------------------------------------------------
36
37//----------------------------------------------------------------------------------------------
40 if (m_checkBox->isChecked())
41 return "1";
42 else
43 return "0";
44}
45
46//----------------------------------------------------------------------------------------------
51 const QString temp = value.isEmpty() ? QString::fromStdString(m_prop->getDefault()) : value;
52
53 if (temp == "0")
54 m_checkBox->setCheckState(Qt::Unchecked);
55 else
56 m_checkBox->setCheckState(Qt::Checked);
57}
58} // namespace MantidQt::API
double value
The value of the point.
Definition FitMW.cpp:51
void setValueImpl(const QString &value) override
Set the value into the GUI.
BoolPropertyWidget(Mantid::Kernel::PropertyWithValue< bool > *prop, QWidget *parent=nullptr, QGridLayout *layout=nullptr, int row=-1)
Constructor.
~BoolPropertyWidget() override
Destructor.
QCheckBox * m_checkBox
Checkbox widget.
Base class for widgets that will set Mantid::Kernel::Property* types.
void setValue(const QString &value)
Set the value of the property given into the GUI state.
QGridLayout * m_gridLayout
Grid layout of the dialog to which we are adding widgets.
QString m_doc
Documentation string (tooltip)
QVector< QWidget * > m_widgets
All contained widgets.
QWidget * m_parent
Parent widget to add sub-widgets to.
void userEditedProperty()
To be called when a user edits a property, as opposed to one being set programmatically.
int m_row
If using the GridLayout, this is the row where the widget was inserted.
Mantid::Kernel::Property * m_prop
Property being looked at. This is NOT owned by the widget.
The concrete, templated class for properties.
const std::string & name() const
Get the property's name.
Definition Property.cpp:61
virtual std::string getDefault() const =0
Get the default value for the property which is the value the property was initialised with.
virtual std::string value() const =0
Returns the value of the property as a string.