From 8c0d0de2e62356e1bbdad97843d185a37973c5c7 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 14 Jul 2015 11:35:04 -0700 Subject: 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 --- qt-ui/modeldelegates.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'qt-ui') 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); -- cgit v1.2.3-70-g09d2