[10] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[10] | 4 | // %flair:license}
|
---|
[9] | 5 | #include "SpinBox.h"
|
---|
| 6 | #include <QFormLayout>
|
---|
| 7 | #include "Layout.h"
|
---|
| 8 | #include <QSpinBox>
|
---|
| 9 |
|
---|
[15] | 10 | SpinBox::SpinBox(Layout *parent, int row, int col, QString name, QString suffix,
|
---|
| 11 | int value, int min, int max, int step)
|
---|
| 12 | : FormLayout(parent, row, col, name, "SpinBox") {
|
---|
| 13 | spinbox = new QSpinBox();
|
---|
[9] | 14 |
|
---|
[15] | 15 | spinbox->setRange(min, max);
|
---|
| 16 | spinbox->setSingleStep(step);
|
---|
| 17 | spinbox->setValue(value);
|
---|
| 18 | spinbox->setSuffix(suffix);
|
---|
| 19 | spinbox_value = value;
|
---|
[9] | 20 |
|
---|
[15] | 21 | object_layout->addRow(name, spinbox);
|
---|
[9] | 22 |
|
---|
[15] | 23 | connect(spinbox, SIGNAL(valueChanged(int)), this, SLOT(valuechanged(int)));
|
---|
[9] | 24 |
|
---|
[15] | 25 | SetValue(QString::number(spinbox_value));
|
---|
[9] | 26 | }
|
---|
| 27 |
|
---|
[15] | 28 | SpinBox::~SpinBox() { delete spinbox; }
|
---|
[9] | 29 |
|
---|
[15] | 30 | void SpinBox::SetUptodate(void) {
|
---|
| 31 | ui_to_var();
|
---|
| 32 | ui_to_xml();
|
---|
| 33 | visible_widget->setPalette(black_pal);
|
---|
[9] | 34 | }
|
---|
| 35 |
|
---|
[15] | 36 | void SpinBox::ui_to_var(void) { spinbox_value = spinbox->value(); }
|
---|
[9] | 37 |
|
---|
[15] | 38 | void SpinBox::ui_to_xml(void) { SetValue(QString::number(spinbox->value())); }
|
---|
[9] | 39 |
|
---|
[15] | 40 | void SpinBox::Reset(void) { spinbox->setValue(spinbox_value); }
|
---|
[9] | 41 |
|
---|
[15] | 42 | void SpinBox::LoadEvent(QDomElement dom) {
|
---|
| 43 | if (spinbox->isEnabled() == true) {
|
---|
| 44 | spinbox->setValue((dom.attribute("value")).toInt());
|
---|
| 45 | }
|
---|
[9] | 46 | }
|
---|
| 47 |
|
---|
[15] | 48 | void SpinBox::valuechanged(int value) {
|
---|
| 49 | if (value != spinbox_value) {
|
---|
| 50 | visible_widget->setPalette(red_pal);
|
---|
| 51 | } else {
|
---|
| 52 | visible_widget->setPalette(black_pal);
|
---|
| 53 | }
|
---|
[9] | 54 | }
|
---|