mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
filter: reset shown_dives in filter
The shown_dives variable was reset by the dive_list code. Arguably, the filter should keep track of the number of shown dives, so move the resetting there. This means adding a new "reset()" member function to the filter and call that instead of "updateAll()" when the core data is reset. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
dea1ef84d5
commit
e80c0d2c60
4 changed files with 15 additions and 8 deletions
|
@ -52,6 +52,16 @@ ShownChange DiveFilter::update(const QVector<dive *> &dives) const
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiveFilter::reset()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
dive *d;
|
||||||
|
shown_dives = dive_table.nr;
|
||||||
|
for_each_dive(i, d)
|
||||||
|
d->hidden_by_filter = false;
|
||||||
|
updateAll();
|
||||||
|
}
|
||||||
|
|
||||||
ShownChange DiveFilter::updateAll() const
|
ShownChange DiveFilter::updateAll() const
|
||||||
{
|
{
|
||||||
dive *old_current = current_dive;
|
dive *old_current = current_dive;
|
||||||
|
|
|
@ -39,6 +39,7 @@ class DiveFilter {
|
||||||
public:
|
public:
|
||||||
static DiveFilter *instance();
|
static DiveFilter *instance();
|
||||||
|
|
||||||
|
void reset();
|
||||||
QString shownText() const;
|
QString shownText() const;
|
||||||
bool diveSiteMode() const; // returns true if we're filtering on dive site (on mobile always returns false)
|
bool diveSiteMode() const; // returns true if we're filtering on dive site (on mobile always returns false)
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
|
|
|
@ -807,13 +807,9 @@ void process_loaded_dives()
|
||||||
int i;
|
int i;
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
|
|
||||||
/* Register dive computer nick names and count shown dives. */
|
/* Register dive computer nick names. */
|
||||||
shown_dives = 0;
|
for_each_dive(i, dive)
|
||||||
for_each_dive(i, dive) {
|
|
||||||
if (!dive->hidden_by_filter)
|
|
||||||
shown_dives++;
|
|
||||||
add_devices_of_dive(dive, &device_table);
|
add_devices_of_dive(dive, &device_table);
|
||||||
}
|
|
||||||
|
|
||||||
sort_dive_table(&dive_table);
|
sort_dive_table(&dive_table);
|
||||||
sort_trip_table(&trip_table);
|
sort_trip_table(&trip_table);
|
||||||
|
|
|
@ -706,7 +706,7 @@ DiveTripModelTree::DiveTripModelTree(QObject *parent) : DiveTripModelBase(parent
|
||||||
|
|
||||||
void DiveTripModelTree::populate()
|
void DiveTripModelTree::populate()
|
||||||
{
|
{
|
||||||
DiveFilter::instance()->updateAll(); // The data was reset - update filter status. TODO: should this really be done here?
|
DiveFilter::instance()->reset(); // The data was reset - update filter status. TODO: should this really be done here?
|
||||||
|
|
||||||
// we want this to be two calls as the second text is overwritten below by the lines starting with "\r"
|
// we want this to be two calls as the second text is overwritten below by the lines starting with "\r"
|
||||||
uiNotification(QObject::tr("populate data model"));
|
uiNotification(QObject::tr("populate data model"));
|
||||||
|
@ -1475,7 +1475,7 @@ DiveTripModelList::DiveTripModelList(QObject *parent) : DiveTripModelBase(parent
|
||||||
|
|
||||||
void DiveTripModelList::populate()
|
void DiveTripModelList::populate()
|
||||||
{
|
{
|
||||||
DiveFilter::instance()->updateAll(); // The data was reset - update filter status. TODO: should this really be done here?
|
DiveFilter::instance()->reset(); // The data was reset - update filter status. TODO: should this really be done here?
|
||||||
|
|
||||||
// Fill model
|
// Fill model
|
||||||
items.reserve(dive_table.nr);
|
items.reserve(dive_table.nr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue