mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
fd7dd5421b
commit
8cb43ed237
1 changed files with 9 additions and 13 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue