diff options
-rw-r--r-- | divesite.c | 13 | ||||
-rw-r--r-- | divesite.h | 1 | ||||
-rw-r--r-- | qt-ui/modeldelegates.cpp | 4 |
3 files changed, 17 insertions, 1 deletions
diff --git a/divesite.c b/divesite.c index 8bc9e04f7..4348461c6 100644 --- a/divesite.c +++ b/divesite.c @@ -108,6 +108,19 @@ struct dive_site *alloc_dive_site() return ds; } +int nr_of_dives_at_dive_site(uint32_t uuid, bool select_only) +{ + int j; + int nr = 0; + struct dive *d; + for_each_dive(j, d) { + if (d->dive_site_uuid == uuid && (!select_only || d->selected)) { + nr++; + } + } + return nr; +} + bool is_dive_site_used(uint32_t uuid, bool select_only) { int j; diff --git a/divesite.h b/divesite.h index 7dab210f1..d1d6ba9ae 100644 --- a/divesite.h +++ b/divesite.h @@ -50,6 +50,7 @@ static inline struct dive_site *get_dive_site_by_uuid(uint32_t uuid) } struct dive_site *alloc_dive_site(); +int nr_of_dives_at_dive_site(uint32_t uuid, bool select_only); bool is_dive_site_used(uint32_t uuid, bool select_only); void delete_dive_site(uint32_t id); uint32_t create_dive_site(const char *name); diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 4078621ab..6f792398f 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -542,7 +542,9 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem } else { int distanceMeters = get_distance(ds->latitude, ds->longitude, displayed_dive_site.latitude, displayed_dive_site.longitude); QString distance = distance_string(distanceMeters); - bottomText += tr(" (~%1 away)").arg(distance); + int nr = nr_of_dives_at_dive_site(ds->uuid, false); + bottomText += tr(" (~%1 away").arg(distance); + bottomText += tr(", %n dive(s) here)", 0, nr); } } if (bottomText.isEmpty()) { |