Skip to content

Commit

Permalink
allow filtering by bookmarked status in poi list
Browse files Browse the repository at this point in the history
  • Loading branch information
rinigus committed Sep 4, 2018
1 parent 1ee801c commit 1e286b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions poor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"map_scale_navigation_car": 2.0,
"map_scale_navigation_foot": 1.0,
"map_scale_navigation_transit": 1.0,
"poi_list_show_bookmarked": False,
"reroute": True,
"router": "stadiamaps",
"show_narrative": True,
Expand Down
21 changes: 18 additions & 3 deletions qml/PoiPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,31 @@ import "."

import "js/util.js" as Util

Dialog {
Page {
id: page
allowedOrientations: app.defaultAllowedOrientations

property bool bookmarkedOnly: false
property string lastQuery: ""
property var searchKeys: ["title", "poiType", "address", "postcode", "text", "phone", "link"]
property var searchKeys: ["title", "poiType", "address", "postcode", "text", "phone", "link"]

SilicaListView {
id: listView
anchors.fill: parent
// Prevent list items from stealing focus.
currentIndex: -1

PullDownMenu {
MenuItem {
text: bookmarkedOnly ? app.tr("Show all") : app.tr("Show bookmarked")
onClicked: {
bookmarkedOnly = !bookmarkedOnly;
app.conf.set("poi_list_show_bookmarked", bookmarkedOnly);
fillModel(lastQuery);
}
}
}

delegate: ListItem {
id: listItem
contentHeight: titleItem.height + detailsItem.height + textItem.height + Theme.paddingLarge
Expand Down Expand Up @@ -169,11 +181,14 @@ Dialog {
}

Component.onCompleted: {
bookmarkedOnly = app.conf.get("poi_list_show_bookmarked");
fillModel("");
}

function fillModel(query) {
var s = Util.findMatchesInObjects(query, map.pois, searchKeys);
var data = map.pois;
if (bookmarkedOnly) data = map.pois.filter(function (p) { return p.bookmarked; });
var s = Util.findMatchesInObjects(query, data, searchKeys);
listView.model.clear();
s.map(function (p){ listView.model.append(p); });
}
Expand Down

0 comments on commit 1e286b5

Please sign in to comment.