Changeset 54 in flair-src for branches/mavlink
- Timestamp:
- Jul 27, 2016, 5:43:01 PM (8 years ago)
- Location:
- branches/mavlink/tools/FlairGCS/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mavlink/tools/FlairGCS/src/Layout.cpp
r48 r54 23 23 #include <QGridLayout> 24 24 #include "ListWidget.h" 25 #include <QStringList> 25 26 26 27 Layout::Layout(QWidget *parent, XmlWidget *xml, QString name, QString type) … … 250 251 } 251 252 if (type == "ListWidget") { 252 widget = new ListWidget(this, row, col, name); 253 // Parse the item list 254 QStringList items; 255 int count = 0; 256 while (dom.hasAttribute("item" + QString::number(count))) { 257 QString item = dom.attribute("item" + QString::number(count)); 258 items.append(item); 259 count++; 260 } 261 widget = new ListWidget(this, row, col, name, items); 253 262 } 254 263 -
branches/mavlink/tools/FlairGCS/src/ListWidget.cpp
r48 r54 14 14 : FormLayout(parent, row, col, name, "ListWidget") { 15 15 listwidget = new QListWidget(); 16 // listwidget->setCurrentIndex(value);17 18 // combobox_value = value;19 20 // object_layout->addRow(name, listwidget);21 16 object_layout->addRow(new QLabel(name)); 22 17 object_layout->addRow(listwidget); 18 // to avoid duplicates when adding items 19 SetIsExpandable(true); 20 } 23 21 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); 22 ListWidget::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 } 31 27 } 32 28 … … 41 37 QListWidgetItem* current_item = listwidget->currentItem(); 42 38 listwidget->removeItemWidget(current_item); 43 if (current_item) { delete current_item; } 39 if (current_item) { 40 delete current_item; 41 } 44 42 } 45 43 } … … 48 46 // ui_to_var(); 49 47 // ui_to_xml(); 48 std::cout << "SetUptodate" << std::endl; 50 49 visible_widget->setPalette(black_pal); 51 50 } … … 62 61 63 62 void 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) { 65 77 // listwidget->setCurrentIndex((dom.attribute("value")).toInt()); 66 }78 // } 67 79 } 68 80 -
branches/mavlink/tools/FlairGCS/src/ListWidget.h
r48 r54 10 10 class QListWidget; 11 11 class Layout; 12 class QStringList; 12 13 13 14 class ListWidget : public FormLayout { … … 16 17 public: 17 18 ListWidget(Layout *parent, int row, int col, QString name); 19 ListWidget(Layout *parent, int row, int col, QString name, QStringList& items); 18 20 ~ListWidget(); 19 21
Note:
See TracChangeset
for help on using the changeset viewer.