diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-06-01 23:37:36 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-09-29 16:13:03 -0700 |
commit | 634e26cbcea064d6ef3d7550dacf54196547bedb (patch) | |
tree | 39ac7894854c770396e8719bf67239d4147e9a7f /mobile-widgets/qmlmanager.cpp | |
parent | 6c443ba8411fb9f019be10e061878f7c9566f560 (diff) | |
download | subsurface-634e26cbcea064d6ef3d7550dacf54196547bedb.tar.gz |
filter: unify desktop and mobile filters
Switch the mobile code to use the constraint-based filter. The one
thing that is still commented out is dive-site mode, since mobile
doesn't (yet) have a dive-site edit feature. And even if it had,
the dive list probably wouldn't be shown at the same time.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 648532d7d..19057fef9 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -29,6 +29,7 @@ #include "core/errorhelper.h" #include "core/file.h" #include "core/divefilter.h" +#include "core/filterconstraint.h" #include "core/qthelper.h" #include "core/qt-gui.h" #include "core/git-access.h" @@ -2084,6 +2085,13 @@ void QMLManager::restartDownload(QAndroidJniObject usbDevice) #endif +static filter_constraint make_filter_constraint(filter_constraint_type type, const QString &s) +{ + filter_constraint res(type); + filter_constraint_set_stringlist(res, s); + return res; +} + void QMLManager::setFilter(const QString filterText, int index) { QString f = filterText.trimmed(); @@ -2091,15 +2099,17 @@ void QMLManager::setFilter(const QString filterText, int index) if (!f.isEmpty()) { // This is ugly - the indices of the mode are hardcoded! switch(index) { - default: - case 0: data.mode = FilterData::Mode::FULLTEXT; break; - case 1: data.mode = FilterData::Mode::PEOPLE; break; - case 2: data.mode = FilterData::Mode::TAGS; break; - } - if (data.mode == FilterData::Mode::FULLTEXT) + default: + case 0: data.fullText = f; - else - data.tags = f.split(",", QString::SkipEmptyParts); + break; + case 1: + data.constraints.push_back(make_filter_constraint(FILTER_CONSTRAINT_PEOPLE, f)); + break; + case 2: + data.constraints.push_back(make_filter_constraint(FILTER_CONSTRAINT_TAGS, f)); + break; + } } DiveFilter::instance()->setFilter(data); } |