source: flair-src/branches/sanscv/tools/FlairGCS/src/ComboBox.cpp@ 383

Last change on this file since 383 was 324, checked in by Sanahuja Guillaume, 5 years ago

removing opencv dependency

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 "ComboBox.h"
6#include "Layout.h"
7#include <QComboBox>
8#include <QFormLayout>
9
10ComboBox::ComboBox(Layout *parent, int row, int col, QString name, int value)
11 : FormLayout(parent, row, col, name, "ComboBox") {
12 combobox = new QComboBox();
13 combobox->setCurrentIndex(value);
14
15 combobox_value = value;
16
17 object_layout->addRow(name, combobox);
18
19 connect(combobox, SIGNAL(currentIndexChanged(int)), this,
20 SLOT(valuechanged(int)));
21
22 SetValue(QString::number(combobox_value));
23
24 // pour ne pas faire de doublons qd on ajoute des items
25 SetIsExpandable(true);
26}
27
28ComboBox::~ComboBox() { delete combobox; }
29
30void ComboBox::XmlEvent(QDomElement *dom) {
31 if (dom->attribute("item") != "") {
32 QString item = dom->attribute("item");
33 combobox->addItem(item);
34 combobox->setCurrentIndex(combobox_value);
35 }
36}
37
38void ComboBox::SetUptodate(void) {
39 ui_to_var();
40 ui_to_xml();
41 visible_widget->setPalette(black_pal);
42}
43
44void ComboBox::ui_to_var(void) { combobox_value = combobox->currentIndex(); }
45
46void ComboBox::ui_to_xml(void) {
47 SetValue(QString::number(combobox->currentIndex()));
48}
49
50void ComboBox::Reset(void) { combobox->setCurrentIndex(combobox_value); }
51
52void ComboBox::LoadEvent(QDomElement *dom) {
53 if (combobox->isEnabled() == true) {
54 combobox->setCurrentIndex((dom->attribute("value")).toInt());
55 }
56}
57
58void ComboBox::valuechanged(int value) {
59 if (value != combobox_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.