Changeset 67 in flair-src for trunk/tools


Ignore:
Timestamp:
08/29/16 16:58:23 (8 years ago)
Author:
Sanahuja Guillaume
Message:

corrections bugs checkpoint map

Location:
trunk/tools/FlairGCS/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/FlairGCS/src/DataRemote.cpp

    r15 r67  
    7878
    7979void DataRemote::SendPeriod(int period, bool auto_refresh) {
     80  RemoveAllAttributes();
     81
    8082  SetAttribute("period", period);
    8183  SetAttribute("enabled", auto_refresh);
  • trunk/tools/FlairGCS/src/Landmark.cpp

    r15 r67  
    4646}
    4747
     48bool Landmark::IsUptodate(void) {
     49  if(text->brush()==QBrush(Qt::white)) {
     50    return true;
     51  } else {
     52    return false;
     53  }
     54}
     55
    4856void Landmark::setCoordinate(const QGeoCoordinate &coordinate) {
    4957  pixmap->setCoordinate(coordinate);
  • trunk/tools/FlairGCS/src/Landmark.h

    r15 r67  
    2929  void RemoveLandmark(void);
    3030  void AddLandmark(QtMobility::QGraphicsGeoMap *geoMap);
     31  bool IsUptodate(void);
    3132
    3233private:
  • trunk/tools/FlairGCS/src/Map.cpp

    r62 r67  
    9595  for (int i = 0; i < points.count(); i++) delete points.at(i);
    9696  delete mapWidget;
    97 
    98   if(geoMap!=0) delete geoMap;
    9997}
    10098
  • trunk/tools/FlairGCS/src/Map.h

    r15 r67  
    2525class Map : public DataRemote {
    2626  Q_OBJECT
     27
     28  friend class MapWidget;
    2729
    2830public:
  • trunk/tools/FlairGCS/src/XmlWidget.cpp

    r15 r67  
    291291}
    292292
     293void XmlWidget::RemoveAllAttributes() {
     294  QString name = write_elem.attribute("name");
     295
     296  QDomNamedNodeMap attributes=write_elem.attributes();
     297  while(attributes.count()!=0) {
     298    printf("%i %s\n",attributes.count(),attributes.item(0).toAttr().name().toLocal8Bit().constData());
     299    write_elem.removeAttribute(attributes.item(0).toAttr().name());
     300  }
     301  SetAttribute("name", name);
     302}
     303
    293304void XmlWidget::RenamedFrom(QString old_name) {
    294305  QString name = write_elem.attribute("name");
  • trunk/tools/FlairGCS/src/XmlWidget.h

    r16 r67  
    6868  void SetAttribute(const QString &name, float value);
    6969  void SetAttribute(const QString &name, double value);
     70  void RemoveAllAttributes(); //except name
    7071  void RemoveAttribute(const QString &name);
    7172};
  • trunk/tools/FlairGCS/src/mapwidget.cpp

    r62 r67  
    5454#include "Landmark.h"
    5555#include "Map.h"
     56#include "ConnectionLayout.h"
    5657
    5758using namespace QtMobility;
     
    6667  pressed = false;
    6768  landmark_match = NULL;
    68   is_uptodate = true;
    6969  this->map = map;
    7070
     
    107107      QList<QAction *> centered_actions;
    108108
     109      //add centered for every point
    109110      QMenu *centered_menu = menu->addMenu("centered");
    110111      for (int i = 0; i < points.count(); i++) {
     
    122123
    123124      b = menu->addAction("place checkpoint");
     125
     126      //add go to for every landmark
    124127      QMenu *go_to_menu = menu->addMenu("go to");
    125128      for (int i = 0; i < landmarks->count(); i++) {
     
    134137      z = map->execmenu(this, menu, event->globalPos());
    135138
     139      //center to the desired point
    136140      for (int i = 0; i < centered_actions.count(); i++) {
    137141        if (z == centered_actions.at(i)) {
     
    146150      }
    147151
     152      //add a landmark
    148153      if (z == b) {
    149154        Landmark *landmark = new Landmark(
     
    151156            QString("%1").arg(landmarks->count() + 1));
    152157        landmarks->append(landmark);
    153         is_uptodate = false;
    154158      }
    155159      for (int i = 0; i < go_to_actions.count(); i++) {
     
    161165      }
    162166
     167    //delete landmark
    163168    } else {
    164169      QAction *a, *z;
    165170      a = menu->addAction("delete");
    166       z = menu->exec(event->globalPos());
    167 
    168       if (z == a) {
    169         int i;
    170         for (i = 0; i < landmarks->count(); i++) {
    171           if (landmarks->at(i)->contains(
     171      //get selected landmark id
     172      int landmark_index;
     173      for (landmark_index = 0; landmark_index < landmarks->count(); landmark_index++) {
     174          if (landmarks->at(landmark_index)->contains(
    172175                  geoMap->screenPositionToCoordinate(event->pos()))) {
    173             delete landmarks->at(i);
    174             landmarks->removeAt(i);
     176            a->setEnabled(landmarks->at(landmark_index)->IsUptodate());
    175177            break;
    176178          }
    177         }
    178         for (int j = i; j < landmarks->count(); j++) {
     179      }
     180      z = menu->exec(event->globalPos());
     181
     182      if (z == a) {
     183        //remove from landmarks_old
     184        for (int i = 0; i < landmarks_old->count(); i++) {
     185          if (landmarks_old->at(i)->contains(
     186                  geoMap->screenPositionToCoordinate(event->pos()))) {
     187            landmarks_old->removeAt(i);
     188            break;
     189          }
     190        }
     191
     192        //remove from landmarks
     193        delete landmarks->at(landmark_index);
     194        landmarks->removeAt(landmark_index);
     195
     196        //reorder the remaining ones
     197        for (int j = landmark_index; j < landmarks->count(); j++) {
    179198          landmarks->at(j)->setText(QString("%1").arg(j + 1));
    180199        }
     200
     201        //send delete
     202        map->RemoveAllAttributes();
     203        map->SetAttribute("lat" + QString::number(landmark_index),"delete");
     204        map->SetAttribute("long" + QString::number(landmark_index),"delete");
     205        map->connectionLayout()->XmlToSend(map->XmlDoc());
     206        map->RemoveAttribute("lat" + QString::number(landmark_index));
     207        map->RemoveAttribute("long" + QString::number(landmark_index));
    181208      }
    182209    }
     
    219246        landmark_match = landmarks->at(i);
    220247        landmark_match->setColor(Qt::red);
    221         is_uptodate = false;
    222248      }
    223249      new_cursor = Qt::PointingHandCursor;
     
    290316}
    291317
    292 bool MapWidget::IsUptodate(void) { return is_uptodate; }
     318bool MapWidget::IsUptodate(void) {
     319  for (int i = 0; i < landmarks->count(); i++) {
     320    if(!landmarks->at(i)->IsUptodate()) return false;
     321  }
     322  return true;
     323}
    293324
    294325void MapWidget::SetUptodate(void) {
     
    306337    landmarks_old->at(i)->setVisible(false);
    307338  }
    308 
    309   is_uptodate = true;
    310339}
    311340
     
    323352    landmarks->at(i)->setColor(Qt::white);
    324353  }
    325 
    326   is_uptodate = true;
    327354}
    328355
  • trunk/tools/FlairGCS/src/mapwidget.h

    r62 r67  
    9494  QPoint dragStartPosition;
    9595  bool pressed;
    96   bool is_uptodate;
    9796
    9897  QGraphicsScene *m_scene;
Note: See TracChangeset for help on using the changeset viewer.