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

Last change on this file since 10 was 10, checked in by Sanahuja Guillaume, 6 years ago

lic

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