Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

osmscout: list nearby types fetched from the server #40

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions guides/osmscout.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ def parse_description(result):
with poor.util.silent(Exception):
items.append(result.admin_region)
return ", ".join(items) or "–"

def types():
return poor.http.get_json("http://localhost:8553/v1/poi_types")
1 change: 1 addition & 0 deletions guides/osmscout_settings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Column {

Component.onCompleted: {
page.params.name = ""
page.types = py.call_sync("poor.app.guide._provider.types")
}
}
}
8 changes: 6 additions & 2 deletions qml/NearbyPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Page {
property string nearText: ""
property string query: ""
property var params: {}
property var types: []
property real radius: 1000

// Offer a different selection of radii depending on the user's
Expand Down Expand Up @@ -67,6 +68,7 @@ Page {
onClicked: {
var dialog = app.pageStack.push("GuidePage.qml");
dialog.accepted.connect(function() {
page.types = []
usingButton.value = py.evaluate("poor.app.guide.name");
column.addSetttings();
});
Expand Down Expand Up @@ -114,7 +116,7 @@ Page {
// Avoid putting label and value on different lines.
width: 3 * parent.width
onClicked: {
var dialog = app.pageStack.push("PlaceTypePage.qml");
var dialog = app.pageStack.push("PlaceTypePage.qml", { 'types': page.types } );
dialog.accepted.connect(function() {
page.query = dialog.query;
});
Expand Down Expand Up @@ -174,7 +176,9 @@ Page {
}

onQueryChanged: {
py.call_sync("poor.app.history.add_place_type", [page.query]);
if (page.types.length === 0) {
py.call_sync("poor.app.history.add_place_type", [page.query]);
}
}

onStatusChanged: {
Expand Down
16 changes: 12 additions & 4 deletions qml/PlaceTypePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Dialog {

property var history: []
property string query: ""
property var types: []

SilicaListView {
id: listView
Expand All @@ -53,10 +54,13 @@ Dialog {
id: contextMenu
MenuItem {
text: app.tr("Remove")
enabled: dialog.types.length === 0
onClicked: {
py.call_sync("poor.app.history.remove_place_type", [model.type]);
dialog.history = py.evaluate("poor.app.history.place_types");
listView.model.remove(index);
if (dialog.types.length === 0) {
py.call_sync("poor.app.history.remove_place_type", [model.type]);
dialog.history = py.evaluate("poor.app.history.place_types");
listView.model.remove(index);
}
}
}
}
Expand Down Expand Up @@ -125,7 +129,11 @@ Dialog {

function loadHistory() {
// Load search history and preallocate list items.
dialog.history = py.evaluate("poor.app.history.place_types");
if (dialog.types.length > 0) {
dialog.history = dialog.types;
} else {
dialog.history = py.evaluate("poor.app.history.place_types");
}
while (listView.model.count < 100)
listView.model.append({"type": "",
"text": "",
Expand Down