Ignore:
Timestamp:
Jul 27, 2016, 5:43:01 PM (5 years ago)
Author:
Thomas Fuhrmann
Message:

Default xml configuration is working with ListWidget?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/mavlink/tools/FlairGCS/src/ListWidget.cpp

    r48 r54  
    1414    : FormLayout(parent, row, col, name, "ListWidget") {
    1515  listwidget = new QListWidget();
    16   // listwidget->setCurrentIndex(value);
    17 
    18   // combobox_value = value;
    19 
    20   // object_layout->addRow(name, listwidget);
    2116  object_layout->addRow(new QLabel(name));
    2217  object_layout->addRow(listwidget);
     18  // to avoid duplicates when adding items
     19  SetIsExpandable(true);
     20}
    2321
    24   // connect(listwidget, SIGNAL(currentIndexChanged(int)), this,
    25   //         SLOT(valuechanged(int)));
    26 
    27   // SetValue(QString::number(combobox_value));
    28 
    29   // pour ne pas faire de doublons qd on ajoute des items
    30   SetIsExpandable(true);
     22ListWidget::ListWidget(Layout *parent, int row, int col, QString name, QStringList& items)
     23    : ListWidget(parent, row, col, name) {
     24  if (!items.isEmpty()) {
     25    listwidget->addItems(items);
     26  }
    3127}
    3228
     
    4137    QListWidgetItem* current_item = listwidget->currentItem();
    4238    listwidget->removeItemWidget(current_item);
    43     if (current_item) { delete current_item; }
     39    if (current_item) {
     40      delete current_item;
     41    }
    4442  }
    4543}
     
    4846  // ui_to_var();
    4947  // ui_to_xml();
     48  std::cout << "SetUptodate" << std::endl;
    5049  visible_widget->setPalette(black_pal);
    5150}
     
    6261
    6362void ListWidget::LoadEvent(QDomElement dom) {
    64   if (listwidget->isEnabled() == true) {
     63  std::cout << "In LoadEvent" << std::endl;
     64  // Parse the item list   
     65  QStringList items;
     66  int count = 0;
     67  while (dom.hasAttribute("item" + QString::number(count))) {
     68    QString item = dom.attribute("item" + QString::number(count));
     69    std::cout << "Item" << count << " : " << item.toStdString() << std::endl;
     70    items.append(item);
     71    count++;
     72  }
     73
     74  listwidget->addItems(items);
     75
     76  // if (listwidget->isEnabled() == true) {
    6577    // listwidget->setCurrentIndex((dom.attribute("value")).toInt());
    66   }
     78  // }
    6779}
    6880
Note: See TracChangeset for help on using the changeset viewer.