- Timestamp:
- Jul 29, 2016, 3:02:35 PM (8 years ago)
- Location:
- branches/mavlink/lib/FlairCore/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mavlink/lib/FlairCore/src/ListWidget.cpp
r57 r59 20 20 21 21 #include <sstream> 22 #include <iostream>23 22 24 23 using std::string; 25 using std::ostringstream;26 24 27 25 namespace flair { … … 29 27 30 28 ListWidget::ListWidget(const LayoutPosition *position, string name) 31 : Widget(position->getLayout(), name, string("ListWidget")) { 32 33 selected_item_row = -1; 34 selected_item_changed = false; 35 29 : Widget(position->getLayout(), name, string("ListWidget")), 30 selectedItemRow(-1), selectedItemChanged(false) { 31 // load the items in the xml file and send them to the ground station 36 32 size_t count = 0; 37 33 while (1) { 38 34 string item; 39 ostringstream item_prop;35 std::ostringstream item_prop; 40 36 item_prop << "item" << count; 41 if (GetPersistentXmlProp(item_prop.str(), item)) {37 if (GetPersistentXmlProp(item_prop.str(), item)) { 42 38 SetVolatileXmlProp(item_prop.str(), item); 43 39 items.push_back(item); … … 47 43 count++; 48 44 } 49 50 45 SetVolatileXmlProp("row", position->Row()); 51 46 SetVolatileXmlProp("col", position->Col()); … … 63 58 64 59 void ListWidget::RemoveItem(void) { 65 if (selected_item_changed) { 66 selected_item_changed = false; 67 SetVolatileXmlProp("delete", selected_item_row); 60 if (selectedItemChanged) { 61 selectedItemChanged = false; 62 items.erase(items.cbegin() + selectedItemRow); 63 SetVolatileXmlProp("delete", selectedItemRow); 68 64 SendXml(); 69 65 } … … 71 67 72 68 void ListWidget::XmlEvent(void) { 73 if (GetPersistentXmlProp("value", selected _item_row)) {74 selected _item_changed = true;69 if (GetPersistentXmlProp("value", selectedItemRow)) { 70 selectedItemChanged = true; 75 71 } 76 72 } -
branches/mavlink/lib/FlairCore/src/ListWidget.h
r57 r59 22 22 23 23 /*! \class ListWidget 24 * 25 * \brief Class displaying a QListWidget on the ground station 26 * 27 */ 24 * 25 * \brief Class displaying a QListWidget on the ground station 26 * 27 * The internal list (called items) contains the same elements 28 * as the list of the QListWidget on the ground station. 29 * To do that, each action done on the ground station has to 30 * applied thanks to a click on the "apply" button. 31 * 32 */ 28 33 class ListWidget : public Widget { 29 34 public: … … 69 74 void XmlEvent(void); 70 75 71 //store the items 76 /** 77 * List of items displayed in the ground station. 78 */ 72 79 std::vector<std::string> items; 73 //selected item row, starting from 0 74 uint16_t selected_item_row; 75 bool selected_item_changed; 80 /** 81 * Row of the item currently selected in the list. 82 */ 83 uint16_t selectedItemRow; 84 /** 85 * Flag to know if the selected item has changed. 86 */ 87 bool selectedItemChanged; 76 88 }; 77 89 -
branches/mavlink/lib/FlairCore/src/Widget.cpp
r53 r59 19 19 #include "Widget_impl.h" 20 20 21 //to delete, for test purpose22 #include <iostream>23 24 21 using std::string; 25 22 … … 96 93 result = xmlGetProp(pimpl_->file_node, (xmlChar *)prop.c_str()); 97 94 if (result != NULL) { 98 value = std::string((char *)result);95 value = std::string((char *)result); 99 96 xmlFree(result); 100 97 return true;
Note:
See TracChangeset
for help on using the changeset viewer.