summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-02-19 21:39:23 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-01 10:21:44 -0800
commite0766aa4bdd19dbcf538534abc8369aff6a6fa7a (patch)
treeb9fe1a781b66cb4128144a429943fd80564de6cc /qt-models
parentc1e33aac214c331f293e6257c9be509421f77c96 (diff)
downloadsubsurface-e0766aa4bdd19dbcf538534abc8369aff6a6fa7a.tar.gz
filter: introduce people- and tags-filtering in the mobile UI
Add a combo-box where the user can switch between "fulltext", "people" and "tags" filtering. Connect the combobox to the already existing filter-code. Dirk: make combo-box smaller by using a smaller font and restricting the width. Setting both maximum and preferred widths gives more consistent results. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divelistmodel.cpp9
-rw-r--r--qt-models/divelistmodel.h3
2 files changed, 8 insertions, 4 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp
index 05f163505..d1ae4093d 100644
--- a/qt-models/divelistmodel.cpp
+++ b/qt-models/divelistmodel.cpp
@@ -207,13 +207,16 @@ void DiveListSortModel::setSourceModel(QAbstractItemModel *sourceModel)
updateFilterState();
}
-void DiveListSortModel::setFilter(QString f)
+void DiveListSortModel::setFilter(QString f, FilterData::Mode mode)
{
f = f.trimmed();
FilterData data;
if (!f.isEmpty()) {
- data.mode = FilterData::Mode::FULLTEXT;
- data.fullText = f;
+ data.mode = mode;
+ if (mode == FilterData::Mode::FULLTEXT)
+ data.fullText = f;
+ else
+ data.tags = f.split(",", QString::SkipEmptyParts);
}
DiveFilter::instance()->setFilter(data);
CollapsedDiveListSortModel::instance()->updateFilterState();
diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h
index f09003b5f..b051605ae 100644
--- a/qt-models/divelistmodel.h
+++ b/qt-models/divelistmodel.h
@@ -5,6 +5,7 @@
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
+#include "core/divefilter.h"
#include "core/subsurface-qt/diveobjecthelper.h"
class CollapsedDiveListSortModel : public QSortFilterProxyModel
@@ -48,7 +49,7 @@ public:
void updateFilterState();
public slots:
int getIdxForId(int id);
- void setFilter(QString f);
+ void setFilter(QString f, FilterData::Mode mode);
void resetFilter();
int shown();
protected: