summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-22 00:05:52 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-24 10:05:27 -0700
commit89784a176efb52558b3fa103401fd7d8d2be0fe5 (patch)
tree5c5e124c30f4ee76103748b02fda2ceac7b3dac8 /core
parent9b8eed7821c7e55c5e2eccd252184a6d2123e3cd (diff)
downloadsubsurface-89784a176efb52558b3fa103401fd7d8d2be0fe5.tar.gz
filter: implement filtering for divemode
This only checks the first divecomputer as the semantics for multiple dive computers with different dive modes are not clear. Should we check them all? The implementation is a bit hackish: the indexes [0...n] of the combobox are mapped onto [-1...n-1], where -1 means don't filter and n-1 is the last valid dive mode. Implements #2329 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/divefilter.cpp4
-rw-r--r--core/divefilter.h1
2 files changed, 5 insertions, 0 deletions
diff --git a/core/divefilter.cpp b/core/divefilter.cpp
index ed8e30f5f..89fbd731d 100644
--- a/core/divefilter.cpp
+++ b/core/divefilter.cpp
@@ -349,6 +349,10 @@ bool DiveFilter::showDive(const struct dive *d) const
if (!filterData.planned && !has_planned(d, false))
return false;
+ // Dive mode
+ if (filterData.diveMode >= 0 && d->dc.divemode != (divemode_t)filterData.diveMode)
+ return false;
+
return true;
}
diff --git a/core/divefilter.h b/core/divefilter.h
index ae5ba9869..37024be47 100644
--- a/core/divefilter.h
+++ b/core/divefilter.h
@@ -101,6 +101,7 @@ struct FilterData {
StringFilterMode equipmentStringMode = StringFilterMode::SUBSTRING;
bool logged = true;
bool planned = true;
+ int diveMode = -1; // -1: don't filter, >= 0: corresponds to divemode_t
};
class DiveFilter {