From 8f7633eff867e7d5437f9caf24e82f581bf624c0 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 16 Oct 2018 07:56:41 -0400 Subject: Mobile/filtering: full text filter, instead of just dive site Signed-off-by: Dirk Hohndel --- qt-models/divelistmodel.cpp | 9 +++++---- qt-models/divelistmodel.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'qt-models') diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 76c0db7e3..38c8c86c0 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -10,8 +10,9 @@ DiveListSortModel::DiveListSortModel(QObject *parent) : QSortFilterProxyModel(pa void DiveListSortModel::setFilter(QString f) { - setFilterRole(DiveListModel::DiveSiteRole); - setFilterRegExp(f); + setFilterRole(DiveListModel::FullTextRole); + setFilterRegExp(QString(".*%1.*").arg(f)); + setFilterCaseSensitivity(Qt::CaseInsensitive); } void DiveListSortModel::resetFilter() @@ -162,7 +163,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(); + case FullTextRole: return curr_dive->fullText(); } return QVariant(); @@ -173,7 +174,7 @@ QHash DiveListModel::roleNames() const QHash roles; roles[DiveRole] = "dive"; roles[DiveDateRole] = "date"; - roles[DiveSiteRole] = "site"; + roles[FullTextRole] = "fulltext"; return roles; } diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index 2773ce33d..c34fb931d 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -29,7 +29,7 @@ public: enum DiveListRoles { DiveRole = Qt::UserRole + 1, DiveDateRole, - DiveSiteRole + FullTextRole }; static DiveListModel *instance(); -- cgit v1.2.3-70-g09d2