2
* GPS Navigation 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
6
* GPS Navigation is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
11
* GPS Navigation is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
18
import QtQuick.Layouts 1.1
19
import Ubuntu.Components 1.3
20
import Ubuntu.Components.ListItems 1.3 as ListItems
21
import QtQuick.XmlListModel 2.0
22
import "js/PoiCategories.js" as Categories
23
import QtQuick.LocalStorage 2.0
24
import "js/db.js" as UnavDB
29
title: i18n.tr("Nearby")
35
property string unit: navApp.settings.unit === 0 ? "km" : "mi"
36
property var factorList: ["1", "5", "15", "30", "50"]
47
mainPageStack.pop(poiPage);
48
if (poiPage.fromPage === "RoutePage.qml")
49
mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"));
57
text: i18n.tr("Search")
59
poiPage.state = "search"
60
poiSearchField.forceActiveFocus()
74
mainPageStack.pop(poiPage)
75
if (poiPage.fromPage === "RoutePage.qml")
76
mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"));
83
rightMargin: units.gu(2)
85
width: parent ? parent.width - units.gu(2) : undefined
86
inputMethodHints: Qt.ImhNoPredictiveText
89
if ( text.length > 0) {
90
categoryList.searchString(text);
94
if (text.length === 0) {
95
categoryListModel.clear();
96
categoryListModel.initialize();
97
poiSearchField.forceActiveFocus();
106
model: [factorList[0]+unit, factorList[1]+unit, factorList[2]+unit, factorList[3]+unit, factorList[4]+unit]
112
id: categoryListModel
113
function initialize() {
114
categoryListModel.clear();
115
Categories.data.forEach( function(category) {
116
categoryListModel.append(category);
119
var res = UnavDB.getNearByHistory();
120
var len = res.rows.length;
121
for ( var i = 0; i < len; ++i) {
122
categoryListModel.insert(
125
theme: i18n.tr("Most recent"),
126
label: i18n.tr(res.rows.item(i).type),
127
en_label: res.rows.item(i).type,
128
clause: res.rows.item(i).clause
133
Component.onCompleted: initialize()
141
height: childrenRect.height
152
model: categoryListModel
157
function searchString( string) {
158
categoryListModel.initialize();
159
for( var i = 0; i < categoryListModel.count; i++){
160
if (model.get(i).label.toLowerCase().indexOf(string.toLowerCase()) === -1) {
161
model.remove(i); i--;
166
section.property: "theme"
167
section.criteria: ViewSection.FullString
168
section.labelPositioning: ViewSection.CurrentLabelAtStart + ViewSection.InlineLabels
169
section.delegate: sectionHeading
170
delegate: ListItems.Standard {
176
//mainPageStack.pop(poiPage);
177
mainPageStack.push(Qt.resolvedUrl("PoiListPage.qml"), {
181
poiType: model.label,
182
clause: model.clause,
183
geoDistFactor: Number(factorList[poiPage.head.sections.selectedIndex])
185
if (navApp.settings.saveHistory) {
186
UnavDB.saveToNearByHistory(model.en_label, model.clause);