From 6067e73f8bc7d2eb8f6cae7a000e91464df06ea9 Mon Sep 17 00:00:00 2001 From: akashihi Date: Tue, 5 Oct 2010 09:15:05 +0000 Subject: [PATCH] Add:gui/qml:Added forgotten routeProxy.h git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3599 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/gui/qml/routeProxy.h | 72 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 navit/navit/gui/qml/routeProxy.h diff --git a/navit/navit/gui/qml/routeProxy.h b/navit/navit/gui/qml/routeProxy.h new file mode 100644 index 0000000..77defd2 --- /dev/null +++ b/navit/navit/gui/qml/routeProxy.h @@ -0,0 +1,72 @@ +#ifndef NAVIT_GUI_QML_ROUTEPROXY_H +#define NAVIT_GUI_QML_ROUTEPROXY_H + + +class NGQProxyRoute : public NGQProxy { + Q_OBJECT; + +public: + NGQProxyRoute(struct gui_priv* this_,QObject* parent) : NGQProxy(this_,parent) { }; + +public slots: + void addDestination() { + int counter=0; + QList destinations=this->_routeDestinations(); + struct pcoord *coords=(struct pcoord*)malloc(sizeof(struct pcoord)*(destinations.size()+1)); //Additional destination included + + for (QList::const_iterator iter=destinations.begin();iter!=destinations.end();iter++) { + coords[counter]=*(iter->u.pcoord); + counter++; + } + + //Add new one + coords[counter]=*(this->object->currentPoint->pc()); + + //Propagate to route engine + route_set_destinations(navit_get_route(this->object->nav),coords,counter+1,1); + } + QString getDestinations() { + + QList destinations=this->_routeDestinations(); + for (QList::const_iterator iter=destinations.begin();iter!=destinations.end();iter++) { + NGQPoint helperPoint(this->object,iter->u.pcoord,MapPoint); + dbg(0,"Added destination %s\n",helperPoint.coordString().toLocal8Bit().constData()); + } + + //dbg(0,QString::number(_itemId).toStdString().c_str()); + + //return retDoc.toString(); + return QString(); + } + +protected: + 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); } + int setAttrFunc(struct attr* attr) {return route_set_attr(navit_get_route(this->object->nav),attr); } + struct attr_iter* getIterFunc() { return route_attr_iter_new(); }; + void dropIterFunc(struct attr_iter* iter) { route_attr_iter_destroy(iter); }; + + QList _routeDestinations() { + QList ret; + struct attr attr; + struct attr_iter *iter; + + //Fill da list + iter=getIterFunc(); + if (iter == NULL) { + return ret; + } + + while (getAttrFunc(attr_destination, &attr, iter) ) { + struct attr c_attr=attr; + ret.push_front(c_attr); //List is reversed in route engine + } + + dropIterFunc(iter); + + return ret; + } +}; + +#include "routeProxy.moc" + +#endif /* NAVIT_GUI_QML_ROUTEPROXY_H */ -- 2.7.4