aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/divefilter.cpp20
-rw-r--r--core/divefilter.h23
2 files changed, 22 insertions, 21 deletions
diff --git a/core/divefilter.cpp b/core/divefilter.cpp
index 7f47e45ac..1372f5a0f 100644
--- a/core/divefilter.cpp
+++ b/core/divefilter.cpp
@@ -73,16 +73,16 @@ namespace {
// Check whether either all, any or none of the items of the first list is
// in the second list as a super string.
// The mode is controlled by the second argument
- bool check(const QStringList &items, const QStringList &list, FilterData::Mode mode, FilterData::StringMode stringMode)
+ bool check(const QStringList &items, const QStringList &list, FilterData::Mode mode, StringFilterMode stringMode)
{
bool negate = mode == FilterData::Mode::NONE_OF;
bool any_of = mode == FilterData::Mode::ANY_OF;
StrCheck strchk =
- stringMode == FilterData::StringMode::SUBSTRING ?
+ stringMode == StringFilterMode::SUBSTRING ?
[](const QString &s1, const QString &s2) { return s1.contains(s2, Qt::CaseInsensitive); } :
- stringMode == FilterData::StringMode::STARTSWITH ?
+ stringMode == StringFilterMode::STARTSWITH ?
[](const QString &s1, const QString &s2) { return s1.startsWith(s2, Qt::CaseInsensitive); } :
- /* FilterData::StringMode::EXACT */
+ /* StringFilterMode::EXACT */
[](const QString &s1, const QString &s2) { return s1.compare(s2, Qt::CaseInsensitive) == 0; };
auto fun = [&list, negate, strchk](const QString &item)
{ return listContainsSuperstring(list, item, strchk) != negate; };
@@ -90,7 +90,7 @@ namespace {
: std::all_of(items.begin(), items.end(), fun);
}
- bool hasTags(const QStringList &tags, const struct dive *d, FilterData::Mode mode, FilterData::StringMode stringMode)
+ bool hasTags(const QStringList &tags, const struct dive *d, FilterData::Mode mode, StringFilterMode stringMode)
{
if (tags.isEmpty())
return true;
@@ -99,7 +99,7 @@ namespace {
return check(tags, dive_tags, mode, stringMode);
}
- bool hasPersons(const QStringList &people, const struct dive *d, FilterData::Mode mode, FilterData::StringMode stringMode)
+ bool hasPersons(const QStringList &people, const struct dive *d, FilterData::Mode mode, StringFilterMode stringMode)
{
if (people.isEmpty())
return true;
@@ -108,7 +108,7 @@ namespace {
return check(people, dive_people, mode, stringMode);
}
- bool hasLocations(const QStringList &locations, const struct dive *d, FilterData::Mode mode, FilterData::StringMode stringMode)
+ bool hasLocations(const QStringList &locations, const struct dive *d, FilterData::Mode mode, StringFilterMode stringMode)
{
if (locations.isEmpty())
return true;
@@ -123,12 +123,12 @@ namespace {
}
// TODO: Finish this implementation.
- bool hasEquipment(const QStringList &, const struct dive *, FilterData::Mode, FilterData::StringMode)
+ bool hasEquipment(const QStringList &, const struct dive *, FilterData::Mode, StringFilterMode)
{
return true;
}
- bool hasSuits(const QStringList &suits, const struct dive *d, FilterData::Mode mode, FilterData::StringMode stringMode)
+ bool hasSuits(const QStringList &suits, const struct dive *d, FilterData::Mode mode, StringFilterMode stringMode)
{
if (suits.isEmpty())
return true;
@@ -138,7 +138,7 @@ namespace {
return check(suits, diveSuits, mode, stringMode);
}
- bool hasNotes(const QStringList &dnotes, const struct dive *d, FilterData::Mode mode, FilterData::StringMode stringMode)
+ bool hasNotes(const QStringList &dnotes, const struct dive *d, FilterData::Mode mode, StringFilterMode stringMode)
{
if (dnotes.isEmpty())
return true;
diff --git a/core/divefilter.h b/core/divefilter.h
index aa166d022..129fe0888 100644
--- a/core/divefilter.h
+++ b/core/divefilter.h
@@ -13,6 +13,12 @@ struct ShownChange {
bool currentChanged;
};
+enum class StringFilterMode {
+ SUBSTRING = 0,
+ STARTSWITH = 1,
+ EXACT = 2
+};
+
// The dive filter for mobile is currently much simpler than for desktop.
// Therefore, for now we have two completely separate implementations.
// This should be unified in the future.
@@ -43,11 +49,6 @@ struct FilterData {
ANY_OF = 1,
NONE_OF = 2
};
- enum class StringMode {
- SUBSTRING = 0,
- STARTSWITH = 1,
- EXACT = 2
- };
bool validFilter = false;
int minVisibility = 0;
@@ -77,12 +78,12 @@ struct FilterData {
Mode dnotesMode = Mode::ALL_OF;
Mode suitMode = Mode::ANY_OF;
Mode equipmentMode = Mode::ALL_OF;
- StringMode tagsStringMode = StringMode::SUBSTRING;
- StringMode peopleStringMode = StringMode::SUBSTRING;
- StringMode locationStringMode = StringMode::SUBSTRING;
- StringMode dnotesStringMode = StringMode::SUBSTRING;
- StringMode suitStringMode = StringMode::SUBSTRING;
- StringMode equipmentStringMode = StringMode::SUBSTRING;
+ StringFilterMode tagsStringMode = StringFilterMode::SUBSTRING;
+ StringFilterMode peopleStringMode = StringFilterMode::SUBSTRING;
+ StringFilterMode locationStringMode = StringFilterMode::SUBSTRING;
+ StringFilterMode dnotesStringMode = StringFilterMode::SUBSTRING;
+ StringFilterMode suitStringMode = StringFilterMode::SUBSTRING;
+ StringFilterMode equipmentStringMode = StringFilterMode::SUBSTRING;
bool logged = true;
bool planned = true;
};