mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
filter: move shown_dive from divelist.c to divefilter.cpp
Arguably, the number of filtered dives is a matter of the divefilter. Let's move it there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9e84fd935b
commit
51d0c42a5c
5 changed files with 24 additions and 22 deletions
|
@ -1,9 +1,10 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include "divefilter.h"
|
||||
#include "divelist.h" // for filter_dive
|
||||
#include "divelist.h"
|
||||
#include "gettextfromc.h"
|
||||
#include "qthelper.h"
|
||||
#include "selection.h"
|
||||
#include "subsurface-qt/divelistnotifier.h"
|
||||
#if !defined(SUBSURFACE_MOBILE) && !defined(SUBSURFACE_DOWNLOADER)
|
||||
#include "desktop-widgets/mapwidget.h"
|
||||
|
@ -12,9 +13,27 @@
|
|||
#include "qt-models/filtermodels.h"
|
||||
#endif
|
||||
|
||||
int shown_dives = 0;
|
||||
|
||||
// Set filter status of dive and return whether it has been changed
|
||||
static bool setFilterStatus(struct dive *d, bool shown)
|
||||
{
|
||||
bool old_shown, changed;
|
||||
if (!d)
|
||||
return false;
|
||||
old_shown = !d->hidden_by_filter;
|
||||
d->hidden_by_filter = !shown;
|
||||
if (!shown && d->selected)
|
||||
deselect_dive(d);
|
||||
changed = old_shown != shown;
|
||||
if (changed)
|
||||
shown_dives += shown - old_shown;
|
||||
return changed;
|
||||
}
|
||||
|
||||
static void updateDiveStatus(dive *d, bool newStatus, ShownChange &change)
|
||||
{
|
||||
if (filter_dive(d, newStatus)) {
|
||||
if (setFilterStatus(d, newStatus)) {
|
||||
if (newStatus)
|
||||
change.newShown.push_back(d);
|
||||
else
|
||||
|
|
|
@ -13,6 +13,8 @@ struct dive;
|
|||
struct dive_trip;
|
||||
struct dive_site;
|
||||
|
||||
extern int shown_dives;
|
||||
|
||||
// Structure describing changes of shown status upon applying the filter
|
||||
struct ShownChange {
|
||||
QVector<dive *> newShown;
|
||||
|
|
|
@ -786,22 +786,6 @@ void delete_single_dive(int idx)
|
|||
delete_dive_from_table(&dive_table, idx);
|
||||
}
|
||||
|
||||
int shown_dives = 0;
|
||||
bool filter_dive(struct dive *d, bool shown)
|
||||
{
|
||||
bool old_shown, changed;
|
||||
if (!d)
|
||||
return false;
|
||||
old_shown = !d->hidden_by_filter;
|
||||
d->hidden_by_filter = !shown;
|
||||
if (!shown && d->selected)
|
||||
deselect_dive(d);
|
||||
changed = old_shown != shown;
|
||||
if (changed)
|
||||
shown_dives += shown - old_shown;
|
||||
return changed;
|
||||
}
|
||||
|
||||
void process_loaded_dives()
|
||||
{
|
||||
int i;
|
||||
|
@ -1375,7 +1359,6 @@ void clear_dive_file_data()
|
|||
while (dive_table.nr)
|
||||
delete_single_dive(0);
|
||||
current_dive = NULL;
|
||||
shown_dives = 0;
|
||||
while (dive_site_table.nr)
|
||||
delete_dive_site(get_dive_site(0, &dive_site_table), &dive_site_table);
|
||||
if (trip_table.nr != 0) {
|
||||
|
|
|
@ -13,7 +13,6 @@ struct trip_table;
|
|||
struct dive_site_table;
|
||||
struct device_table;
|
||||
struct deco_state;
|
||||
extern int shown_dives;
|
||||
|
||||
struct dive_table {
|
||||
int nr, allocated;
|
||||
|
@ -53,7 +52,6 @@ extern void insert_dive(struct dive_table *table, struct dive *d);
|
|||
extern void get_dive_gas(const struct dive *dive, int *o2_p, int *he_p, int *o2low_p);
|
||||
extern int get_divenr(const struct dive *dive);
|
||||
extern int remove_dive(const struct dive *dive, struct dive_table *table);
|
||||
extern bool filter_dive(struct dive *d, bool shown); /* returns true if status changed */
|
||||
extern int get_dive_nr_at_idx(int idx);
|
||||
extern void set_dive_nr_for_current_dive();
|
||||
extern timestamp_t get_surface_interval(timestamp_t when);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "mobilelistmodel.h"
|
||||
#include "core/divelist.h" // for shown_dives
|
||||
#include "core/divefilter.h" // for shown_dives
|
||||
|
||||
MobileListModelBase::MobileListModelBase(DiveTripModelBase *sourceIn) : source(sourceIn)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue