summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-13 12:35:12 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-13 12:35:12 -0800
commitdae76cdc2dad1ec49520c6cb23530adaa5a6134a (patch)
treef03a2d606c387d5debf554389290894ce211606f
parent01cd09c77a4be0ea7072e0cefac62f07c4a29c27 (diff)
downloadsubsurface-dae76cdc2dad1ec49520c6cb23530adaa5a6134a.tar.gz
Add a function to count dives with a specific suit
Checking against the location field probably wasn't the best way to do this... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--dive.c14
-rw-r--r--dive.h1
-rw-r--r--qt-ui/filtermodels.cpp2
3 files changed, 16 insertions, 1 deletions
diff --git a/dive.c b/dive.c
index 67f08f972..5705921fc 100644
--- a/dive.c
+++ b/dive.c
@@ -2541,6 +2541,20 @@ int count_dives_with_location(const char *location)
return counter;
}
+// count the dives with exactly the suit
+int count_dives_with_suit(const char *suit)
+{
+ int i, counter = 0;
+ struct dive *d;
+
+ for_each_dive (i, d) {
+ if (same_string(d->suit, suit))
+ counter++;
+ }
+ return counter;
+}
+
+
struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer_downloaded)
{
struct dive *res = alloc_dive();
diff --git a/dive.h b/dive.h
index c745255a3..321606dcf 100644
--- a/dive.h
+++ b/dive.h
@@ -237,6 +237,7 @@ bool taglist_contains(struct tag_entry *tag_list, const char *tag);
int count_dives_with_tag(const char *tag);
int count_dives_with_person(const char *person);
int count_dives_with_location(const char *location);
+int count_dives_with_suit(const char *suit);
struct extra_data {
const char *key;
diff --git a/qt-ui/filtermodels.cpp b/qt-ui/filtermodels.cpp
index edd62cb49..2f19233e1 100644
--- a/qt-ui/filtermodels.cpp
+++ b/qt-ui/filtermodels.cpp
@@ -67,7 +67,7 @@ CREATE_DATA_METHOD( CLASS, COUNTER_FUNCTION )
CREATE_COMMON_METHODS_FOR_FILTER(TagFilterModel, count_dives_with_tag);
CREATE_COMMON_METHODS_FOR_FILTER(BuddyFilterModel, count_dives_with_person);
CREATE_COMMON_METHODS_FOR_FILTER(LocationFilterModel, count_dives_with_location);
-CREATE_COMMON_METHODS_FOR_FILTER(SuitsFilterModel, count_dives_with_location);
+CREATE_COMMON_METHODS_FOR_FILTER(SuitsFilterModel, count_dives_with_suit);
CREATE_INSTANCE_METHOD(MultiFilterSortModel);