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