2012-02-12 17:26:17 +00:00
|
|
|
#include "inputboolean.h"
|
|
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
#include "math.h"
|
|
|
|
|
|
|
|
InputBoolean::InputBoolean(QWidget* form, QString label, int* value) : BaseInput(form, label)
|
|
|
|
{
|
|
|
|
this->value = value;
|
|
|
|
|
|
|
|
checkbox = new QCheckBox(form);
|
|
|
|
|
|
|
|
connect(checkbox, SIGNAL(stateChanged(int)), this, SLOT(applyValue()));
|
|
|
|
|
|
|
|
_preview = new QLabel(form);
|
|
|
|
_control = checkbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InputBoolean::updatePreview()
|
|
|
|
{
|
|
|
|
if (checkbox->checkState() == Qt::Checked)
|
|
|
|
{
|
2012-02-28 13:45:11 +00:00
|
|
|
((QLabel*)_preview)->setText(tr("Yes"));
|
2012-02-12 17:26:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-28 13:45:11 +00:00
|
|
|
((QLabel*)_preview)->setText(tr("No"));
|
2012-02-12 17:26:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BaseInput::updatePreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InputBoolean::applyValue()
|
|
|
|
{
|
|
|
|
if (checkbox->checkState() == Qt::Checked)
|
|
|
|
{
|
|
|
|
*value = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*value = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BaseInput::applyValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InputBoolean::revert()
|
|
|
|
{
|
|
|
|
if (*value)
|
|
|
|
{
|
|
|
|
checkbox->setCheckState(Qt::Checked);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
checkbox->setCheckState(Qt::Unchecked);
|
|
|
|
}
|
|
|
|
|
|
|
|
BaseInput::revert();
|
|
|
|
}
|