source: flair-src/trunk/tools/FlairGCS/src/CheckBox.cpp@ 9

Last change on this file since 9 was 9, checked in by Sanahuja Guillaume, 7 years ago

gcs

File size: 1.4 KB
Line 
1#include "CheckBox.h"
2#include "Layout.h"
3#include <QCheckBox>
4#include <QFormLayout>
5
6CheckBox::CheckBox(Layout* parent,int row, int col,QString name,bool value): FormLayout(parent,row,col,name,"CheckBox")
7{
8 checkbox = new QCheckBox();
9 checkbox->setChecked(value);
10
11 checkbox_value=value;
12
13 object_layout->addRow(name,checkbox);
14
15 connect(checkbox,SIGNAL(toggled(bool)),this, SLOT(valuechanged(bool)));
16
17 if(checkbox_value==true)
18 {
19 SetValue("1");
20 }
21 else
22 {
23 SetValue("0");
24 }
25}
26
27CheckBox::~CheckBox()
28{
29 delete checkbox;
30}
31
32void CheckBox::SetUptodate(void)
33{
34 ui_to_var();
35 ui_to_xml();
36 visible_widget->setPalette(black_pal);
37}
38
39void CheckBox::ui_to_var(void)
40{
41 checkbox_value=checkbox->isChecked();
42}
43
44void CheckBox::ui_to_xml(void)
45{
46 if(checkbox->isChecked()==true)
47 {
48 SetValue("1");
49 }
50 else
51 {
52 SetValue("0");
53 }
54}
55
56void CheckBox::Reset(void)
57{
58 checkbox->setChecked(checkbox_value);
59}
60
61void CheckBox::LoadEvent(QDomElement dom)
62{
63 if(checkbox->isEnabled()==true)
64 {
65 if(dom.attribute("value")==QString("1"))
66 {
67 checkbox->setChecked(true);
68 }
69 else
70 {
71 checkbox->setChecked(false);
72 }
73 }
74}
75
76void CheckBox::valuechanged(bool value)
77{
78 if(value!=checkbox_value)
79 {
80 visible_widget->setPalette(red_pal);
81 }
82 else
83 {
84 visible_widget->setPalette(black_pal);
85 }
86}
Note: See TracBrowser for help on using the repository browser.