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>
This commit is contained in:
Berthold Stoeger 2020-06-22 14:05:46 +02:00 committed by Dirk Hohndel
parent 68fffc2672
commit 38b686687f
5 changed files with 12 additions and 14 deletions

View file

@ -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;

View file

@ -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;