Ignore:
Timestamp:
Jul 29, 2016, 3:02:35 PM (5 years ago)
Author:
Thomas Fuhrmann
Message:

Improve ListWidget? + code cleanup + doxygen comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/mavlink/lib/FlairCore/src/ListWidget.cpp

    r57 r59  
    2020
    2121#include <sstream>
    22 #include <iostream>
    2322
    2423using std::string;
    25 using std::ostringstream;
    2624
    2725namespace flair {
     
    2927
    3028ListWidget::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
    3632  size_t count = 0;
    3733  while (1) {
    3834    string item;
    39     ostringstream item_prop;
     35    std::ostringstream item_prop;
    4036    item_prop << "item" << count;
    41     if(GetPersistentXmlProp(item_prop.str(), item)) {
     37    if (GetPersistentXmlProp(item_prop.str(), item)) {
    4238      SetVolatileXmlProp(item_prop.str(), item);
    4339      items.push_back(item);
     
    4743    count++;
    4844  }
    49 
    5045  SetVolatileXmlProp("row", position->Row());
    5146  SetVolatileXmlProp("col", position->Col());
     
    6358
    6459void 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);
    6864    SendXml();
    6965  }
     
    7167
    7268void ListWidget::XmlEvent(void) {
    73   if (GetPersistentXmlProp("value", selected_item_row)) {
    74     selected_item_changed = true;
     69  if (GetPersistentXmlProp("value", selectedItemRow)) {
     70    selectedItemChanged = true;
    7571  }
    7672}
Note: See TracChangeset for help on using the changeset viewer.