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