diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-02-19 20:14:32 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-03-01 10:21:44 -0800 |
commit | 8cb43ed237f0ecfe14024e8f9ac8761d2e0ddfd8 (patch) | |
tree | e480156e9fe85eee88743ffbb409713c2cb1c0d8 /qt-models | |
parent | fd7dd5421b1af258831b9c834e32f27ebd976472 (diff) | |
download | subsurface-8cb43ed237f0ecfe14024e8f9ac8761d2e0ddfd8.tar.gz |
filter: use DiveFilter on mobile
Use the DiveFilter class on mobile to update the filter. This
is mostly for convergence of the mobile and desktop models.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divelistmodel.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index ffcde5d4a..05f163505 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "qt-models/divelistmodel.h" +#include "core/divefilter.h" #include "core/divesite.h" #include "core/qthelper.h" #include "core/trip.h" @@ -193,18 +194,7 @@ DiveListSortModel *DiveListSortModel::instance() void DiveListSortModel::updateFilterState() { - if (filterString.isEmpty()) { - resetFilter(); - return; - } - // store this in local variables to avoid having to call these methods over and over - bool includeNotes = qPrefGeneral::filterFullTextNotes(); - Qt::CaseSensitivity cs = qPrefGeneral::filterCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive; - - int i; - struct dive *d; - for_each_dive(i, d) - d->hidden_by_filter = !diveContainsText(d, filterString, cs, includeNotes); + DiveFilter::instance()->updateAll(); } void DiveListSortModel::setSourceModel(QAbstractItemModel *sourceModel) @@ -219,7 +209,13 @@ void DiveListSortModel::setSourceModel(QAbstractItemModel *sourceModel) void DiveListSortModel::setFilter(QString f) { - filterString = f; + f = f.trimmed(); + FilterData data; + if (!f.isEmpty()) { + data.mode = FilterData::Mode::FULLTEXT; + data.fullText = f; + } + DiveFilter::instance()->setFilter(data); CollapsedDiveListSortModel::instance()->updateFilterState(); invalidateFilter(); } |