summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/imports/location/qdeclarativegeoroutemodel.cpp97
-rw-r--r--src/imports/location/qdeclarativegeoroutemodel_p.h11
-rw-r--r--src/location/maps/qgeoroutingmanager.cpp27
-rw-r--r--src/location/maps/qgeoroutingmanager.h10
-rw-r--r--src/location/maps/qgeoroutingmanagerengine.cpp30
-rw-r--r--src/location/maps/qgeoroutingmanagerengine.h10
-rw-r--r--src/location/maps/qgeoroutingmanagerengine_p.h1
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp6
8 files changed, 178 insertions, 14 deletions
diff --git a/src/imports/location/qdeclarativegeoroutemodel.cpp b/src/imports/location/qdeclarativegeoroutemodel.cpp
index f315cea2..2a792fe5 100644
--- a/src/imports/location/qdeclarativegeoroutemodel.cpp
+++ b/src/imports/location/qdeclarativegeoroutemodel.cpp
@@ -408,6 +408,103 @@ bool QDeclarativeGeoRouteModel::autoUpdate() const
}
/*!
+ \qmlproperty Locale QtLocation::RouteModel::locale
+
+ This property holds the locale which will be used when calculating the route. Setting this
+ property also sets the \l {QtLocation::RouteModel::measurementSystem}{measurementSystem}
+ property.
+*/
+void QDeclarativeGeoRouteModel::setLocale(const QLocale &locale)
+{
+ if (!plugin_) {
+ qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, ROUTE_PLUGIN_NOT_SET);
+ return;
+ }
+
+ QGeoServiceProvider *serviceProvider = plugin_->sharedGeoServiceProvider();
+ if (!serviceProvider)
+ return;
+
+ QGeoRoutingManager *routingManager = serviceProvider->routingManager();
+ if (!routingManager) {
+ qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, ROUTE_MGR_NOT_SET);
+ return;
+ }
+
+ if (routingManager->locale() == locale)
+ return;
+
+ routingManager->setLocale(locale);
+ emit localeChanged();
+}
+
+QLocale QDeclarativeGeoRouteModel::locale() const
+{
+ if (!plugin_)
+ return QLocale();
+
+ QGeoServiceProvider *serviceProvider = plugin_->sharedGeoServiceProvider();
+ if (!serviceProvider)
+ return QLocale();
+
+ QGeoRoutingManager *routingManager = serviceProvider->routingManager();
+ if (!routingManager) {
+ qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, ROUTE_MGR_NOT_SET);
+ return QLocale();
+ }
+
+ return routingManager->locale();
+}
+
+/*!
+ \qmlproperty Locale::MeasurementSystem QtLocation::RouteModel::measurementSystem
+
+ This property holds the measurement system which will be used when calculating the route. This
+ property is changed when the \l {QtLocation::RouteModel::locale}{locale} property is changed.
+*/
+void QDeclarativeGeoRouteModel::setMeasurementSystem(QLocale::MeasurementSystem ms)
+{
+ if (!plugin_) {
+ qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, ROUTE_PLUGIN_NOT_SET);
+ return;
+ }
+
+ QGeoServiceProvider *serviceProvider = plugin_->sharedGeoServiceProvider();
+ if (!serviceProvider)
+ return;
+
+ QGeoRoutingManager *routingManager = serviceProvider->routingManager();
+ if (!routingManager) {
+ qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, ROUTE_MGR_NOT_SET);
+ return;
+ }
+
+ if (routingManager->measurementSystem() == ms)
+ return;
+
+ routingManager->setMeasurementSystem(ms);
+ emit measurementSystemChanged();
+}
+
+QLocale::MeasurementSystem QDeclarativeGeoRouteModel::measurementSystem() const
+{
+ if (!plugin_)
+ return QLocale().measurementSystem();
+
+ QGeoServiceProvider *serviceProvider = plugin_->sharedGeoServiceProvider();
+ if (!serviceProvider)
+ return QLocale().measurementSystem();
+
+ QGeoRoutingManager *routingManager = serviceProvider->routingManager();
+ if (!routingManager) {
+ qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, ROUTE_MGR_NOT_SET);
+ return QLocale().measurementSystem();
+ }
+
+ return routingManager->measurementSystem();
+}
+
+/*!
\internal
*/
void QDeclarativeGeoRouteModel::setStatus(QDeclarativeGeoRouteModel::Status status)
diff --git a/src/imports/location/qdeclarativegeoroutemodel_p.h b/src/imports/location/qdeclarativegeoroutemodel_p.h
index 0d663eed..ebaf386a 100644
--- a/src/imports/location/qdeclarativegeoroutemodel_p.h
+++ b/src/imports/location/qdeclarativegeoroutemodel_p.h
@@ -77,6 +77,9 @@ class QDeclarativeGeoRouteModel : public QAbstractListModel, public QQmlParserSt
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged)
Q_PROPERTY(RouteError error READ error NOTIFY errorChanged)
+ Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged)
+ Q_PROPERTY(QLocale::MeasurementSystem measurementSystem READ measurementSystem WRITE setMeasurementSystem NOTIFY measurementSystemChanged)
+
Q_INTERFACES(QQmlParserStatus)
public:
@@ -121,6 +124,12 @@ public:
void setAutoUpdate(bool autoUpdate);
bool autoUpdate() const;
+ void setLocale(const QLocale &locale);
+ QLocale locale() const;
+
+ void setMeasurementSystem(QLocale::MeasurementSystem ms);
+ QLocale::MeasurementSystem measurementSystem() const;
+
Status status() const;
QString errorString() const;
RouteError error() const;
@@ -139,6 +148,8 @@ Q_SIGNALS:
void errorStringChanged();
void errorChanged();
void routesChanged();
+ void localeChanged();
+ void measurementSystemChanged();
public Q_SLOTS:
void update();
diff --git a/src/location/maps/qgeoroutingmanager.cpp b/src/location/maps/qgeoroutingmanager.cpp
index 5637a269..07af687b 100644
--- a/src/location/maps/qgeoroutingmanager.cpp
+++ b/src/location/maps/qgeoroutingmanager.cpp
@@ -347,6 +347,33 @@ QLocale QGeoRoutingManager::locale() const
}
/*!
+ Sets the measurement system used by this manager to \a system.
+
+ The measurement system can be set independently of the locale. Both setLocale() and this
+ function set the measurement system. The value set by the last function called will be used.
+
+ \sa measurementSystem(), locale(), setLocale()
+*/
+void QGeoRoutingManager::setMeasurementSystem(QLocale::MeasurementSystem system)
+{
+ d_ptr->engine->setMeasurementSystem(system);
+}
+
+/*!
+ Returns the measurement system used by this manager.
+
+ If setMeasurementSystem() has been called then the value returned by this function may be
+ different to that returned by locale().\l {QLocale::measurementSystem()}{measurementSystem()}.
+ In which case the value returned by this function is what will be used by the manager.
+
+ \sa setMeasurementSystem(), setLocale()
+*/
+QLocale::MeasurementSystem QGeoRoutingManager::measurementSystem() const
+{
+ return d_ptr->engine->measurementSystem();
+}
+
+/*!
\fn void QGeoRoutingManager::finished(QGeoRouteReply *reply)
This signal is emitted when \a reply has finished processing.
diff --git a/src/location/maps/qgeoroutingmanager.h b/src/location/maps/qgeoroutingmanager.h
index d9ff6816..72dfc370 100644
--- a/src/location/maps/qgeoroutingmanager.h
+++ b/src/location/maps/qgeoroutingmanager.h
@@ -42,22 +42,20 @@
#ifndef QGEOROUTINGMANAGER_H
#define QGEOROUTINGMANAGER_H
+#include <QtCore/QObject>
+#include <QtCore/QLocale>
#include <QtLocation/QGeoRouteRequest>
#include <QtLocation/QGeoRouteReply>
-#include <QObject>
-#include <QMap>
-
QT_BEGIN_NAMESPACE
-class QLocale;
-
class QGeoRoutingManagerEngine;
class QGeoRoutingManagerPrivate;
class Q_LOCATION_EXPORT QGeoRoutingManager : public QObject
{
Q_OBJECT
+
public:
~QGeoRoutingManager();
@@ -76,6 +74,8 @@ public:
void setLocale(const QLocale &locale);
QLocale locale() const;
+ void setMeasurementSystem(QLocale::MeasurementSystem system);
+ QLocale::MeasurementSystem measurementSystem() const;
Q_SIGNALS:
void finished(QGeoRouteReply *reply);
diff --git a/src/location/maps/qgeoroutingmanagerengine.cpp b/src/location/maps/qgeoroutingmanagerengine.cpp
index 8629bcb5..20a10164 100644
--- a/src/location/maps/qgeoroutingmanagerengine.cpp
+++ b/src/location/maps/qgeoroutingmanagerengine.cpp
@@ -347,6 +347,7 @@ QGeoRouteRequest::ManeuverDetails QGeoRoutingManagerEngine::supportedManeuverDet
void QGeoRoutingManagerEngine::setLocale(const QLocale &locale)
{
d_ptr->locale = locale;
+ d_ptr->measurementSystem = locale.measurementSystem();
}
/*!
@@ -359,6 +360,33 @@ QLocale QGeoRoutingManagerEngine::locale() const
}
/*!
+ Sets the measurement system used by this manager to \a system.
+
+ The measurement system can be set independently of the locale. Both setLocale() and this
+ function set the measurement system. The value set by the last function called will be used.
+
+ \sa measurementSystem(), locale(), setLocale()
+*/
+void QGeoRoutingManagerEngine::setMeasurementSystem(QLocale::MeasurementSystem system)
+{
+ d_ptr->measurementSystem = system;
+}
+
+/*!
+ Returns the measurement system used by this manager.
+
+ If setMeasurementSystem() has been called then the value returned by this function may be
+ different to that returned by locale().\l {QLocale::measurementSystem()}{measurementSystem()}.
+ In which case the value returned by this function is what will be used by the manager.
+
+ \sa setMeasurementSystem(), setLocale()
+*/
+QLocale::MeasurementSystem QGeoRoutingManagerEngine::measurementSystem() const
+{
+ return d_ptr->measurementSystem;
+}
+
+/*!
\fn void QGeoRoutingManagerEngine::finished(QGeoRouteReply *reply)
This signal is emitted when \a reply has finished processing.
@@ -391,7 +419,7 @@ Use deleteLater() instead.
*******************************************************************************/
QGeoRoutingManagerEnginePrivate::QGeoRoutingManagerEnginePrivate()
- : managerVersion(-1)
+: managerVersion(-1), measurementSystem(locale.measurementSystem())
{
}
diff --git a/src/location/maps/qgeoroutingmanagerengine.h b/src/location/maps/qgeoroutingmanagerengine.h
index fa05b984..71f3f77a 100644
--- a/src/location/maps/qgeoroutingmanagerengine.h
+++ b/src/location/maps/qgeoroutingmanagerengine.h
@@ -42,16 +42,14 @@
#ifndef QGEOROUTINGMANAGERENGINE_H
#define QGEOROUTINGMANAGERENGINE_H
+#include <QtCore/QObject>
+#include <QtCore/QMap>
+#include <QtCore/QLocale>
#include <QtLocation/QGeoRouteRequest>
#include <QtLocation/QGeoRouteReply>
-#include <QObject>
-#include <QMap>
-
QT_BEGIN_NAMESPACE
-class QLocale;
-
class QGeoRoutingManagerEnginePrivate;
class Q_LOCATION_EXPORT QGeoRoutingManagerEngine : public QObject
@@ -76,6 +74,8 @@ public:
void setLocale(const QLocale &locale);
QLocale locale() const;
+ void setMeasurementSystem(QLocale::MeasurementSystem system);
+ QLocale::MeasurementSystem measurementSystem() const;
Q_SIGNALS:
void finished(QGeoRouteReply *reply);
diff --git a/src/location/maps/qgeoroutingmanagerengine_p.h b/src/location/maps/qgeoroutingmanagerengine_p.h
index e868fad8..ad6f8660 100644
--- a/src/location/maps/qgeoroutingmanagerengine_p.h
+++ b/src/location/maps/qgeoroutingmanagerengine_p.h
@@ -77,6 +77,7 @@ public:
QGeoRouteRequest::ManeuverDetails supportedManeuverDetails;
QLocale locale;
+ QLocale::MeasurementSystem measurementSystem;
private:
Q_DISABLE_COPY(QGeoRoutingManagerEnginePrivate)
diff --git a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
index 9bd60155..53bdc3cd 100644
--- a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
@@ -442,14 +442,14 @@ QString QGeoRoutingManagerEngineNokia::routeRequestString(const QGeoRouteRequest
requestString += "&instructionformat=text";
- const QLocale loc(locale());
-
requestString += "&metricSystem=";
- if (QLocale::MetricSystem == loc.measurementSystem())
+ if (QLocale::MetricSystem == measurementSystem())
requestString += "metric";
else
requestString += "imperial";
+ const QLocale loc(locale());
+
if (QLocale::C != loc.language() && QLocale::AnyLanguage != loc.language()) {
requestString += "&language=";
requestString += loc.name();