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

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

gcs

File size: 1.5 KB
Line 
1#include "ComboBox.h"
2#include "Layout.h"
3#include <QComboBox>
4#include <QFormLayout>
5
6ComboBox::ComboBox(Layout* parent,int row, int col,QString name,int value): FormLayout(parent,row,col,name,"ComboBox")
7{
8 combobox = new QComboBox();
9 combobox->setCurrentIndex(value);
10
11 combobox_value=value;
12
13 object_layout->addRow(name,combobox);
14
15 connect(combobox,SIGNAL(currentIndexChanged(int)),this, SLOT(valuechanged(int)));
16
17 SetValue(QString::number(combobox_value));
18
19 //pour ne pas faire de doublons qd on ajoute des items
20 SetIsExpandable(true);
21}
22
23ComboBox::~ComboBox()
24{
25 delete combobox;
26}
27
28void ComboBox::XmlEvent(QDomElement dom)
29{
30 if(dom.attribute("item")!="") {
31 QString item=dom.attribute("item");
32 combobox->addItem(item);
33 combobox->setCurrentIndex(combobox_value);
34 }
35}
36
37void ComboBox::SetUptodate(void)
38{
39 ui_to_var();
40 ui_to_xml();
41 visible_widget->setPalette(black_pal);
42
43}
44
45void ComboBox::ui_to_var(void)
46{
47 combobox_value=combobox->currentIndex();
48}
49
50void ComboBox::ui_to_xml(void)
51{
52 SetValue(QString::number(combobox->currentIndex()));
53}
54
55void ComboBox::Reset(void)
56{
57 combobox->setCurrentIndex(combobox_value);
58}
59
60void ComboBox::LoadEvent(QDomElement dom)
61{
62 if(combobox->isEnabled()==true)
63 {
64 combobox->setCurrentIndex((dom.attribute("value")).toInt());
65 }
66}
67
68void ComboBox::valuechanged(int value)
69{
70 if(value!=combobox_value)
71 {
72 visible_widget->setPalette(red_pal);
73 }
74 else
75 {
76 visible_widget->setPalette(black_pal);
77 }
78}
Note: See TracBrowser for help on using the repository browser.