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 |
|
---|
10 | ComboBox::ComboBox(Layout* parent,int row, int col,QString name,int value): FormLayout(parent,row,col,name,"ComboBox")
|
---|
11 | {
|
---|
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, SLOT(valuechanged(int)));
|
---|
20 |
|
---|
21 | SetValue(QString::number(combobox_value));
|
---|
22 |
|
---|
23 | //pour ne pas faire de doublons qd on ajoute des items
|
---|
24 | SetIsExpandable(true);
|
---|
25 | }
|
---|
26 |
|
---|
27 | ComboBox::~ComboBox()
|
---|
28 | {
|
---|
29 | delete combobox;
|
---|
30 | }
|
---|
31 |
|
---|
32 | void ComboBox::XmlEvent(QDomElement dom)
|
---|
33 | {
|
---|
34 | if(dom.attribute("item")!="") {
|
---|
35 | QString item=dom.attribute("item");
|
---|
36 | combobox->addItem(item);
|
---|
37 | combobox->setCurrentIndex(combobox_value);
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | void ComboBox::SetUptodate(void)
|
---|
42 | {
|
---|
43 | ui_to_var();
|
---|
44 | ui_to_xml();
|
---|
45 | visible_widget->setPalette(black_pal);
|
---|
46 |
|
---|
47 | }
|
---|
48 |
|
---|
49 | void ComboBox::ui_to_var(void)
|
---|
50 | {
|
---|
51 | combobox_value=combobox->currentIndex();
|
---|
52 | }
|
---|
53 |
|
---|
54 | void ComboBox::ui_to_xml(void)
|
---|
55 | {
|
---|
56 | SetValue(QString::number(combobox->currentIndex()));
|
---|
57 | }
|
---|
58 |
|
---|
59 | void ComboBox::Reset(void)
|
---|
60 | {
|
---|
61 | combobox->setCurrentIndex(combobox_value);
|
---|
62 | }
|
---|
63 |
|
---|
64 | void ComboBox::LoadEvent(QDomElement dom)
|
---|
65 | {
|
---|
66 | if(combobox->isEnabled()==true)
|
---|
67 | {
|
---|
68 | combobox->setCurrentIndex((dom.attribute("value")).toInt());
|
---|
69 | }
|
---|
70 | }
|
---|
71 |
|
---|
72 | void ComboBox::valuechanged(int value)
|
---|
73 | {
|
---|
74 | if(value!=combobox_value)
|
---|
75 | {
|
---|
76 | visible_widget->setPalette(red_pal);
|
---|
77 | }
|
---|
78 | else
|
---|
79 | {
|
---|
80 | visible_widget->setPalette(black_pal);
|
---|
81 | }
|
---|
82 | }
|
---|