Changeset 64 in flair-src for branches


Ignore:
Timestamp:
Aug 23, 2016, 1:55:03 PM (8 years ago)
Author:
Thomas Fuhrmann
Message:

Save config on target and save all locally are now working

Location:
branches/mavlink/tools/FlairGCS/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/mavlink/tools/FlairGCS/src/ListWidget.cpp

    r61 r64  
    1212#include <sstream>
    1313
    14 // #include <iostream>
     14//to remove, for tests only
     15#include <iostream>
    1516
    1617ListWidget::ListWidget(Layout *parent, int row, int col, QString name)
     
    5556  if (dom.attribute("delete") != "") {
    5657    int row_to_del = dom.attribute("delete").toInt();
     58    RemoveItemFromXml(row_to_del);
    5759    QListWidgetItem *item_to_del = listwidget->takeItem(row_to_del);
    5860    if (item_to_del) {
     
    8890void ListWidget::Reset(void) {
    8991  if (currentItemRow != -1) {
     92    // TODO recharger l'élément supprimé si non appliqué ou recharger la variable
    9093    listwidget->setCurrentRow(currentItemRow);
    9194  }
     
    9497void ListWidget::LoadEvent(QDomElement dom) {
    9598  //function not tested
    96   // std::cout << "FlairGCS LoadEvent" << std::endl;
     99  std::cout << "FlairGCS LoadEvent" << std::endl;
    97100  if (listwidget->isEnabled() == true) {
    98     // std::cout << "FlairGCS LoadEvent loading" << std::endl;
     101    std::cout << "FlairGCS LoadEvent loading" << std::endl;
    99102    listwidget->clear();
    100103    QStringList items;
    101104    int count = 0;
    102105    while (dom.hasAttribute("item" + QString::number(count))) {
     106      std::cout << "FlairGCS LoadEvent boucle" << std::endl;
    103107      listwidget->addItem(dom.attribute("item" + QString::number(count)));
    104108      count++;
     
    117121
    118122bool ListWidget::IsUptodate(void) { return isUpToDate; }
     123
     124void 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  
    9292  void ui_to_xml(void);
    9393  /**
     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  /**
    94103   * Pointer to the managed QListWidget widget.
    95104   */
Note: See TracChangeset for help on using the changeset viewer.