summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-06-22 14:05:46 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-09-29 16:13:03 -0700
commit38b686687faed3f8f60828105a2036d5f4e48db6 (patch)
tree5bbaa2f97566bb01a77a38906304470f62d9ae94 /core
parent68fffc267212470f6d5eb218744b29a851f61cc2 (diff)
downloadsubsurface-38b686687faed3f8f60828105a2036d5f4e48db6.tar.gz
cleanup: move shown-text calculation from filter widget to core
The filter widget was caching whether the filter was active and used that flag to calculate the "# dives shown" string. Move this directly to the DiveFilter class to remove interdependencies and to unify with mobile. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/divefilter.cpp9
-rw-r--r--core/divefilter.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/core/divefilter.cpp b/core/divefilter.cpp
index 5765ed673..9f54f5cca 100644
--- a/core/divefilter.cpp
+++ b/core/divefilter.cpp
@@ -2,6 +2,7 @@
#include "divefilter.h"
#include "divelist.h" // for filter_dive
+#include "gettextfromc.h"
#include "qthelper.h"
#include "subsurface-qt/divelistnotifier.h"
#ifndef SUBSURFACE_MOBILE
@@ -151,6 +152,14 @@ bool DiveFilter::diveSiteMode() const
}
#endif
+QString DiveFilter::shownText() const
+{
+ if (diveSiteMode() || filterData.validFilter())
+ return gettextFromC::tr("%L1/%L2 shown").arg(shown_dives).arg(dive_table.nr);
+ else
+ return gettextFromC::tr("%L1 dives").arg(dive_table.nr);
+}
+
void DiveFilter::setFilter(const FilterData &data)
{
filterData = data;
diff --git a/core/divefilter.h b/core/divefilter.h
index a0c9b5d2f..3ebb049ef 100644
--- a/core/divefilter.h
+++ b/core/divefilter.h
@@ -38,6 +38,7 @@ class DiveFilter {
public:
static DiveFilter *instance();
+ QString shownText() const;
bool diveSiteMode() const; // returns true if we're filtering on dive site (on mobile always returns false)
#ifndef SUBSURFACE_MOBILE
const QVector<dive_site *> &filteredDiveSites() const;