mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
e82f8ea565
commit
8c0d0de2e6
6 changed files with 38 additions and 1 deletions
18
qthelper.cpp
18
qthelper.cpp
|
|
@ -55,6 +55,24 @@ QString weight_string(int weight_in_grams)
|
|||
return (str);
|
||||
}
|
||||
|
||||
QString distance_string(int distanceInMeters)
|
||||
{
|
||||
QString str;
|
||||
if(get_units()->length == units::METERS) {
|
||||
if (distanceInMeters >= 1000)
|
||||
str = QString(translate("gettextFromC", "%1km")).arg(distanceInMeters / 1000);
|
||||
else
|
||||
str = QString(translate("gettextFromC", "%1m")).arg(distanceInMeters);
|
||||
} else {
|
||||
double miles = m_to_mile(distanceInMeters);
|
||||
if (miles >= 1.0)
|
||||
str = QString(translate("gettextFromC", "%1mi")).arg((int)miles);
|
||||
else
|
||||
str = QString(translate("gettextFromC", "%1yd")).arg((int)(miles * 1760));
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
extern "C" const char *printGPSCoords(int lat, int lon)
|
||||
{
|
||||
unsigned int latdeg, londeg;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue