aboutsummaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-12 16:01:58 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-12 16:02:37 -0800
commit61dc19d2e0bc69004b03a990993eda547f4e0093 (patch)
tree0cb4af2322199c5ef65bf1083d8a3f4c2e7ac083 /dive.c
parent5a329ff26295717181dd99b22dab5b6b1e80d821 (diff)
downloadsubsurface-61dc19d2e0bc69004b03a990993eda547f4e0093.tar.gz
Show the number of dives with given person / location in the filter panel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/dive.c b/dive.c
index d20c11b68..67f08f972 100644
--- a/dive.c
+++ b/dive.c
@@ -2500,6 +2500,7 @@ bool taglist_contains(struct tag_entry *tag_list, const char *tag)
return false;
}
+// count the dives where the tag list contains the given tag
int count_dives_with_tag(const char *tag)
{
int i, counter = 0;
@@ -2512,6 +2513,34 @@ int count_dives_with_tag(const char *tag)
return counter;
}
+extern bool string_sequence_contains(const char *string_sequence, const char *text);
+
+// count the dives where the person is included in the comma separated string sequences of buddies or divemasters
+int count_dives_with_person(const char *person)
+{
+ int i, counter = 0;
+ struct dive *d;
+
+ for_each_dive (i, d) {
+ if (string_sequence_contains(d->buddy, person) || string_sequence_contains(d->divemaster, person))
+ counter++;
+ }
+ return counter;
+}
+
+// count the dives with exactly the location
+int count_dives_with_location(const char *location)
+{
+ int i, counter = 0;
+ struct dive *d;
+
+ for_each_dive (i, d) {
+ if (same_string(d->location, location))
+ counter++;
+ }
+ return counter;
+}
+
struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer_downloaded)
{
struct dive *res = alloc_dive();