include $(top_srcdir)/Makefile.inc
AM_CPPFLAGS = @QT_DECLARATIVE_CFLAGS@ @QT_GUI_CFLAGS@ @NAVIT_CFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/navit -DMODULE=gui_qml
modulegui_LTLIBRARIES = libgui_qml.la
-libgui_qml_la_SOURCES = gui_qml.moc gui_qml.cpp proxy.moc proxy.h
+libgui_qml_la_SOURCES = gui_qml.moc gui_qml.cpp proxy.moc proxy.h ngqpoint,moc ngqpoint.h
libgui_qml_la_LDFLAGS = @QT_DECLARATIVE_LIBS@ @QT_GUI_LIBS@ -module -avoid-version
-BUILT_SOURCES = gui_qml.moc proxy.moc
+BUILT_SOURCES = gui_qml.moc proxy.moc ngqpoint.moc
gui_qml.moc: gui_qml.cpp
@MOC@ $(srcdir)/gui_qml.cpp >gui_qml.moc
proxy.moc: proxy.h
@MOC@ $(srcdir)/proxy.h >proxy.moc
+ngqpoint.moc: ngqpoint.h
+ @MOC@ $(srcdir)/ngqpoint.h >ngqpoint.moc
#include "map.h"
#include "coord.h"
#include "vehicle.h"
+#include "coord.h"
+#include "transform.h"
+#include "mapset.h"
+#include "route.h"
//WORKAOUND for the c/c++ compatibility issues.
//range is defined inside of struct attr so it is invisible in c++
class NGQProxyGui* guiProxy;
class NGQProxyNavit* navitProxy;
class NGQProxyVehicle* vehicleProxy;
+ class NGQPoint* currentPoint;
};
#include "proxy.h"
+#include "ngqpoint.h"
//Proxy classes
class NGQProxyGui : public NGQProxy {
this->source=QString("");
}
+ void setNewPoint(struct point* p,NGQPointTypes type) {
+ if (this->object->currentPoint!=NULL) {
+ delete this->object->currentPoint;
+ }
+ this->object->currentPoint = new NGQPoint(this->object,p,type,NULL);
+ this->object->guiWidget->rootContext()->setContextProperty("point",this->object->currentPoint);
+ }
public slots:
void setPage(QString page) {
dbg(0,"Page is: %s\n",page.toStdString().c_str());
return retId;
}
-
+ void setDestination() {
+ navit_set_destination(this->object->nav,this->object->currentPoint->pc(),this->object->currentPoint->coordString().toStdString().c_str(),1);
+ }
+ void setPosition() {
+ navit_set_position(this->object->nav,this->object->currentPoint->pc());
+ }
protected:
int getAttrFunc(enum attr_type type, struct attr* attr, struct attr_iter* iter) { return navit_get_attr(this->object->nav, type, attr, iter); }
int setAttrFunc(struct attr* attr) {return navit_set_attr(this->object->nav,attr); }
{
struct gui_priv *this_=(struct gui_priv*)data;
+ /* There is a special 'popup' feature in navit, that makes all 'click-on-point' related stuff
+ but it looks VERY unflexible, so i'm not able to use it. I believe we need
+ to re-design the popup feature or remove it at all */
+ if ( button == 3 ) {
+ this_->guiProxy->setNewPoint(p,MapPoint);
+ this_->guiWidget->clearItems();
+ this_->guiProxy->setReturnSource(QString(""));
+ this_->guiProxy->setPage("point.qml");
+ this_->switcherWidget->setCurrentWidget(this_->guiWidget);
+ }
+
// check whether the position of the mouse changed during press/release OR if it is the scrollwheel
if (!navit_handle_button(this_->nav, pressed, button, p, NULL)) {
dbg(1,"navit has handled button\n");
if ( button == 1 && this_->menu_on_map_click ) {
if (!this_->lazy) {
+ this_->guiWidget->clearItems();
this_->guiProxy->setReturnSource(QString(""));
this_->guiProxy->setPage("main.qml");
}
this_->switcherWidget->setCurrentWidget(this_->guiWidget);
}
- /* There is a special 'popup' feature in navit, that makes all 'click-on-point' related stuff
- but it looks VERY unflexible, so i'm not able to use it. I believe we need
- to re-design the popup feature or remove it at all */
- if ( button == 3 && this_->menu_on_map_click ) {
- this_->switcherWidget->setCurrentWidget(this_->guiWidget);
- }
}
//GUI interface calls
--- /dev/null
+#ifndef NAVIT_GUI_QML_POINT_H
+#define NAVIT_GUI_QML_POINT_H
+
+enum NGQPointTypes {MapPoint};
+
+class NGQPoint : public QObject {
+ Q_OBJECT;
+
+ /*Q_PROPERTY(QString type READ type CONSTANT);*/
+
+ Q_PROPERTY(QString coordString READ coordString CONSTANT);
+ Q_PROPERTY(QString pointName READ pointName CONSTANT);
+ Q_PROPERTY(QString py READ py CONSTANT);
+ /*Q_PROPERTY(QString cx READ cx CONSTANT);
+ Q_PROPERTY(QString cy READ cy CONSTANT);*/
+public:
+ NGQPoint(struct gui_priv* this_,struct point* p,NGQPointTypes type=MapPoint,QObject *parent=NULL) : QObject(parent) {
+ this->object=this_;
+ transform_reverse(navit_get_trans(this->object->nav), p, &co);
+ transform_to_geo(transform_get_projection(navit_get_trans(this->object->nav)), &co, &g);
+ c.pro = transform_get_projection(navit_get_trans(this->object->nav));
+ c.x = co.x;
+ c.y = co.y;
+ this->p.x=p->x;
+ this->p.y=p->y;
+ this->type=type;
+ }
+
+ struct pcoord* pc() { return &c; }
+public slots:
+ QString coordString() {
+ char latc='N',lngc='E';
+ int lat_deg,lat_min,lat_sec;
+ int lng_deg,lng_min,lng_sec;
+ struct coord_geo g=this->g;
+
+ if (g.lat < 0) {
+ g.lat=-g.lat;
+ latc='S';
+ }
+ if (g.lng < 0) {
+ g.lng=-g.lng;
+ lngc='W';
+ }
+ lat_deg=g.lat;
+ lat_min=fmod(g.lat*60,60);
+ lat_sec=fmod(g.lat*3600,60);
+ lng_deg=g.lng;
+ lng_min=fmod(g.lng*60,60);
+ lng_sec=fmod(g.lng*3600,60);
+ return QString("%1°%2'%3\" %4%5%6°%7'%8\" %9").arg(lat_deg).arg(lat_min).arg(lat_sec).arg(latc).arg(' ').arg(lng_deg).arg(lng_min).arg(lng_sec).arg(lngc);
+ }
+ QString pointName() {
+ int dist=10;
+ struct mapset *ms;
+ struct mapset_handle *h;
+ struct map_rect *mr;
+ struct map *m;
+ struct item *item;
+ struct street_data *data;
+ struct map_selection sel;
+ struct transformation *trans;
+ enum projection pro;
+ struct attr attr;
+ char *label;
+ QString ret;
+
+ trans=navit_get_trans(this->object->nav);
+ pro=transform_get_projection(trans);
+ transform_from_geo(pro, &g, &co);
+ ms=navit_get_mapset(this->object->nav);
+ sel.next=NULL;
+ sel.u.c_rect.lu.x=c.x-dist;
+ sel.u.c_rect.lu.y=c.y+dist;
+ sel.u.c_rect.rl.x=c.x+dist;
+ sel.u.c_rect.rl.y=c.y-dist;
+ sel.order=18;
+ sel.range=item_range_all;
+ h=mapset_open(ms);
+ while ((m=mapset_next(h,1))) {
+ mr=map_rect_new(m, &sel);
+ if (! mr)
+ continue;
+ while ((item=map_rect_get_item(mr))) {
+ data=street_get_data(item);
+ if (transform_within_dist_item(&co, item->type, data->c, data->count, dist)) {
+ if (item_attr_get(item, attr_label, &attr)) {
+ label=map_convert_string(m, attr.u.str);
+ if (QString(item_to_name(item->type)).startsWith(QString("poi_"))) {
+ ret=item_to_name(item->type);
+ ret=ret.remove(QString("poi_"));
+ ret+=QString(" ")+label;
+ map_convert_free(label);
+ street_data_free(data);
+ map_rect_destroy(mr);
+ mapset_close(h);
+ return ret;
+ }
+ if (QString(item_to_name(item->type)).startsWith(QString("poly_"))) {
+ ret=item_to_name(item->type);
+ ret=ret.remove(QString("poly_"));
+ ret+=QString(" ")+label;
+ map_convert_free(label);
+ street_data_free(data);
+ map_rect_destroy(mr);
+ mapset_close(h);
+ return ret;
+ }
+ if (QString(item_to_name(item->type)).startsWith(QString("street_"))) {
+ ret="Street ";
+ ret+=label;
+ map_convert_free(label);
+ street_data_free(data);
+ map_rect_destroy(mr);
+ mapset_close(h);
+ return ret;
+ }
+ map_convert_free(label);
+ } else
+ ret=item_to_name(item->type);
+ }
+ street_data_free(data);
+ }
+ map_rect_destroy(mr);
+ }
+ mapset_close(h);
+ return ret;
+ }
+ QString px() {
+ char buffer[1024];
+ coord_format(this->g.lat,this->g.lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
+ return QString(buffer);
+ }
+ QString py() { return QString().setNum(p.y); }
+protected:
+private:
+ struct gui_priv* object;
+
+ NGQPointTypes type;
+ struct coord_geo g;
+ struct coord co;
+ struct pcoord c;
+ struct point p;
+};
+
+#include "ngqpoint.moc"
+
+#endif /* NAVIT_GUI_QML_POINT_H */
--- /dev/null
+import Qt 4.6
+
+Rectangle {
+ id: page
+
+ width: 800; height: 424
+ color: "Black"
+ opacity: 0
+
+ function pageOpen() {
+ page.opacity = 1;
+ }
+
+ Component.onCompleted: pageOpen();
+
+ opacity: Behavior {
+ NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
+ }
+
+ Text {
+ id: infoTxt;
+ text: point.coordString; color: "White"; font.pointSize: 20;
+ anchors.top:parent.top;anchors.horizontalCenter:parent.horizontalCenter
+ }
+ Text {
+ id: nameTxt;
+ text: point.pointName; color: "White"; font.pointSize: 20;
+ anchors.top:infoTxt.bottom;anchors.topMargin: 5;anchors.horizontalCenter:parent.horizontalCenter
+ }
+
+ Grid {
+ columns: 3;rows: 1
+ anchors.horizontalCenter: parent.horizontalCenter;
+ anchors.bottom: parent.verticalCenter; anchors.bottomMargin: 48;
+ spacing: 64
+ ButtonIcon {
+ id: btnView; text: "View on map"; icon: "gui_maps.svg"; onClicked: console.log("Implement me!");
+ }
+ ButtonIcon {
+ id: btnRoadbook; text: "Set as position"; icon: "gui_active.svg"; onClicked: { navit.setPosition(); gui.backToMap() }
+ }
+ ButtonIcon {
+ id: btnSettings; text: "Set as destination"; icon: "gui_active.svg"; onClicked: { navit.setDestination(); gui.backToMap() }
+ }
+ }
+
+ Grid {
+ columns: 3;rows: 1
+ anchors.horizontalCenter: parent.horizontalCenter;
+ anchors.top: parent.verticalCenter; anchors.topMargin: 48;
+ spacing: 64
+ ButtonIcon {
+ id: btnQuit; text: "Nearest POIs"; icon: "attraction.svg"; onClicked: console.log("Implement me!");
+ }
+ ButtonIcon {
+ id: btnStop; text: "Add as a Bookmark"; icon: "gui_bookmark.svg"; onClicked: console.log("Implement me!");
+ }
+ ButtonIcon {
+ id: btnInfo; text: "Point information"; icon: "gui_menu.svg"; onClicked: console.log("Implement me!");
+ }
+ }
+
+ Cellar {anchors.bottom: page.bottom; anchors.horizontalCenter: page.horizontalCenter; width: page.width }
+}