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

Last change on this file since 15 was 15, checked in by Bayard Gildas, 5 years ago

sources reformatted with flair-format-dir script

File size: 1.6 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 "ComboBox.h"
6#include "Layout.h"
7#include <QComboBox>
8#include <QFormLayout>
9
[15]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);
[9]14
[15]15  combobox_value = value;
[9]16
[15]17  object_layout->addRow(name, combobox);
[9]18
[15]19  connect(combobox, SIGNAL(currentIndexChanged(int)), this,
20          SLOT(valuechanged(int)));
[9]21
[15]22  SetValue(QString::number(combobox_value));
[9]23
[15]24  // pour ne pas faire de doublons qd on ajoute des items
25  SetIsExpandable(true);
[9]26}
27
[15]28ComboBox::~ComboBox() { delete combobox; }
[9]29
[15]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  }
[9]36}
37
[15]38void ComboBox::SetUptodate(void) {
39  ui_to_var();
40  ui_to_xml();
41  visible_widget->setPalette(black_pal);
[9]42}
43
[15]44void ComboBox::ui_to_var(void) { combobox_value = combobox->currentIndex(); }
[9]45
[15]46void ComboBox::ui_to_xml(void) {
47  SetValue(QString::number(combobox->currentIndex()));
[9]48}
49
[15]50void ComboBox::Reset(void) { combobox->setCurrentIndex(combobox_value); }
[9]51
[15]52void ComboBox::LoadEvent(QDomElement dom) {
53  if (combobox->isEnabled() == true) {
54    combobox->setCurrentIndex((dom.attribute("value")).toInt());
55  }
[9]56}
57
[15]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  }
[9]64}
Note: See TracBrowser for help on using the repository browser.