summaryrefslogtreecommitdiffstats
path: root/qt-ui/modeldelegates.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-14 11:35:04 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-14 11:52:17 -0700
commit8c0d0de2e62356e1bbdad97843d185a37973c5c7 (patch)
tree0179eee9ba82a843f676551e61b9886930c9ceab /qt-ui/modeldelegates.cpp
parente82f8ea565a68aa1fa980cb12c1f136b1d4a57f9 (diff)
downloadsubsurface-8c0d0de2e62356e1bbdad97843d185a37973c5c7.tar.gz
Location completer: give distance if known
If both the displayed dive and the dive site which is shown as a potential completion have a GPS fix, indicate the distance. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/modeldelegates.cpp')
-rw-r--r--qt-ui/modeldelegates.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp
index 3357d3909..3e4c860df 100644
--- a/qt-ui/modeldelegates.cpp
+++ b/qt-ui/modeldelegates.cpp
@@ -517,6 +517,18 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
free( (void*) gpsCoords);
}
+ if (dive_site_has_gps_location(ds) && dive_site_has_gps_location(&displayed_dive_site)) {
+ // so we are showing a completion and both the current dive site and the completion
+ // have a GPS fix... so let's show the distance
+ if (ds->latitude.udeg == displayed_dive_site.latitude.udeg &&
+ ds->longitude.udeg == displayed_dive_site.longitude.udeg) {
+ bottomText += tr(" (same GPS fix)");
+ } 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);
+ }
+ }
fontBigger.setPointSize(fontBigger.pointSize() + 1);
fontBigger.setBold(true);