navit  0.5.1-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
routeProxy.h
Go to the documentation of this file.
1 #ifndef NAVIT_GUI_QML_ROUTEPROXY_H
2 #define NAVIT_GUI_QML_ROUTEPROXY_H
3 
4 
5 class NGQProxyRoute : public NGQProxy {
6  Q_OBJECT;
7 
8 public:
9  NGQProxyRoute(struct gui_priv* this_,QObject* parent) : NGQProxy(this_,parent) { };
10 
11 public slots:
12  void addDestination() {
13  int counter=0;
14  QList<struct attr> destinations=this->_routeDestinations();
15  struct pcoord *coords=(struct pcoord*)malloc(sizeof(struct pcoord)*(destinations.size()+1)); //Additional destination included
16 
17  for (QList<struct attr>::const_iterator iter=destinations.begin();iter!=destinations.end();iter++) {
18  coords[counter]=*(iter->u.pcoord);
19  counter++;
20  }
21 
22  //Add new one
23  coords[counter]=*(this->object->currentPoint->pc());
24 
25  //Propagate to route engine
26  route_set_destinations(navit_get_route(this->object->nav),coords,counter+1,1);
27  }
28  QString getDestinations() {
29 
30  QList<struct attr> destinations=this->_routeDestinations();
31  for (QList<struct attr>::const_iterator iter=destinations.begin();iter!=destinations.end();iter++) {
32  NGQPoint helperPoint(this->object,iter->u.pcoord,MapPoint);
33  dbg(lvl_debug,"Added destination %s\n",helperPoint.coordString().toLocal8Bit().constData());
34  }
35 
36  //dbg(lvl_debug,QString::number(_itemId).toStdString().c_str());
37 
38  //return retDoc.toString();
39  return QString();
40  }
41 
42 protected:
43  int getAttrFunc(enum attr_type type, struct attr* attr, struct attr_iter* iter) {return route_get_attr(navit_get_route(this->object->nav), type, attr, iter); }
44  int setAttrFunc(struct attr* attr) {return route_set_attr(navit_get_route(this->object->nav),attr); }
45  struct attr_iter* getIterFunc() { return route_attr_iter_new(); };
47 
48  QList<struct attr> _routeDestinations() {
49  QList<struct attr> ret;
50  struct attr attr;
51  struct attr_iter *iter;
52 
53  //Fill da list
54  iter=getIterFunc();
55  if (iter == NULL) {
56  return ret;
57  }
58 
59  while (getAttrFunc(attr_destination, &attr, iter) ) {
60  struct attr c_attr=attr;
61  ret.push_front(c_attr); //List is reversed in route engine
62  }
63 
64  dropIterFunc(iter);
65 
66  return ret;
67  }
68 };
69 
70 #include "routeProxy.moc"
71 
72 #endif /* NAVIT_GUI_QML_ROUTEPROXY_H */
attr_type
Definition: attr.h:34
int setAttrFunc(struct attr *attr)
Definition: routeProxy.h:44
tuple iter
Definition: eval.py:8
Definition: gpx2navit_txt.h:51
Definition: ngqpoint.h:32
struct route * navit_get_route(struct navit *this_)
Definition: navit.c:3393
void addDestination()
Definition: routeProxy.h:12
NGQProxyRoute(struct gui_priv *this_, QObject *parent)
Definition: routeProxy.h:9
void dropIterFunc(struct attr_iter *iter)
Definition: routeProxy.h:46
void route_set_destinations(struct route *this, struct pcoord *dst, int count, int async)
Sets the destination of a route.
Definition: route.c:1185
Definition: graphics_win32.h:52
int getAttrFunc(enum attr_type type, struct attr *attr, struct attr_iter *iter)
Definition: routeProxy.h:43
#define dbg(level,...)
Definition: debug.h:59
Definition: debug.h:52
void route_attr_iter_destroy(struct attr_iter *iter)
Definition: route.c:4234
Definition: config_.c:48
QList< struct attr > _routeDestinations()
Definition: routeProxy.h:48
struct navit * nav
Definition: graphics_win32.h:53
Definition: attr.h:156
int route_set_attr(struct route *this_, struct attr *attr)
Definition: route.c:4084
struct gui_priv * object
Definition: proxy.h:89
Definition: ngqpoint.h:34
Definition: routeProxy.h:5
int route_get_attr(struct route *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Definition: route.c:4154
char type[3]
Definition: garmin_img.c:130
Definition: coord.h:40
QString coordString
Definition: ngqpoint.h:35
QString getDestinations()
Definition: routeProxy.h:28
Definition: proxy.h:21
struct attr_iter * getIterFunc()
Definition: routeProxy.h:45
struct attr_iter * route_attr_iter_new(void)
Definition: route.c:4228