Changeset 64 in flair-src
- Timestamp:
- Aug 23, 2016, 1:55:03 PM (8 years ago)
- Location:
- branches/mavlink/tools/FlairGCS/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mavlink/tools/FlairGCS/src/ListWidget.cpp
r61 r64 12 12 #include <sstream> 13 13 14 // #include <iostream> 14 //to remove, for tests only 15 #include <iostream> 15 16 16 17 ListWidget::ListWidget(Layout *parent, int row, int col, QString name) … … 55 56 if (dom.attribute("delete") != "") { 56 57 int row_to_del = dom.attribute("delete").toInt(); 58 RemoveItemFromXml(row_to_del); 57 59 QListWidgetItem *item_to_del = listwidget->takeItem(row_to_del); 58 60 if (item_to_del) { … … 88 90 void ListWidget::Reset(void) { 89 91 if (currentItemRow != -1) { 92 // TODO recharger l'élément supprimé si non appliqué ou recharger la variable 90 93 listwidget->setCurrentRow(currentItemRow); 91 94 } … … 94 97 void ListWidget::LoadEvent(QDomElement dom) { 95 98 //function not tested 96 //std::cout << "FlairGCS LoadEvent" << std::endl;99 std::cout << "FlairGCS LoadEvent" << std::endl; 97 100 if (listwidget->isEnabled() == true) { 98 //std::cout << "FlairGCS LoadEvent loading" << std::endl;101 std::cout << "FlairGCS LoadEvent loading" << std::endl; 99 102 listwidget->clear(); 100 103 QStringList items; 101 104 int count = 0; 102 105 while (dom.hasAttribute("item" + QString::number(count))) { 106 std::cout << "FlairGCS LoadEvent boucle" << std::endl; 103 107 listwidget->addItem(dom.attribute("item" + QString::number(count))); 104 108 count++; … … 117 121 118 122 bool ListWidget::IsUptodate(void) { return isUpToDate; } 123 124 void ListWidget::RemoveItemFromXml(int row_to_del) { 125 // Shift the elements in the XML file to have the one to delete at the end 126 std::ostringstream item_prop; 127 for (int count = row_to_del; count < listwidget->count() - 1; count++) { 128 item_prop << "item" << count; 129 SetAttribute(QString::fromStdString(item_prop.str()), 130 listwidget->item(count + 1)->text()); 131 // Clear the value of the stringstream 132 item_prop.str(std::string()); 133 } 134 // Delete the last element from the XML file 135 item_prop << "item" << (listwidget->count() - 1); 136 RemoveAttribute(QString::fromStdString(item_prop.str())); 137 } -
branches/mavlink/tools/FlairGCS/src/ListWidget.h
r60 r64 92 92 void ui_to_xml(void); 93 93 /** 94 * \brief Removes the row_to_del element from the internal xml file. 95 * 96 * As the order of the elements is important, all the elements after the one 97 * deleted are shifted to occupy the blank space. 98 * 99 * \param[in] row_to_del The row of the element to delete. 100 */ 101 void RemoveItemFromXml(int row_to_del); 102 /** 94 103 * Pointer to the managed QListWidget widget. 95 104 */
Note:
See TracChangeset
for help on using the changeset viewer.