summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-23 18:31:39 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-29 00:09:31 +0000
commit14ab95608cc0694caff580825666d2009177e0a2 (patch)
treeb620ffcf6e48e25cc04764fc1fde00ffffc89465
parentd3a7c5448fe166444980ed41757c9e03d83ece2f (diff)
downloadsubsurface-14ab95608cc0694caff580825666d2009177e0a2.tar.gz
Dive site: pass dive-site pointer to nr_of_dives_at_dive_site()
Instead of passing a uuid, pass a pointer to the dive site. This is small step in an effort to remove uuids. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--core/divesite.c6
-rw-r--r--core/divesite.h2
-rw-r--r--desktop-widgets/modeldelegates.cpp2
3 files changed, 6 insertions, 4 deletions
diff --git a/core/divesite.c b/core/divesite.c
index f6e96e3c5..437605b71 100644
--- a/core/divesite.c
+++ b/core/divesite.c
@@ -130,13 +130,15 @@ struct dive_site *alloc_or_get_dive_site(uint32_t uuid)
return ds;
}
-int nr_of_dives_at_dive_site(uint32_t uuid, bool select_only)
+int nr_of_dives_at_dive_site(struct dive_site *ds, bool select_only)
{
int j;
int nr = 0;
struct dive *d;
+ if (!ds)
+ return 0;
for_each_dive(j, d) {
- if (d->dive_site_uuid == uuid && (!select_only || d->selected)) {
+ if (d->dive_site_uuid == ds->uuid && (!select_only || d->selected)) {
nr++;
}
}
diff --git a/core/divesite.h b/core/divesite.h
index 0b21d69af..f5754f5da 100644
--- a/core/divesite.h
+++ b/core/divesite.h
@@ -54,7 +54,7 @@ static inline struct dive_site *get_dive_site_by_uuid(uint32_t uuid)
void dive_site_table_sort();
struct dive_site *alloc_or_get_dive_site(uint32_t uuid);
-int nr_of_dives_at_dive_site(uint32_t uuid, bool select_only);
+int nr_of_dives_at_dive_site(struct dive_site *ds, bool select_only);
bool is_dive_site_used(uint32_t uuid, bool select_only);
void free_dive_site(struct dive_site *ds);
void delete_dive_site(uint32_t id);
diff --git a/desktop-widgets/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp
index 842598467..3a1428e02 100644
--- a/desktop-widgets/modeldelegates.cpp
+++ b/desktop-widgets/modeldelegates.cpp
@@ -492,7 +492,7 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
} else {
int distanceMeters = get_distance(&ds->location, &currentDiveSite->location);
QString distance = distance_string(distanceMeters);
- int nr = nr_of_dives_at_dive_site(ds->uuid, false);
+ int nr = nr_of_dives_at_dive_site(ds, false);
bottomText += tr(" (~%1 away").arg(distance);
bottomText += tr(", %n dive(s) here)", "", nr);
}