2
* uNav http://launchpad.net/unav
3
* Copyright (C) 2015-2016 Marcos Alvarez Costales https://launchpad.net/~costales
4
* Copyright (C) 2015-2016 JkB https://launchpad.net/~joergberroth
5
* Copyright (C) 2016 Nekhelesh Ramananthan https://launchpad.net/~nik90
7
* uNav is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 3 of the License, or
10
* (at your option) any later version.
12
* uNav is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
19
import Ubuntu.Components 1.3
25
title: i18n.tr("Route")
29
Component.onCompleted: mainPageStack.executeJavaScript("qml_set_route_status();")
34
anchors { fill: parent; margins: units.gu(2) }
35
height: contentItem.childrenRect.height
36
boundsBehavior: (contentHeight > routePage.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
40
ListElement {section: 0 ; text: "Search"; iconName: "../nav/img/pages/route/search.svg" }
41
ListElement {section: 0 ; text: "Favorites"; iconName: "../nav/img/pages/route/favorites.svg" }
42
ListElement {section: 1 ; text: "Nearby"; iconName: "../nav/img/pages/route/nearby_enabled.svg"}
43
ListElement {section: 2 ; text: "Nearby"; iconName: "../nav/img/pages/route/nearby_disabled.svg"}
44
ListElement {section: 0 ; text: "Coordinates"; iconName: "../nav/img/pages/route/coordinates.svg"}
45
ListElement {section: 0 ; text: "Share"; iconName: "../nav/img/pages/route/share.svg"}
46
ListElement {section: 3 ; text: "Cancel Route"; iconName: "../nav/img/pages/route/cancel.svg" }
51
//from system-settings (lp:ubuntu-system-settings)
52
property int itemWidth: units.gu(14)
53
// The amount of whitespace, including column spacing
54
property int space: parent.width - columns * itemWidth
55
// The column spacing is 1/n of the left/right margins
58
columnSpacing: space / ((2 * n) + (columns - 1))
59
rowSpacing: units.gu(6)
60
width: (columns * itemWidth) + columnSpacing * (columns - 1)
61
anchors.horizontalCenter: parent.horizontalCenter
63
var items = Math.floor(parent.width / itemWidth)
64
var count = repeater.count
65
return count < items ? count : items
73
delegate: AbstractButton {
78
visible: ( (model.section === 0) ||
79
(model.section === 1 && mainPageStack.currentLat !== "null" && mainPageStack.currentLng !== "null") ||
80
(model.section === 2 && (mainPageStack.currentLat === "null" || mainPageStack.currentLng === "null")) ||
81
(model.section === 3 && mainPageStack.routeState !== 'no') )
85
visible: button.pressed
86
anchors { fill: col; margins: -units.gu(1) }
87
backgroundColor: UbuntuColors.darkGrey
99
source: model.iconName
100
anchors.horizontalCenter: parent.horizontalCenter
106
text: i18n.tr(model.text)
107
horizontalAlignment: Text.AlignHCenter
108
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
109
anchors.horizontalCenter: parent.horizontalCenter
114
if (model.text === "Nearby" && (mainPageStack.currentLat === "null" || mainPageStack.currentLng === "null")) {
119
mainPageStack.pop(routePage)
120
if (model.text === "Favorites") {
121
mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"))
122
} else if (model.text === "Search") {
123
mainPageStack.push(Qt.resolvedUrl("SearchPage.qml"))
124
} else if (model.text === "Nearby") {
125
mainPageStack.push(Qt.resolvedUrl("PoiPage.qml"), {"fromPage": "RoutePage.qml", "lat": mainPageStack.currentLat, "lng": mainPageStack.currentLng})
126
} else if (model.text === "Coordinates") {
127
mainPageStack.push(Qt.resolvedUrl("Coordinate.qml"))
128
} else if (model.text === "Share") {
129
mainPageStack.push(Qt.resolvedUrl("SharePage.qml"))
130
} else if (model.text === "Cancel Route") {
131
mainPageStack.routeState = 'no';
132
mainPageStack.executeJavaScript("click_cancel_route();")