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

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

flairgcs:
speed up processing time when receiving datas from uav
triger watchdog while receiving datas from uav
(avoids connection lost in uav)

File size: 1.5 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)
11 : FormLayout(parent, row, col, name, "CheckBox") {
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 SetValue("1");
23 } else {
24 SetValue("0");
25 }
26}
27
28CheckBox::~CheckBox() { delete checkbox; }
29
30void CheckBox::SetUptodate(void) {
31 ui_to_var();
32 ui_to_xml();
33 visible_widget->setPalette(black_pal);
34}
35
36void CheckBox::ui_to_var(void) { checkbox_value = checkbox->isChecked(); }
37
38void CheckBox::ui_to_xml(void) {
39 if (checkbox->isChecked() == true) {
40 SetValue("1");
41 } else {
42 SetValue("0");
43 }
44}
45
46void CheckBox::Reset(void) { checkbox->setChecked(checkbox_value); }
47
48void CheckBox::LoadEvent(QDomElement *dom) {
49 if (checkbox->isEnabled() == true) {
50 if (dom->attribute("value") == QString("1")) {
51 checkbox->setChecked(true);
52 } else {
53 checkbox->setChecked(false);
54 }
55 }
56}
57
58void CheckBox::valuechanged(bool value) {
59 if (value != checkbox_value) {
60 visible_widget->setPalette(red_pal);
61 } else {
62 visible_widget->setPalette(black_pal);
63 }
64}
Note: See TracBrowser for help on using the repository browser.