diff options
author | Viktor Verebelyi <vviktor2@gmail.com> | 2020-10-08 23:32:38 +0100 |
---|---|---|
committer | Viktor Verebelyi <vviktor2@gmail.com> | 2020-10-08 23:32:45 +0100 |
commit | dd09e93ca86135e8f8e75be0036c8b83312e823b (patch) | |
tree | 63bb7bf739c62c8b364866398fd829ffd8303f95 | |
parent | 8719cdbb3e3a6b5bba5b881a632559163e96f39e (diff) | |
download | navit-dd09e93ca86135e8f8e75be0036c8b83312e823b.tar.gz |
Add:qt5_gui:Levy Add routing/navigation status tracking
-rw-r--r-- | navit/graphics/qt5/QNavitQuick_2.cpp | 1 | ||||
-rw-r--r-- | navit/gui/qt5_qml/gui_qt5_qml.qrc | 1 | ||||
-rw-r--r-- | navit/gui/qt5_qml/navitroute.cpp | 66 | ||||
-rw-r--r-- | navit/gui/qt5_qml/navitroute.h | 34 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/MainLayout.qml | 63 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/MapNavigationBar.qml | 20 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/RouteCalculating.qml | 26 |
7 files changed, 153 insertions, 58 deletions
diff --git a/navit/graphics/qt5/QNavitQuick_2.cpp b/navit/graphics/qt5/QNavitQuick_2.cpp index 1098c9a01..303ddb275 100644 --- a/navit/graphics/qt5/QNavitQuick_2.cpp +++ b/navit/graphics/qt5/QNavitQuick_2.cpp @@ -213,7 +213,6 @@ void QNavitQuick_2::setPitch(int pitch){ setNavitNumProperty(attr_pitch, pitch); m_pitch = pitch; emit propertiesChanged(); - qDebug() << pitch; } } diff --git a/navit/gui/qt5_qml/gui_qt5_qml.qrc b/navit/gui/qt5_qml/gui_qt5_qml.qrc index 8788f63a4..87795a0bb 100644 --- a/navit/gui/qt5_qml/gui_qt5_qml.qrc +++ b/navit/gui/qt5_qml/gui_qt5_qml.qrc @@ -951,5 +951,6 @@ <file>themes/Levy/SearchDrawerContextMenu.qml</file> <file>themes/Levy/SearchDrawerBreadcrumbs.qml</file> <file>themes/Levy/DestinationDetailsBar.qml</file> + <file>themes/Levy/RouteCalculating.qml</file> </qresource> </RCC> diff --git a/navit/gui/qt5_qml/navitroute.cpp b/navit/gui/qt5_qml/navitroute.cpp index 18101eb0b..243976f74 100644 --- a/navit/gui/qt5_qml/navitroute.cpp +++ b/navit/gui/qt5_qml/navitroute.cpp @@ -1,6 +1,6 @@ #include "navitroute.h" -NavitRoute::NavitRoute() +NavitRoute::NavitRoute() : m_status(Invalid) { } @@ -51,12 +51,10 @@ void NavitRoute::setNavit(NavitInstance * navit){ navit_add_callback(m_navitInstance->getNavit(),cb); navit_add_callback(m_navitInstance->getNavit(),cb2); - struct navit * tst = navit->getNavit(); - + statusUpdate(); } void NavitRoute::routeUpdate(){ -// listIcons(m_navitInstance); struct map * map = nullptr; struct map_rect * mr = nullptr; struct navigation * nav = nullptr; @@ -114,14 +112,58 @@ void NavitRoute::routeUpdate(){ emit propertiesChanged(); } map_rect_destroy(mr); + + statusUpdate(); } +QString NavitRoute::getLastDestination(struct pcoord *pc) { + if(m_navitInstance){ + struct map *formerdests; + struct map_rect *mr_formerdests; + struct item *item; + struct attr attr; + + if(!navit_get_attr(m_navitInstance->getNavit(), attr_former_destination_map, &attr, nullptr)) + return ""; + + formerdests=attr.u.map; + if(!formerdests) + return ""; + + mr_formerdests=map_rect_new(formerdests, nullptr); + if(!mr_formerdests) + return ""; + + pc->pro = map_projection(formerdests); + + QString ret; + while ((item=map_rect_get_item(mr_formerdests))) { + struct coord c; + if (item->type!=type_former_destination) continue; + if (!item_attr_get(item, attr_label, &attr)) continue; + + if (item_coord_get(item, &c, 1)) { + pc->x = c.x; + pc->y = c.y; + ret=attr.u.str; + } + } + map_rect_destroy(mr_formerdests); + return ret; + } +} void NavitRoute::destinationUpdate(){ struct route * route = navit_get_route(m_navitInstance->getNavit()); int destCount = route_get_destination_count(route); + statusUpdate(); + if(destCount > m_destCount){ - emit destinationAdded(); + QString destination = getLastDestination(&m_lastDestinationCoord); + + navit_set_center(m_navitInstance->getNavit(), &m_lastDestinationCoord, 1); + navit_zoom_level(m_navitInstance->getNavit(), 4, nullptr); + emit destinationAdded(destination); } else if (destCount < m_destCount) { emit destinationRemoved(); } @@ -130,6 +172,20 @@ void NavitRoute::destinationUpdate(){ } m_destCount = destCount; } + +void NavitRoute::statusUpdate(){ + struct navigation * nav = nullptr; + nav = navit_get_navigation(m_navitInstance->getNavit()); + if(!nav) { + return; + } + struct attr attr; + navigation_get_attr(nav, attr_nav_status, &attr,nullptr); + if(m_status != attr.u.num){ + m_status = static_cast<Status>(attr.u.num); + emit statusChanged(); + } +} void NavitRoute::routeCallbackHandler(NavitRoute * navitRoute){ navitRoute->routeUpdate(); } diff --git a/navit/gui/qt5_qml/navitroute.h b/navit/gui/qt5_qml/navitroute.h index 8ff4ab5ab..00f6f5ff1 100644 --- a/navit/gui/qt5_qml/navitroute.h +++ b/navit/gui/qt5_qml/navitroute.h @@ -41,6 +41,7 @@ class NavitRoute : public QObject Q_PROPERTY(QString distance READ getDistance NOTIFY propertiesChanged) Q_PROPERTY(QString timeLeft READ getTimeLeft NOTIFY propertiesChanged) Q_PROPERTY(QString arrivalTime READ getArrivalTime NOTIFY propertiesChanged) + Q_PROPERTY(Status status READ getStatus NOTIFY statusChanged) public: NavitRoute(); void setNavit(NavitInstance * navit); @@ -48,23 +49,43 @@ public: static void destinationCallbackHandler(NavitRoute * navitRoute); void routeUpdate(); void destinationUpdate(); - Q_INVOKABLE void setDestination(QString label, int x, int y); - Q_INVOKABLE void setPosition(int x, int y); - Q_INVOKABLE void addStop(QString label, int x, int y, int position); - Q_INVOKABLE void cancelNavigation(); + void statusUpdate(); + + enum Status { + Invalid = status_invalid, + NoRoute = status_no_route, + Idle = status_no_destination, + Calculating = status_calculating, + Recalculating = status_recalculating, + Navigating = status_routing + }; + + Q_ENUMS(Status) signals: void propertiesChanged(); - void destinationAdded(); + void destinationAdded(QString destination); void destinationRemoved(); void navigationFinished(); + void statusChanged(); +public slots: + void setDestination(QString label, int x, int y); + void setPosition(int x, int y); + void addStop(QString label, int x, int y, int position); + void cancelNavigation(); + private: NavitInstance *m_navitInstance = nullptr; QStringList m_directions; QString m_distance; QString m_timeLeft; QString m_arrivalTime; + Status m_status; + + QString m_lastDestination; + struct pcoord m_lastDestinationCoord; int m_destCount; + QString getLastDestination(pcoord *pc); QStringList getDirections() { return m_directions; } @@ -77,6 +98,9 @@ private: QString getArrivalTime() { return m_arrivalTime; } + Status getStatus(){ + return m_status; + } }; #endif // NAVITROUTE_H diff --git a/navit/gui/qt5_qml/themes/Levy/MainLayout.qml b/navit/gui/qt5_qml/themes/Levy/MainLayout.qml index 4ac68e1de..eccd0f65f 100644 --- a/navit/gui/qt5_qml/themes/Levy/MainLayout.qml +++ b/navit/gui/qt5_qml/themes/Levy/MainLayout.qml @@ -28,7 +28,7 @@ Item { function startNavigation() { __root.state = "" __root.prevState = "" - mapNavigationBar.state = "navigationState" + mapNavigationBar.setNavigationState() navit1.pitch = 45; navit1.followVehicle = 1 @@ -51,7 +51,16 @@ Item { destinationDetailsBar.address = destination; } onNavigationFinished: { - mapNavigationBar.state = "" + console.log("onNavigationFinished"); + mapNavigationBar.setNormalState() + } + onStatusChanged: { + console.log(status) + NavitRoute.Navigating + if(status === NavitRoute.Recalculating || status === NavitRoute.Navigating ){ + console.log("showing navigation state") + mapNavigationBar.setNavigationState() + } } } @@ -265,7 +274,19 @@ Item { __root.state = "routeOverviewPOIs"; searchDrawer.searchPOIs(""); } - } Item { + } + + RouteCalculating { + id: routeCalculating + width: parent.width * 0.4 + height: parent.height * 0.05 + anchors.topMargin: parent.height * 0.05 + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + visible: (navitRoute.status === NavitRoute.Calculating || navitRoute.status === NavitRoute.Recalculating ) + } + + Item { id: recenterButton width: parent.width > parent.height ? parent.height * 0.1 : parent.width * 0.1 height: width @@ -307,6 +328,8 @@ Item { } + + Rectangle { id: overlay color: "#00000000" @@ -405,7 +428,7 @@ Item { } onCancelRoute : { __root.state = "" - mapNavigationBar.state = "" + mapNavigationBar.setNormalState() navitRoute.cancelNavigation(); } } @@ -696,41 +719,13 @@ Item { - - - - - - - - - - - - - - - - - - - - - - - - - /*##^## Designer { D{i:0;height:720;width:1280}D{i:24;anchors_height:200;anchors_width:200}D{i:25;anchors_height:200;anchors_width:200} D{i:26;anchors_height:200;anchors_width:200}D{i:27;anchors_height:200;anchors_width:200} D{i:23;anchors_height:200;anchors_width:200}D{i:29;anchors_height:200;anchors_width:200} D{i:28;anchors_height:200;anchors_width:200}D{i:4;anchors_x:196}D{i:5;anchors_width:200;anchors_x:196} D{i:6;anchors_height:100;anchors_width:100}D{i:7;anchors_height:100;anchors_width:100} -D{i:8;anchors_y:109}D{i:10;anchors_height:200;anchors_width:200}D{i:11;anchors_height:100;anchors_width:100} -D{i:12;anchors_height:100;anchors_width:100;anchors_y:109}D{i:9;anchors_y:109}D{i:13;anchors_y:109} -D{i:22;anchors_height:200;anchors_width:200}D{i:23;anchors_height:200;anchors_width:200} -D{i:24;anchors_height:200;anchors_width:200}D{i:26;anchors_height:200;anchors_width:200} -D{i:27;anchors_height:200;anchors_width:200}D{i:25;anchors_height:200;anchors_width:200} +D{i:8;anchors_y:109}D{i:9;anchors_y:109}D{i:13;anchors_height:100;anchors_width:100} +D{i:14;anchors_height:100;anchors_width:100;anchors_y:109}D{i:15;anchors_y:109}D{i:12;anchors_height:200;anchors_width:200} } ##^##*/ diff --git a/navit/gui/qt5_qml/themes/Levy/MapNavigationBar.qml b/navit/gui/qt5_qml/themes/Levy/MapNavigationBar.qml index 9c37b0721..a8e68cc80 100644 --- a/navit/gui/qt5_qml/themes/Levy/MapNavigationBar.qml +++ b/navit/gui/qt5_qml/themes/Levy/MapNavigationBar.qml @@ -9,6 +9,13 @@ Item { property alias distanceLeft: distanceLeft.text property alias arrivalTime: arrivingTime.text + function setNavigationState(){ + __root.state = "navigationState" + } + function setNormalState(){ + __root.state = "" + } + Rectangle { id: leftButton width: height @@ -226,16 +233,3 @@ Item { ] } - - - - - - - -/*##^## Designer { - D{i:0;autoSize:true;height:100;width:1000}D{i:2;anchors_height:200}D{i:4;anchors_height:200} -D{i:3;anchors_height:200;anchors_x:20}D{i:6;anchors_x:24;anchors_y:37}D{i:7;anchors_height:100;anchors_width:100} -D{i:9;anchors_height:200}D{i:14;anchors_height:100;anchors_width:100}D{i:8;anchors_height:200} -} - ##^##*/ diff --git a/navit/gui/qt5_qml/themes/Levy/RouteCalculating.qml b/navit/gui/qt5_qml/themes/Levy/RouteCalculating.qml new file mode 100644 index 000000000..9b26ffc61 --- /dev/null +++ b/navit/gui/qt5_qml/themes/Levy/RouteCalculating.qml @@ -0,0 +1,26 @@ +import QtQuick 2.9 + +Item { + Rectangle { + id: rectangle + color: "#ffffff" + radius: parent.height/2 + border.width: 1 + anchors.fill: parent + + Text { + id: calculatingText + text: qsTr("Calculating Route...") + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: 24 + } + } + +} + +/*##^## Designer { + D{i:0;autoSize:true;height:50;width:600}D{i:1;anchors_height:200;anchors_width:200} +} + ##^##*/ |