summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mobile-widgets/qml/DiveList.qml39
-rw-r--r--qt-models/divelistmodel.cpp5
-rw-r--r--qt-models/divelistmodel.h1
3 files changed, 37 insertions, 8 deletions
diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml
index b2dde0cd0..8dd8dd010 100644
--- a/mobile-widgets/qml/DiveList.qml
+++ b/mobile-widgets/qml/DiveList.qml
@@ -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
+ }
+
}
}
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp
index 38c8c86c0..1c4e20b48 100644
--- a/qt-models/divelistmodel.cpp
+++ b/qt-models/divelistmodel.cpp
@@ -20,6 +20,11 @@ void DiveListSortModel::resetFilter()
setFilterRegExp("");
}
+int DiveListSortModel::shown()
+{
+ return rowCount();
+}
+
int DiveListSortModel::getDiveId(int idx)
{
DiveListModel *mySourceModel = qobject_cast<DiveListModel *>(sourceModel());
diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h
index c34fb931d..b633cc3d5 100644
--- a/qt-models/divelistmodel.h
+++ b/qt-models/divelistmodel.h
@@ -19,6 +19,7 @@ public slots:
int getIdxForId(int id);
void setFilter(QString f);
void resetFilter();
+ int shown();
};
class DiveListModel : public QAbstractListModel