Changeset 53 in flair-src


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

Default xml configuration is working with ListWidget

Location:
branches/mavlink/lib/FlairCore/src
Files:
3 edited

Legend:

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

    r49 r53  
    1919#include "LayoutPosition.h"
    2020
     21#include <sstream>
     22#include <iostream>
     23
    2124using std::string;
     25using std::ostringstream;
    2226
    2327namespace flair {
     
    2630ListWidget::ListWidget(const LayoutPosition *position, string name)
    2731    : Widget(position->getLayout(), name, string("ListWidget")) {
    28  
     32  size_t count = 0;
     33  while (1) {
     34    string item;
     35    ostringstream item_prop;
     36    item_prop << "item" << count;
     37    if(GetPersistentXmlProp(item_prop.str(), item)) {
     38      SetVolatileXmlProp(item_prop.str(), item);
     39      items.push_back(item);
     40    } else {
     41      break;
     42    }
     43    count++;
     44  }
    2945  // value_changed = true;
    3046  SetVolatileXmlProp("row", position->Row());
     
    4763
    4864void ListWidget::XmlEvent(void) {
     65  std::cout << "FlairCore ListWidget XmlEvent" << std::endl;
    4966  // GetMutex();
    5067  // if (GetPersistentXmlProp("value", box_value))
  • branches/mavlink/lib/FlairCore/src/ListWidget.h

    r49 r53  
    6868  */
    6969  void XmlEvent(void);
     70
     71  //store the items
     72  std::vector<std::string> items;
    7073};
    7174
  • branches/mavlink/lib/FlairCore/src/Widget.cpp

    r15 r53  
    1919#include "Widget_impl.h"
    2020
     21//to delete, for test purpose
     22#include <iostream>
     23
    2124using std::string;
    2225
     
    8285  if (GetPersistentXmlProp<double>(prop, tmp)) {
    8386    value = tmp;
     87    return true;
     88  } else {
     89    return false;
     90  }
     91}
     92
     93template <>
     94bool Widget::GetPersistentXmlProp(std::string prop, std::string &value) {
     95  xmlChar *result = NULL;
     96  result = xmlGetProp(pimpl_->file_node, (xmlChar *)prop.c_str());
     97  if (result != NULL) {
     98    value = std::string((char*)result);
     99    xmlFree(result);
    84100    return true;
    85101  } else {
Note: See TracChangeset for help on using the changeset viewer.