Changeset 15 in flair-src for trunk/tools/FlairGCS/src/ComboBox.cpp


Ignore:
Timestamp:
Apr 8, 2016, 3:40:57 PM (5 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/FlairGCS/src/ComboBox.cpp

    r10 r15  
    88#include <QFormLayout>
    99
    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);
     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);
    1414
    15     combobox_value=value;
     15  combobox_value = value;
    1616
    17     object_layout->addRow(name,combobox);
     17  object_layout->addRow(name, combobox);
    1818
    19     connect(combobox,SIGNAL(currentIndexChanged(int)),this, SLOT(valuechanged(int)));
     19  connect(combobox, SIGNAL(currentIndexChanged(int)), this,
     20          SLOT(valuechanged(int)));
    2021
    21     SetValue(QString::number(combobox_value));
     22  SetValue(QString::number(combobox_value));
    2223
    23     //pour ne pas faire de doublons qd on ajoute des items
    24     SetIsExpandable(true);
     24  // pour ne pas faire de doublons qd on ajoute des items
     25  SetIsExpandable(true);
    2526}
    2627
    27 ComboBox::~ComboBox()
    28 {
    29     delete combobox;
     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  }
    3036}
    3137
    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     }
     38void ComboBox::SetUptodate(void) {
     39  ui_to_var();
     40  ui_to_xml();
     41  visible_widget->setPalette(black_pal);
    3942}
    4043
    41 void ComboBox::SetUptodate(void)
    42 {
    43     ui_to_var();
    44     ui_to_xml();
    45     visible_widget->setPalette(black_pal);
     44void ComboBox::ui_to_var(void) { combobox_value = combobox->currentIndex(); }
    4645
     46void ComboBox::ui_to_xml(void) {
     47  SetValue(QString::number(combobox->currentIndex()));
    4748}
    4849
    49 void ComboBox::ui_to_var(void)
    50 {
    51     combobox_value=combobox->currentIndex();
     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  }
    5256}
    5357
    54 void ComboBox::ui_to_xml(void)
    55 {
    56     SetValue(QString::number(combobox->currentIndex()));
     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  }
    5764}
    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 }
Note: See TracChangeset for help on using the changeset viewer.