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

Last change on this file was 269, checked in by Sanahuja Guillaume, 3 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
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 "CheckBox.h"
6#include "Layout.h"
7#include <QCheckBox>
8#include <QFormLayout>
9
[15]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);
[9]14
[15]15  checkbox_value = value;
[9]16
[15]17  object_layout->addRow(name, checkbox);
[9]18
[15]19  connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(valuechanged(bool)));
[9]20
[15]21  if (checkbox_value == true) {
22    SetValue("1");
23  } else {
24    SetValue("0");
25  }
[9]26}
27
[15]28CheckBox::~CheckBox() { delete checkbox; }
[9]29
[15]30void CheckBox::SetUptodate(void) {
31  ui_to_var();
32  ui_to_xml();
33  visible_widget->setPalette(black_pal);
[9]34}
35
[15]36void CheckBox::ui_to_var(void) { checkbox_value = checkbox->isChecked(); }
[9]37
[15]38void CheckBox::ui_to_xml(void) {
39  if (checkbox->isChecked() == true) {
40    SetValue("1");
41  } else {
42    SetValue("0");
43  }
[9]44}
45
[15]46void CheckBox::Reset(void) { checkbox->setChecked(checkbox_value); }
[9]47
[269]48void CheckBox::LoadEvent(QDomElement *dom) {
[15]49  if (checkbox->isEnabled() == true) {
[269]50    if (dom->attribute("value") == QString("1")) {
[15]51      checkbox->setChecked(true);
52    } else {
53      checkbox->setChecked(false);
[9]54    }
[15]55  }
[9]56}
57
[15]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  }
[9]64}
Note: See TracBrowser for help on using the repository browser.