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(0,"Added destination %s\n",helperPoint.coordString().toLocal8Bit().constData());
|
34 |
}
|
35 |
|
36 |
//dbg(0,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(); };
|
46 |
void dropIterFunc(struct attr_iter* iter) { route_attr_iter_destroy(iter); };
|
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 */
|