diff options
Diffstat (limited to 'qt-ui/modeldelegates.cpp')
-rw-r--r-- | qt-ui/modeldelegates.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 953c16b87..8e296d412 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -11,6 +11,9 @@ #include "weightmodel.h" #include "divetripmodel.h" #include "qthelper.h" +#ifndef NO_MARBLE +#include "globe.h" +#endif #include <QCompleter> #include <QKeyEvent> @@ -511,12 +514,15 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem if (!ds) return; - for (int i = 0; i < ds->taxonomy.nr; i++) { - if(ds->taxonomy.category[i].category == TC_NONE) + for (int i = 0; i < 3; i++) { + if (prefs.geocoding.category[i] == TC_NONE) + continue; + int idx = taxonomy_index_for_category(&ds->taxonomy, prefs.geocoding.category[i]); + if (idx == -1) continue; if(!bottomText.isEmpty()) - bottomText += " "; - bottomText += QString(ds->taxonomy.category[i].value) + " "; + bottomText += " / "; + bottomText += QString(ds->taxonomy.category[idx].value); } if (bottomText.isEmpty()) { @@ -525,7 +531,27 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem free( (void*) gpsCoords); } - print_part: +#ifndef NO_MARBLE + if ((option.state & QStyle::State_HasFocus) && dive_site_has_gps_location(ds)) { + qDebug() << "center on" << ds->name; + MainWindow::instance()->globe()->centerOnDiveSite(ds->uuid); + } +#endif + + 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); + } + } +print_part: + fontBigger.setPointSize(fontBigger.pointSize() + 1); fontBigger.setBold(true); |