Add:gui/qml:Added bolierplate for POI viewer
authorakashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Wed, 31 Mar 2010 13:33:45 +0000 (13:33 +0000)
committerakashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Wed, 31 Mar 2010 13:33:45 +0000 (13:33 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3109 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/gui/qml/guiProxy.h
navit/navit/gui/qml/navitProxy.h
navit/navit/gui/qml/ngqpoint.h
navit/navit/gui/qml/skins/navit/PageNavigation.qml
navit/navit/gui/qml/skins/navit/PageRoute.qml

index 1b51134..9e0d482 100644 (file)
@@ -28,6 +28,13 @@ public:
                this->object->currentPoint = new NGQPoint(this->object,p,type,NULL);
                this->object->guiWidget->rootContext()->setContextProperty("point",this->object->currentPoint);
        }
+       void setNewPoint(struct coord* c,NGQPointTypes type) {
+               if (this->object->currentPoint!=NULL) {
+                       delete this->object->currentPoint;
+               }
+               this->object->currentPoint = new NGQPoint(this->object,c,type,NULL);
+               this->object->guiWidget->rootContext()->setContextProperty("point",this->object->currentPoint);
+       }
        void processCommand(QString function) {
                this->function=function;
                this->setPage("command.qml",true);
@@ -159,6 +166,10 @@ private:
        QString function;
 };
 
+void __setNewPoint(struct gui_priv* this_,struct coord* c, NGQPointTypes type) {
+       this_->guiProxy->setNewPoint(c,type);
+}
+
 #include "guiProxy.moc"
 
 #endif /* NAVIT_GUI_QML_GUIPROXY_H */
index 20787c7..58855a8 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef NAVIT_GUI_QML_NAVIT_H
 #define NAVIT_GUI_QML_NAVIT_H
 
+void __setNewPoint(struct gui_priv* this_,struct coord* c, NGQPointTypes type);
+
 class NGQProxyNavit : public NGQProxy {
     Q_OBJECT;
 
@@ -72,9 +74,40 @@ public slots:
 
                return retId;
        }
+       QString getDestination() {
+               struct attr attr;
+               struct coord c;
+
+               if (getAttrFunc(attr_destination, &attr, NULL) ) {
+                       c.x=attr.u.pcoord->x;
+                       c.y=attr.u.pcoord->y;
+                       __setNewPoint(this->object,&c,MapPoint);
+                       return this->object->currentPoint->pointName();
+               }
+               return QString();
+       }
        void setDestination() {
                navit_set_destination(this->object->nav,this->object->currentPoint->pc(),this->object->currentPoint->coordString().toStdString().c_str(),1);
        }
+       QString getPosition() {
+               struct attr attr;
+               struct pcoord pc;
+               struct coord c;
+               struct transformation *trans;
+
+               trans=navit_get_trans(this->object->nav);
+
+               getAttrFunc(attr_vehicle, &attr, NULL);
+               this->object->currVehicle=attr.u.vehicle;
+
+               if (vehicle_get_attr(this->object->currVehicle, attr_position_coord_geo, &attr, NULL)) {
+                  pc.pro=transform_get_projection(trans);
+                  transform_from_geo(pc.pro, attr.u.coord_geo, &c);
+                  __setNewPoint(this->object,&c,MapPoint);
+                  return this->object->currentPoint->pointName();
+               }
+               return QString();
+       }
        void setPosition() {
                navit_set_position(this->object->nav,this->object->currentPoint->pc());
        }
index c55cd72..f4e83fe 100644 (file)
@@ -24,6 +24,20 @@ public:
         this->name=this->_coordName();
         this->coord=this->_coordString();
     }
+    NGQPoint(struct gui_priv* this_,struct coord* c,NGQPointTypes type=Bookmark,QObject *parent=NULL) : QObject(parent) {
+        this->object=this_;
+        this->co.x=c->x;
+        this->co.y=c->y;
+        transform_to_geo(transform_get_projection(navit_get_trans(this->object->nav)), &co, &g);
+        this->c.pro = transform_get_projection(navit_get_trans(this->object->nav));
+        this->c.x = c->x;
+        this->c.y = c->y;
+        this->type=type;
+
+        this->name=this->_coordName();
+        this->coord=this->_coordString();
+    }
+
     NGQPoint(struct gui_priv* this_,struct coord* c,QString name,NGQPointTypes type=Bookmark,QObject *parent=NULL) : QObject(parent) {
         this->object=this_;
         this->co.x=c->x;
index 7f1953c..d43213e 100644 (file)
@@ -10,6 +10,10 @@ Rectangle {
 
     function pageOpen() {
         page.opacity = 1;
+       if (navit.getDestination().length>0) {
+               btnPoi.opacity=0.8;
+       }
+
     }
     
     Component.onCompleted: pageOpen();    
@@ -40,7 +44,8 @@ Rectangle {
         anchors.top: parent.verticalCenter; anchors.topMargin: gui.height/16;
         spacing: gui.width/12
         ButtonIcon {
-            id: btnQuit; text: "POIs"; icon: "attraction.svg"; onClicked: console.log("Implement me!");
+            id: btnPoi; text: "POIs near\nPosition"; icon: "attraction.svg"; onClicked: console.log("Implement me!");
+           opacity: 0;
         }
         ButtonIcon {
             id: btnStop; text: "Stop"; icon: "gui_stop.svg"; onClicked: console.log("Implement me!");
index a2c5949..4667804 100644 (file)
@@ -9,6 +9,9 @@ Rectangle {
 \r
     function pageOpen() {\r
         page.opacity = 1;\r
+       if (navit.getPosition().length>0) {\r
+               btnPoi.opacity=0.8;\r
+       }\r
     }\r
     \r
     Component.onCompleted: pageOpen();    \r
@@ -39,10 +42,11 @@ Rectangle {
         anchors.top: parent.verticalCenter; anchors.topMargin: gui.height/16;\r
         spacing: gui.width/12\r
         ButtonIcon {\r
-            id: btnAbout; text: "Search"; icon: "gui_town.svg"; onClicked: gui.setPage("PageSearch.qml");\r
+            id: btnSearch; text: "Search"; icon: "gui_town.svg"; onClicked: gui.setPage("PageSearch.qml");\r
         }\r
         ButtonIcon {\r
-            id: btnQuit; text: "POIs"; icon: "attraction.svg"; onClicked: console.log("Implement me!");\r
+            id: btnPoi; text: "POIs near\nDestination"; icon: "attraction.svg"; onClicked: console.log("Implement me!");\r
+           opacity: 0;\r
         }\r
     }\r
 \r