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
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "qt-models/divelistmodel.h"
|
#include "qt-models/divelistmodel.h"
|
||||||
|
#include "core/divefilter.h"
|
||||||
#include "core/divesite.h"
|
#include "core/divesite.h"
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "core/trip.h"
|
#include "core/trip.h"
|
||||||
|
@ -193,18 +194,7 @@ DiveListSortModel *DiveListSortModel::instance()
|
||||||
|
|
||||||
void DiveListSortModel::updateFilterState()
|
void DiveListSortModel::updateFilterState()
|
||||||
{
|
{
|
||||||
if (filterString.isEmpty()) {
|
DiveFilter::instance()->updateAll();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveListSortModel::setSourceModel(QAbstractItemModel *sourceModel)
|
void DiveListSortModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||||
|
@ -219,7 +209,13 @@ void DiveListSortModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||||
|
|
||||||
void DiveListSortModel::setFilter(QString f)
|
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();
|
CollapsedDiveListSortModel::instance()->updateFilterState();
|
||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue