summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-10-30 21:46:01 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-12-29 08:34:09 -0800
commit9e84fd935bd68ef667426d92f3c27b3aab58649a (patch)
treedd8ce62d0968bdf390b60d00199f0cf44240b4f5 /core
parente80c0d2c60e53071632095322845c32c80767f6f (diff)
downloadsubsurface-9e84fd935bd68ef667426d92f3c27b3aab58649a.tar.gz
filter: keep track on shown_dive on dive removal in DiveFilter
When removing dives, the UndoCommands would keep track of the shown dives. When adding, they were calling into the filter instead. Let's remove this asymmetry. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/divefilter.cpp6
-rw-r--r--core/divefilter.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/core/divefilter.cpp b/core/divefilter.cpp
index 4c40869f5..cdf74a49f 100644
--- a/core/divefilter.cpp
+++ b/core/divefilter.cpp
@@ -101,6 +101,12 @@ DiveFilter::DiveFilter() : diveSiteRefCount(0)
{
}
+void DiveFilter::diveRemoved(const dive *d) const
+{
+ if (!d->hidden_by_filter)
+ --shown_dives;
+}
+
bool DiveFilter::showDive(const struct dive *d) const
{
if (d->invalid && !prefs.display_invalid_dives)
diff --git a/core/divefilter.h b/core/divefilter.h
index 608cf4843..84c9efee2 100644
--- a/core/divefilter.h
+++ b/core/divefilter.h
@@ -51,6 +51,7 @@ public:
void setFilter(const FilterData &data);
ShownChange update(const QVector<dive *> &dives) const; // Update filter status of given dives and return dives whose status changed
ShownChange updateAll() const; // Update filter status of all dives and return dives whose status changed
+ void diveRemoved(const dive *dive) const; // Dive was removed; update count accordingly
private:
DiveFilter();
bool showDive(const struct dive *d) const; // Should that dive be shown?