From 0bc0b6bfe8666744611f8afa775a58b95e686652 Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Sun, 4 Feb 2018 16:46:03 +0100 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-models/divelistmodel.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'qt-models/divelistmodel.cpp') diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 8dc119ad8..76c0db7e3 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -8,6 +8,17 @@ DiveListSortModel::DiveListSortModel(QObject *parent) : QSortFilterProxyModel(pa } +void DiveListSortModel::setFilter(QString f) +{ + setFilterRole(DiveListModel::DiveSiteRole); + setFilterRegExp(f); +} + +void DiveListSortModel::resetFilter() +{ + setFilterRegExp(""); +} + int DiveListSortModel::getDiveId(int idx) { DiveListModel *mySourceModel = qobject_cast(sourceModel()); @@ -151,6 +162,7 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const switch(role) { case DiveRole: return QVariant::fromValue(curr_dive); case DiveDateRole: return (qlonglong)curr_dive->timestamp(); + case DiveSiteRole: return curr_dive->location(); } return QVariant(); @@ -161,6 +173,7 @@ QHash DiveListModel::roleNames() const QHash roles; roles[DiveRole] = "dive"; roles[DiveDateRole] = "date"; + roles[DiveSiteRole] = "site"; return roles; } -- cgit v1.2.3-70-g09d2