mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Filter: constify doFilter() argument
Conceptually, the doFilter() functions shouldn't modify the dive they test. Therefore, make the argument const. To do this, constify the parameter of get_dive_location(), which likewise seems to be the right thing to do. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
fb47c15cd8
commit
8a394b9db4
4 changed files with 14 additions and 12 deletions
|
|
@ -4202,9 +4202,9 @@ const char *get_dive_country(struct dive *dive)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *get_dive_location(struct dive *dive)
|
const char *get_dive_location(const struct dive *dive)
|
||||||
{
|
{
|
||||||
struct dive_site *ds = get_dive_site_by_uuid(dive->dive_site_uuid);
|
const struct dive_site *ds = get_dive_site_by_uuid(dive->dive_site_uuid);
|
||||||
if (ds && ds->name)
|
if (ds && ds->name)
|
||||||
return ds->name;
|
return ds->name;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,7 @@ extern struct dive *get_dive(int nr);
|
||||||
extern struct dive *get_dive_from_table(int nr, struct dive_table *dt);
|
extern struct dive *get_dive_from_table(int nr, struct dive_table *dt);
|
||||||
extern struct dive_site *get_dive_site_for_dive(struct dive *dive);
|
extern struct dive_site *get_dive_site_for_dive(struct dive *dive);
|
||||||
extern const char *get_dive_country(struct dive *dive);
|
extern const char *get_dive_country(struct dive *dive);
|
||||||
extern char *get_dive_location(struct dive *dive);
|
extern const char *get_dive_location(const struct dive *dive);
|
||||||
extern unsigned int number_of_computers(struct dive *dive);
|
extern unsigned int number_of_computers(struct dive *dive);
|
||||||
extern struct divecomputer *get_dive_dc(struct dive *dive, int nr);
|
extern struct divecomputer *get_dive_dc(struct dive *dive, int nr);
|
||||||
extern timestamp_t dive_endtime(const struct dive *dive);
|
extern timestamp_t dive_endtime(const struct dive *dive);
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ int SuitsFilterModel::countDives(const char *s) const
|
||||||
return count_dives_with_suit(s);
|
return count_dives_with_suit(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SuitsFilterModel::doFilter(dive *d) const
|
bool SuitsFilterModel::doFilter(const dive *d) const
|
||||||
{
|
{
|
||||||
// rowCount() == 0 should never happen, because we have the "no suits" row
|
// rowCount() == 0 should never happen, because we have the "no suits" row
|
||||||
// let's handle it gracefully anyway.
|
// let's handle it gracefully anyway.
|
||||||
|
|
@ -196,7 +196,7 @@ void TagFilterModel::repopulate()
|
||||||
updateList(list);
|
updateList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TagFilterModel::doFilter(dive *d) const
|
bool TagFilterModel::doFilter(const dive *d) const
|
||||||
{
|
{
|
||||||
// If there's nothing checked, this should show everything
|
// If there's nothing checked, this should show everything
|
||||||
// rowCount() == 0 should never happen, because we have the "no tags" row
|
// rowCount() == 0 should never happen, because we have the "no tags" row
|
||||||
|
|
@ -234,7 +234,7 @@ int BuddyFilterModel::countDives(const char *s) const
|
||||||
return count_dives_with_person(s);
|
return count_dives_with_person(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BuddyFilterModel::doFilter(dive *d) const
|
bool BuddyFilterModel::doFilter(const dive *d) const
|
||||||
{
|
{
|
||||||
// If there's nothing checked, this should show everything
|
// If there's nothing checked, this should show everything
|
||||||
// rowCount() == 0 should never happen, because we have the "no tags" row
|
// rowCount() == 0 should never happen, because we have the "no tags" row
|
||||||
|
|
@ -289,7 +289,7 @@ int LocationFilterModel::countDives(const char *s) const
|
||||||
return count_dives_with_location(s);
|
return count_dives_with_location(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocationFilterModel::doFilter(struct dive *d) const
|
bool LocationFilterModel::doFilter(const dive *d) const
|
||||||
{
|
{
|
||||||
// rowCount() == 0 should never happen, because we have the "no location" row
|
// rowCount() == 0 should never happen, because we have the "no location" row
|
||||||
// let's handle it gracefully anyway.
|
// let's handle it gracefully anyway.
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,12 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
struct dive;
|
||||||
|
|
||||||
class FilterModelBase : public QStringListModel {
|
class FilterModelBase : public QStringListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
virtual bool doFilter(struct dive *d) const = 0;
|
virtual bool doFilter(const dive *d) const = 0;
|
||||||
void clearFilter();
|
void clearFilter();
|
||||||
void selectAll();
|
void selectAll();
|
||||||
void invertSelection();
|
void invertSelection();
|
||||||
|
|
@ -34,7 +36,7 @@ class TagFilterModel : public FilterModelBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static TagFilterModel *instance();
|
static TagFilterModel *instance();
|
||||||
bool doFilter(struct dive *d) const;
|
bool doFilter(const dive *d) const;
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void repopulate();
|
void repopulate();
|
||||||
|
|
@ -48,7 +50,7 @@ class BuddyFilterModel : public FilterModelBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static BuddyFilterModel *instance();
|
static BuddyFilterModel *instance();
|
||||||
bool doFilter(struct dive *d) const;
|
bool doFilter(const dive *d) const;
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void repopulate();
|
void repopulate();
|
||||||
|
|
@ -62,7 +64,7 @@ class LocationFilterModel : public FilterModelBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static LocationFilterModel *instance();
|
static LocationFilterModel *instance();
|
||||||
bool doFilter(struct dive *d) const;
|
bool doFilter(const dive *d) const;
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void repopulate();
|
void repopulate();
|
||||||
|
|
@ -78,7 +80,7 @@ class SuitsFilterModel : public FilterModelBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static SuitsFilterModel *instance();
|
static SuitsFilterModel *instance();
|
||||||
bool doFilter(struct dive *d) const;
|
bool doFilter(const dive *d) const;
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void repopulate();
|
void repopulate();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue