diff options
author | Jan Mulder <jlmulder@xs4all.nl> | 2018-02-04 16:46:03 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-23 22:45:29 +0100 |
commit | 0bc0b6bfe8666744611f8afa775a58b95e686652 (patch) | |
tree | c5e1d70743c0c842759c827e46a6267d004c9541 /mobile-widgets/qml | |
parent | f1bb2c847896689a5e70b6f423b1cfdc923824de (diff) | |
download | subsurface-0bc0b6bfe8666744611f8afa775a58b95e686652.tar.gz |
Mobile/filtering: first attempt to filter on dive site
[Dirk Hohndel: this is the starting point of my following commits, I decided to
leave it in place to give Jan credit for the work he did on
figuring out some of the plumbing needed to get things to work]
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qml')
-rw-r--r-- | mobile-widgets/qml/DiveList.qml | 32 | ||||
-rw-r--r-- | mobile-widgets/qml/main.qml | 3 |
2 files changed, 35 insertions, 0 deletions
diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml index ac9f6f391..b81cc9ac8 100644 --- a/mobile-widgets/qml/DiveList.qml +++ b/mobile-widgets/qml/DiveList.qml @@ -336,6 +336,7 @@ Kirigami.ScrollablePage { prefs.credentialStatus === CloudStatus.CS_NOCLOUD) { page.actions.main = page.downloadFromDCAction page.actions.right = page.addDiveAction + page.actions.left = page.filterToggleAction page.title = qsTr("Dive list") if (diveListView.count === 0) showPassiveNotification(qsTr("Please tap the '+' button to add a dive (or download dives from a supported dive computer)"), 3000) @@ -363,6 +364,20 @@ Kirigami.ScrollablePage { visible: diveListView.visible && diveListView.count === 0 } + Component { + id: filterHeader + Controls.TextField { + id: sitefilter + visible: (opacity > 0) && rootItem.filterToggle + text: "" + placeholderText: "Dive site name" + onTextChanged: { + rootItem.filterPattern = text + diveModel.setFilter(text) + } + } + } + ListView { id: diveListView anchors.fill: parent @@ -371,6 +386,7 @@ Kirigami.ScrollablePage { model: diveModel currentIndex: -1 delegate: diveDelegate + header: filterHeader boundsBehavior: Flickable.DragOverBounds maximumFlickVelocity: parent.height * 5 bottomMargin: Kirigami.Units.iconSizes.medium + Kirigami.Units.gridUnit @@ -420,6 +436,22 @@ Kirigami.ScrollablePage { } } + property QtObject filterToggleAction: Kirigami.Action { + icon { + name: ":icons/ic_filter_list" + } + text: qsTr("Filter dives") + onTriggered: { + rootItem.filterToggle = !rootItem.filterToggle + if (rootItem.filterToggle) { + diveModel.setFilter(rootItem.filterPattern) + } else { + diveModel.resetFilter() + rootItem.filterPattern = "" + } + } + } + onBackRequested: { if (startPage.visible && diveListView.count > 0 && prefs.credentialStatus !== CloudStatus.CS_INCORRECT_USER_PASSWD) { diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index 73f7712d9..e58c83689 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -32,6 +32,9 @@ Kirigami.ApplicationWindow { property alias pluggedInDeviceName: manager.pluggedInDeviceName property alias showPin: prefs.showPin property alias defaultCylinderIndex: settingsWindow.defaultCylinderIndex + property bool filterToggle: false + property string filterPattern: "" + onNotificationTextChanged: { if (notificationText != "") { // there's a risk that we have a >5 second gap in update events; |