Navit SVN

/work/compile/navit/src/navit/gui/qml/routeProxy.h

00001 #ifndef NAVIT_GUI_QML_ROUTEPROXY_H
00002 #define NAVIT_GUI_QML_ROUTEPROXY_H
00003 
00004 
00005 class NGQProxyRoute : public NGQProxy {
00006     Q_OBJECT;
00007 
00008 public:
00009     NGQProxyRoute(struct gui_priv* this_,QObject* parent) : NGQProxy(this_,parent) { };
00010 
00011 public slots:
00012         void addDestination() {
00013                 int counter=0;
00014                 QList<struct attr> destinations=this->_routeDestinations();
00015                 struct pcoord *coords=(struct pcoord*)malloc(sizeof(struct pcoord)*(destinations.size()+1)); //Additional destination included
00016 
00017                 for (QList<struct attr>::const_iterator iter=destinations.begin();iter!=destinations.end();iter++) {                    
00018                         coords[counter]=*(iter->u.pcoord);
00019                         counter++;
00020                 }
00021 
00022                 //Add new one
00023                 coords[counter]=*(this->object->currentPoint->pc());            
00024 
00025                 //Propagate to route engine
00026                 route_set_destinations(navit_get_route(this->object->nav),coords,counter+1,1);
00027         }
00028     QString getDestinations() {
00029 
00030                 QList<struct attr> destinations=this->_routeDestinations();
00031                 for (QList<struct attr>::const_iterator iter=destinations.begin();iter!=destinations.end();iter++) {
00032                         NGQPoint helperPoint(this->object,iter->u.pcoord,MapPoint);
00033                         dbg(0,"Added destination %s\n",helperPoint.coordString().toLocal8Bit().constData());
00034                 }
00035 
00036                 //dbg(0,QString::number(_itemId).toStdString().c_str());
00037 
00038                 //return retDoc.toString();
00039                 return QString();
00040         }
00041 
00042 protected:
00043     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); }
00044         int setAttrFunc(struct attr* attr) {return route_set_attr(navit_get_route(this->object->nav),attr); }
00045     struct attr_iter* getIterFunc() { return route_attr_iter_new(); };
00046         void dropIterFunc(struct attr_iter* iter) { route_attr_iter_destroy(iter); };
00047 
00048         QList<struct attr> _routeDestinations() {
00049                 QList<struct attr> ret;
00050                 struct attr attr;
00051                 struct attr_iter *iter;
00052 
00053                 //Fill da list
00054                 iter=getIterFunc();
00055                 if (iter == NULL) {
00056                         return ret;
00057                 }
00058 
00059                 while (getAttrFunc(attr_destination, &attr, iter) ) {
00060                         struct attr c_attr=attr;
00061                         ret.push_front(c_attr); //List is reversed in route engine
00062                 }
00063 
00064                 dropIterFunc(iter);
00065 
00066                 return ret;
00067         }
00068 };
00069 
00070 #include "routeProxy.moc"
00071 
00072 #endif /* NAVIT_GUI_QML_ROUTEPROXY_H */