From 8a394b9db42a21f684c6ae85005a55c29d060c38 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 14 Aug 2018 14:09:30 -0400 Subject: 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 --- qt-models/filtermodels.cpp | 8 ++++---- qt-models/filtermodels.h | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'qt-models') diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index bd95e0ad9..6e5605654 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -132,7 +132,7 @@ int SuitsFilterModel::countDives(const char *s) const 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 // let's handle it gracefully anyway. @@ -196,7 +196,7 @@ void TagFilterModel::repopulate() updateList(list); } -bool TagFilterModel::doFilter(dive *d) const +bool TagFilterModel::doFilter(const dive *d) const { // If there's nothing checked, this should show everything // 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); } -bool BuddyFilterModel::doFilter(dive *d) const +bool BuddyFilterModel::doFilter(const dive *d) const { // If there's nothing checked, this should show everything // 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); } -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 // let's handle it gracefully anyway. diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h index 2ccfec010..0c35f2612 100644 --- a/qt-models/filtermodels.h +++ b/qt-models/filtermodels.h @@ -7,10 +7,12 @@ #include #include +struct dive; + class FilterModelBase : public QStringListModel { Q_OBJECT public: - virtual bool doFilter(struct dive *d) const = 0; + virtual bool doFilter(const dive *d) const = 0; void clearFilter(); void selectAll(); void invertSelection(); @@ -34,7 +36,7 @@ class TagFilterModel : public FilterModelBase { Q_OBJECT public: static TagFilterModel *instance(); - bool doFilter(struct dive *d) const; + bool doFilter(const dive *d) const; public slots: void repopulate(); @@ -48,7 +50,7 @@ class BuddyFilterModel : public FilterModelBase { Q_OBJECT public: static BuddyFilterModel *instance(); - bool doFilter(struct dive *d) const; + bool doFilter(const dive *d) const; public slots: void repopulate(); @@ -62,7 +64,7 @@ class LocationFilterModel : public FilterModelBase { Q_OBJECT public: static LocationFilterModel *instance(); - bool doFilter(struct dive *d) const; + bool doFilter(const dive *d) const; public slots: void repopulate(); @@ -78,7 +80,7 @@ class SuitsFilterModel : public FilterModelBase { Q_OBJECT public: static SuitsFilterModel *instance(); - bool doFilter(struct dive *d) const; + bool doFilter(const dive *d) const; public slots: void repopulate(); -- cgit v1.2.3-70-g09d2