Mobile/filtering: add properties for dive list model and filter text

This allows us to modify those from different parts of the code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2018-10-20 11:57:36 -04:00
parent 09507416c8
commit 2183e41bb0

View file

@ -20,6 +20,8 @@ Kirigami.ScrollablePage {
property int horizontalPadding: Kirigami.Units.gridUnit / 2 - Kirigami.Units.smallSpacing + 1 property int horizontalPadding: Kirigami.Units.gridUnit / 2 - Kirigami.Units.smallSpacing + 1
property string activeTrip property string activeTrip
property bool showBusy: false property bool showBusy: false
property QtObject diveListModel: diveModel
property string numShownText
supportsRefreshing: true supportsRefreshing: true
onRefreshingChanged: { onRefreshingChanged: {
@ -409,7 +411,6 @@ Kirigami.ScrollablePage {
anchors.right: parent.right anchors.right: parent.right
anchors.leftMargin: Kirigami.Units.gridUnit / 2 anchors.leftMargin: Kirigami.Units.gridUnit / 2
anchors.rightMargin: Kirigami.Units.gridUnit / 2 anchors.rightMargin: Kirigami.Units.gridUnit / 2
onVisibleChanged: numShown.text = diveModel.shown()
Controls.TextField { Controls.TextField {
id: sitefilter id: sitefilter
z: 10 z: 10
@ -424,7 +425,6 @@ Kirigami.ScrollablePage {
diveModel.setFilter(text) diveModel.setFilter(text)
console.log("back from setFilter") console.log("back from setFilter")
showBusy = false showBusy = false
numShown.text = diveModel.shown()
} }
onEnabledChanged: { onEnabledChanged: {
// reset the filter when it gets toggled // reset the filter when it gets toggled
@ -438,10 +438,7 @@ Kirigami.ScrollablePage {
id: numShown id: numShown
z: 10 z: 10
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
// when this is first rendered, the model is still empty, so text: numShownText
// instead of having a misleading 0 here, just don't show a count
// it gets set whenever visibility or the search text changes
text: ""
} }
} }
} }
@ -452,7 +449,7 @@ Kirigami.ScrollablePage {
anchors.fill: parent anchors.fill: parent
opacity: 1.0 - startPage.opacity opacity: 1.0 - startPage.opacity
visible: opacity > 0 visible: opacity > 0
model: diveModel model: page.diveListModel
currentIndex: -1 currentIndex: -1
delegate: diveDelegate delegate: diveDelegate
header: filterHeader header: filterHeader