mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
6c443ba841
commit
634e26cbce
3 changed files with 37 additions and 175 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue