source: flair-src/trunk/tools/FlairGCS/src/SpinBox.cpp@ 88

Last change on this file since 88 was 15, checked in by Bayard Gildas, 8 years ago

sources reformatted with flair-format-dir script

File size: 1.4 KB
Line 
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}
5#include "SpinBox.h"
6#include <QFormLayout>
7#include "Layout.h"
8#include <QSpinBox>
9
10SpinBox::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();
14
15 spinbox->setRange(min, max);
16 spinbox->setSingleStep(step);
17 spinbox->setValue(value);
18 spinbox->setSuffix(suffix);
19 spinbox_value = value;
20
21 object_layout->addRow(name, spinbox);
22
23 connect(spinbox, SIGNAL(valueChanged(int)), this, SLOT(valuechanged(int)));
24
25 SetValue(QString::number(spinbox_value));
26}
27
28SpinBox::~SpinBox() { delete spinbox; }
29
30void SpinBox::SetUptodate(void) {
31 ui_to_var();
32 ui_to_xml();
33 visible_widget->setPalette(black_pal);
34}
35
36void SpinBox::ui_to_var(void) { spinbox_value = spinbox->value(); }
37
38void SpinBox::ui_to_xml(void) { SetValue(QString::number(spinbox->value())); }
39
40void SpinBox::Reset(void) { spinbox->setValue(spinbox_value); }
41
42void SpinBox::LoadEvent(QDomElement dom) {
43 if (spinbox->isEnabled() == true) {
44 spinbox->setValue((dom.attribute("value")).toInt());
45 }
46}
47
48void SpinBox::valuechanged(int value) {
49 if (value != spinbox_value) {
50 visible_widget->setPalette(red_pal);
51 } else {
52 visible_widget->setPalette(black_pal);
53 }
54}
Note: See TracBrowser for help on using the repository browser.