[Marble-commits] branches/KDE/4.6/kdeedu/marble/src [POSSIBLY UNSAFE]
Dennis Nienhüser
earthwings at gentoo.org
Thu Dec 23 16:44:44 CET 2010
SVN commit 1208876 by nienhueser:
Support imperial units in the routing plugin and when generating driving instructions.
Backport of commit 1208843.
M +10 -1 lib/routing/instructions/RoutingInstruction.cpp [POSSIBLY UNSAFE: system]
M +10 -1 plugins/render/routing/RoutingPlugin.cpp
--- branches/KDE/4.6/kdeedu/marble/src/lib/routing/instructions/RoutingInstruction.cpp #1208875:1208876
@@ -316,9 +316,17 @@
QString RoutingInstruction::nextDistanceInstruction() const
{
- QString distanceUnit = "m";
+ QLocale::MeasurementSystem const measurement = QLocale::system().measurementSystem();
int precision = 0;
qreal length = distance();
+ QString distanceUnit = "m";
+
+ if ( measurement == QLocale::ImperialSystem ) {
+ precision = 1;
+ distanceUnit = "mi";
+ length /= 1000.0;
+ length /= 1.609344;
+ } else {
if ( length >= 1000 ) {
length /= 1000;
distanceUnit = "km";
@@ -330,6 +338,7 @@
} else {
length = 10 * qRound( length / 10 );
}
+ }
if ( length == 0 ) {
return QString();
--- branches/KDE/4.6/kdeedu/marble/src/plugins/render/routing/RoutingPlugin.cpp #1208875:1208876
@@ -19,6 +19,7 @@
#include "MarbleGraphicsGridLayout.h"
#include "MarbleModel.h"
#include "MarbleWidget.h"
+#include "MarbleLocale.h"
#include "PluginManager.h"
#include "PositionTracking.h"
#include "PositionProviderPlugin.h"
@@ -105,8 +106,15 @@
QString RoutingPluginPrivate::fuzzyDistance( qreal length ) const
{
+ int precision = 0;
QString distanceUnit = "m";
- int precision = 0;
+
+ if ( MarbleGlobal::getInstance()->locale()->distanceUnit() == Marble::MilesFeet ) {
+ precision = 1;
+ distanceUnit = "mi";
+ length *= METER2KM;
+ length *= KM2MI;
+ } else {
if ( length >= 1000 ) {
length /= 1000;
distanceUnit = "km";
@@ -118,6 +126,7 @@
} else {
length = 10 * qRound( length / 10 );
}
+ }
return QString( "%1 %2" ).arg( length, 0, 'f', precision ).arg( distanceUnit );
}
More information about the Marble-commits
mailing list