diff --git a/guides/osmscout.py b/guides/osmscout.py index bbd205a..b354968 100644 --- a/guides/osmscout.py +++ b/guides/osmscout.py @@ -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") diff --git a/guides/osmscout_settings.qml b/guides/osmscout_settings.qml index 059e4c8..9b02375 100644 --- a/guides/osmscout_settings.qml +++ b/guides/osmscout_settings.qml @@ -36,6 +36,7 @@ Column { Component.onCompleted: { page.params.name = "" + page.types = py.call_sync("poor.app.guide._provider.types") } } } diff --git a/qml/NearbyPage.qml b/qml/NearbyPage.qml index fefaec0..be60335 100644 --- a/qml/NearbyPage.qml +++ b/qml/NearbyPage.qml @@ -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 @@ -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(); }); @@ -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; }); @@ -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: { diff --git a/qml/PlaceTypePage.qml b/qml/PlaceTypePage.qml index 4452294..16a07d6 100644 --- a/qml/PlaceTypePage.qml +++ b/qml/PlaceTypePage.qml @@ -29,6 +29,7 @@ Dialog { property var history: [] property string query: "" + property var types: [] SilicaListView { id: listView @@ -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); + } } } } @@ -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": "",