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

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

sources reformatted with flair-format-dir script

File size: 1.4 KB
RevLine 
[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]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();
[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]28SpinBox::~SpinBox() { delete spinbox; }
[9]29
[15]30void SpinBox::SetUptodate(void) {
31 ui_to_var();
32 ui_to_xml();
33 visible_widget->setPalette(black_pal);
[9]34}
35
[15]36void SpinBox::ui_to_var(void) { spinbox_value = spinbox->value(); }
[9]37
[15]38void SpinBox::ui_to_xml(void) { SetValue(QString::number(spinbox->value())); }
[9]39
[15]40void SpinBox::Reset(void) { spinbox->setValue(spinbox_value); }
[9]41
[15]42void SpinBox::LoadEvent(QDomElement dom) {
43 if (spinbox->isEnabled() == true) {
44 spinbox->setValue((dom.attribute("value")).toInt());
45 }
[9]46}
47
[15]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 }
[9]54}
Note: See TracBrowser for help on using the repository browser.