mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Mobile/filtering: add count of filtered dives to search bar
The count in the trip headers is still that for the complete trip and therefore misleading. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
65aa6bc43b
commit
90d321f0ff
3 changed files with 37 additions and 8 deletions
|
@ -366,15 +366,38 @@ Kirigami.ScrollablePage {
|
|||
|
||||
Component {
|
||||
id: filterHeader
|
||||
Controls.TextField {
|
||||
id: sitefilter
|
||||
visible: (opacity > 0) && rootItem.filterToggle
|
||||
text: ""
|
||||
placeholderText: "Dive site name"
|
||||
onTextChanged: {
|
||||
rootItem.filterPattern = text
|
||||
diveModel.setFilter(text)
|
||||
RowLayout {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
visible: rootItem.filterToggle
|
||||
height: rootItem.filterToggle ? sitefilter.implicitHeight * 1.1 : 0
|
||||
Rectangle {
|
||||
width: Kirigami.Units.gridUnit / 4
|
||||
}
|
||||
onVisibleChanged: numShown.text = diveModel.shown()
|
||||
Controls.TextField {
|
||||
id: sitefilter
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
text: ""
|
||||
placeholderText: "Full text search"
|
||||
onTextChanged: {
|
||||
rootItem.filterPattern = text
|
||||
diveModel.setFilter(text)
|
||||
numShown.text = diveModel.shown()
|
||||
}
|
||||
}
|
||||
Controls.Label {
|
||||
id: numShown
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
// when this is first rendered, the model is still empty, so
|
||||
// instead of having a misleading 0 here, just don't show a count
|
||||
// it gets set whenever visibility or the search text changes
|
||||
text: ""
|
||||
}
|
||||
Rectangle {
|
||||
width: Kirigami.Units.regularSpacing
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,11 @@ void DiveListSortModel::resetFilter()
|
|||
setFilterRegExp("");
|
||||
}
|
||||
|
||||
int DiveListSortModel::shown()
|
||||
{
|
||||
return rowCount();
|
||||
}
|
||||
|
||||
int DiveListSortModel::getDiveId(int idx)
|
||||
{
|
||||
DiveListModel *mySourceModel = qobject_cast<DiveListModel *>(sourceModel());
|
||||
|
|
|
@ -19,6 +19,7 @@ public slots:
|
|||
int getIdxForId(int id);
|
||||
void setFilter(QString f);
|
||||
void resetFilter();
|
||||
int shown();
|
||||
};
|
||||
|
||||
class DiveListModel : public QAbstractListModel
|
||||
|
|
Loading…
Add table
Reference in a new issue