summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKari Oikarinen <kari.oikarinen@qt.io>2019-01-08 08:18:31 +0200
committerKari Oikarinen <kari.oikarinen@qt.io>2019-01-08 08:18:31 +0200
commitf1dd13632651a9efd0ea976a3efdd9c555a34bc2 (patch)
treec647c2741ed1be32c8ad8dac6c962fc79bf17fe4
parent4ab5838d9ba26eef2b2156bbf9cd428547bbebe0 (diff)
parent1688c44d223145abfdca19a7b31faecbafb0d315 (diff)
downloadqtlocation-f1dd13632651a9efd0ea976a3efdd9c555a34bc2.tar.gz
Merge 5.12 into 5.12.1
Change-Id: Ib65445a9e316252e7483d2878b8cdad252242177
-rw-r--r--.gitignore3
-rw-r--r--.qmake.conf2
-rw-r--r--dist/changes-5.11.332
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitemview.cpp3
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem.cpp13
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem_p.h1
-rw-r--r--src/location/declarativemaps/qquickgeomapgesturearea.cpp1
-rw-r--r--src/location/maps/qgeorouteparser.cpp16
-rw-r--r--src/location/maps/qgeorouteparser_p.h15
-rw-r--r--src/location/maps/qgeorouteparser_p_p.h2
-rw-r--r--src/location/maps/qgeorouteparserosrmv4.cpp21
-rw-r--r--src/location/maps/qgeorouteparserosrmv5.cpp16
-rw-r--r--src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp8
-rw-r--r--src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp7
-rw-r--r--src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp7
-rw-r--r--src/plugins/position/android/jar/src/org/qtproject/qt5/android/positioning/QtPositioning.java7
-rw-r--r--src/plugins/position/android/src/jnipositioning.cpp86
-rw-r--r--src/plugins/position/android/src/qgeopositioninfosource_android.cpp5
-rw-r--r--src/plugins/position/android/src/qgeopositioninfosource_android_p.h1
-rw-r--r--src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp5
-rw-r--r--src/positioning/qgeocoordinate.cpp28
-rw-r--r--src/positioning/qgeopositioninfosource.cpp58
-rw-r--r--tests/applications/positioning_backend/logwidget.cpp46
-rw-r--r--tests/applications/positioning_backend/logwidget.h47
-rw-r--r--tests/applications/positioning_backend/main.cpp7
-rw-r--r--tests/applications/positioning_backend/positioning_backend.pro6
-rw-r--r--tests/applications/positioning_backend/widget.cpp14
-rw-r--r--tests/applications/positioning_backend/widget.h5
28 files changed, 381 insertions, 81 deletions
diff --git a/.gitignore b/.gitignore
index 5b60c37d..a4fa8e34 100644
--- a/.gitignore
+++ b/.gitignore
@@ -85,6 +85,9 @@ tst_*.log
tst_*.debug
tst_*~
+# Android temporary files
+*so-deployment-settings.json
+
# xemacs temporary files
*.flc
diff --git a/.qmake.conf b/.qmake.conf
index 0815e3b5..3dc70a37 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,7 +1,7 @@
load(qt_build_config)
CONFIG += warning_clean
-MODULE_VERSION = 5.12.0
+MODULE_VERSION = 5.12.1
# Adds a way to debug location. The define is needed for multiple subprojects as they
# include the essential headers.
diff --git a/dist/changes-5.11.3 b/dist/changes-5.11.3
new file mode 100644
index 00000000..9b09a0c0
--- /dev/null
+++ b/dist/changes-5.11.3
@@ -0,0 +1,32 @@
+Qt 5.11.3 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with Qt 5.11.0 through 5.11.2.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+http://doc.qt.io/qt-5/index.html
+
+The Qt version 5.11 series is binary compatible with the 5.10.x series.
+Applications compiled for 5.10 will continue to run with 5.11.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* Qt 5.11.3 Changes *
+****************************************************************************
+
+ QtLocation
+ ----------
+
+ - [QTBUG-69617] Fixed Qt.labs.location not linking statically on iOS.
+ - [QTBUG-71355] Fixed crash when calling QGeoPath::length() on empty
+ QGeoPath instance.
+ - Fixed place search matching based on category in mapbox plugin. Previously,
+ the search results contained places which did not have any category set.
+
diff --git a/src/location/declarativemaps/qdeclarativegeomapitemview.cpp b/src/location/declarativemaps/qdeclarativegeomapitemview.cpp
index 41ab3453..d404fd47 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitemview.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapitemview.cpp
@@ -175,6 +175,9 @@ void QDeclarativeGeoMapItemView::createdItem(int index, QObject */*object*/)
void QDeclarativeGeoMapItemView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
{
+ if (!m_map) // everything will be done in instantiateAllItems. Removal is done by declarativegeomap.
+ return;
+
// move changes are expressed as one remove + one insert, with the same moveId.
// For simplicity, they will be treated as remove + insert.
// Changes will be also ignored, as they represent only data changes, not layout changes
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
index b692bc76..f4cdc6bf 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
@@ -320,18 +320,9 @@ QDeclarativePolygonMapItem::QDeclarativePolygonMapItem(QQuickItem *parent)
{
setFlag(ItemHasContents, true);
QObject::connect(&border_, SIGNAL(colorChanged(QColor)),
- this, SLOT(handleBorderUpdated()));
+ this, SLOT(markSourceDirtyAndUpdate()));
QObject::connect(&border_, SIGNAL(widthChanged(qreal)),
- this, SLOT(handleBorderUpdated()));
-}
-
-/*!
- \internal
-*/
-void QDeclarativePolygonMapItem::handleBorderUpdated()
-{
- borderGeometry_.markSourceDirty();
- polishAndUpdate();
+ this, SLOT(markSourceDirtyAndUpdate()));
}
QDeclarativePolygonMapItem::~QDeclarativePolygonMapItem()
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
index a68b6315..87d72307 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
@@ -120,7 +120,6 @@ protected:
protected Q_SLOTS:
void markSourceDirtyAndUpdate();
- void handleBorderUpdated();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) override;
private:
diff --git a/src/location/declarativemaps/qquickgeomapgesturearea.cpp b/src/location/declarativemaps/qquickgeomapgesturearea.cpp
index b15dbc4d..88a766f5 100644
--- a/src/location/declarativemaps/qquickgeomapgesturearea.cpp
+++ b/src/location/declarativemaps/qquickgeomapgesturearea.cpp
@@ -1087,6 +1087,7 @@ void QQuickGeoMapGestureArea::update()
m_allPoints << m_touchPoints;
if (m_allPoints.isEmpty() && !m_mousePoint.isNull())
m_allPoints << *m_mousePoint.data();
+ std::sort(m_allPoints.begin(), m_allPoints.end(), [](const QTouchEvent::TouchPoint &tp1, const QTouchEvent::TouchPoint &tp2) { return tp1.id() < tp2.id(); });
touchPointStateMachine();
diff --git a/src/location/maps/qgeorouteparser.cpp b/src/location/maps/qgeorouteparser.cpp
index 646902e0..51b839dd 100644
--- a/src/location/maps/qgeorouteparser.cpp
+++ b/src/location/maps/qgeorouteparser.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
Private class implementations
*/
-QGeoRouteParserPrivate::QGeoRouteParserPrivate() : QObjectPrivate()
+QGeoRouteParserPrivate::QGeoRouteParserPrivate() : QObjectPrivate(), trafficSide(QGeoRouteParser::RightHandTraffic)
{
}
@@ -85,6 +85,20 @@ QUrl QGeoRouteParser::requestUrl(const QGeoRouteRequest &request, const QString
return d->requestUrl(request, prefix);
}
+QGeoRouteParser::TrafficSide QGeoRouteParser::trafficSide() const
+{
+ Q_D(const QGeoRouteParser);
+ return d->trafficSide;
+}
+
+void QGeoRouteParser::setTrafficSide(QGeoRouteParser::TrafficSide trafficSide)
+{
+ Q_D(QGeoRouteParser);
+ if (d->trafficSide == trafficSide) return;
+ d->trafficSide = trafficSide;
+ Q_EMIT trafficSideChanged(trafficSide);
+}
+
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeorouteparser_p.h b/src/location/maps/qgeorouteparser_p.h
index 33c3a4db..053dadb1 100644
--- a/src/location/maps/qgeorouteparser_p.h
+++ b/src/location/maps/qgeorouteparser_p.h
@@ -61,12 +61,25 @@ class Q_LOCATION_PRIVATE_EXPORT QGeoRouteParser : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QGeoRouteParser)
-
+ Q_PROPERTY(TrafficSide trafficSide READ trafficSide WRITE setTrafficSide NOTIFY trafficSideChanged)
+ Q_ENUMS(TrafficSide)
public:
+ enum TrafficSide {
+ RightHandTraffic,
+ LeftHandTraffic
+ };
virtual ~QGeoRouteParser();
QGeoRouteReply::Error parseReply(QList<QGeoRoute> &routes, QString &errorString, const QByteArray &reply) const;
QUrl requestUrl(const QGeoRouteRequest &request, const QString &prefix) const;
+ TrafficSide trafficSide() const;
+
+public Q_SLOTS:
+ void setTrafficSide(TrafficSide trafficSide);
+
+Q_SIGNALS:
+ void trafficSideChanged(TrafficSide trafficSide);
+
protected:
QGeoRouteParser(QGeoRouteParserPrivate &dd, QObject *parent = nullptr);
diff --git a/src/location/maps/qgeorouteparser_p_p.h b/src/location/maps/qgeorouteparser_p_p.h
index 63c773eb..c0080437 100644
--- a/src/location/maps/qgeorouteparser_p_p.h
+++ b/src/location/maps/qgeorouteparser_p_p.h
@@ -64,6 +64,8 @@ public:
virtual QGeoRouteReply::Error parseReply(QList<QGeoRoute> &routes, QString &errorString, const QByteArray &reply) const = 0;
virtual QUrl requestUrl(const QGeoRouteRequest &request, const QString &prefix) const = 0;
+
+ QGeoRouteParser::TrafficSide trafficSide;
};
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeorouteparserosrmv4.cpp b/src/location/maps/qgeorouteparserosrmv4.cpp
index bd36e7f3..24c920b0 100644
--- a/src/location/maps/qgeorouteparserosrmv4.cpp
+++ b/src/location/maps/qgeorouteparserosrmv4.cpp
@@ -86,7 +86,7 @@ static QList<QGeoCoordinate> parsePolyline(const QByteArray &data)
return path;
}
-static QGeoManeuver::InstructionDirection osrmInstructionDirection(const QString &instructionCode)
+static QGeoManeuver::InstructionDirection osrmInstructionDirection(const QString &instructionCode, QGeoRouteParser::TrafficSide trafficSide)
{
if (instructionCode == QLatin1String("0"))
return QGeoManeuver::NoDirection;
@@ -98,9 +98,15 @@ static QGeoManeuver::InstructionDirection osrmInstructionDirection(const QString
return QGeoManeuver::DirectionRight;
else if (instructionCode == QLatin1String("4"))
return QGeoManeuver::DirectionHardRight;
- else if (instructionCode == QLatin1String("5"))
+ else if (instructionCode == QLatin1String("5")) {
+ switch (trafficSide) {
+ case QGeoRouteParser::RightHandTraffic:
+ return QGeoManeuver::DirectionUTurnLeft;
+ case QGeoRouteParser::LeftHandTraffic:
+ return QGeoManeuver::DirectionUTurnRight;
+ }
return QGeoManeuver::DirectionUTurnLeft;
- else if (instructionCode == QLatin1String("6"))
+ } else if (instructionCode == QLatin1String("6"))
return QGeoManeuver::DirectionHardLeft;
else if (instructionCode == QLatin1String("7"))
return QGeoManeuver::DirectionLeft;
@@ -240,7 +246,7 @@ static QString osrmInstructionText(const QString &instructionCode, const QString
}
static QGeoRoute constructRoute(const QByteArray &geometry, const QJsonArray &instructions,
- const QJsonObject &summary)
+ const QJsonObject &summary, QGeoRouteParser::TrafficSide trafficSide)
{
QGeoRoute route;
@@ -272,7 +278,7 @@ static QGeoRoute constructRoute(const QByteArray &geometry, const QJsonArray &in
segment.setDistance(segmentLength);
QGeoManeuver maneuver;
- maneuver.setDirection(osrmInstructionDirection(instructionCode));
+ maneuver.setDirection(osrmInstructionDirection(instructionCode, trafficSide));
maneuver.setDistanceToNextInstruction(segmentLength);
maneuver.setInstructionText(osrmInstructionText(instructionCode, wayname));
maneuver.setPosition(path.at(position));
@@ -349,7 +355,7 @@ QGeoRouteReply::Error QGeoRouteParserOsrmV4Private::parseReply(QList<QGeoRoute>
QJsonArray routeInstructions = object.value(QStringLiteral("route_instructions")).toArray();
- QGeoRoute route = constructRoute(routeGeometry, routeInstructions, routeSummary);
+ QGeoRoute route = constructRoute(routeGeometry, routeInstructions, routeSummary, trafficSide);
routes.append(route);
@@ -365,7 +371,8 @@ QGeoRouteReply::Error QGeoRouteParserOsrmV4Private::parseReply(QList<QGeoRoute>
for (int i = 0; i < alternativeSummaries.count(); ++i) {
route = constructRoute(alternativeGeometries.at(i).toString().toLatin1(),
alternativeInstructions.at(i).toArray(),
- alternativeSummaries.at(i).toObject());
+ alternativeSummaries.at(i).toObject(),
+ trafficSide);
//routes.append(route);
}
}
diff --git a/src/location/maps/qgeorouteparserosrmv5.cpp b/src/location/maps/qgeorouteparserosrmv5.cpp
index 39910229..cc39158f 100644
--- a/src/location/maps/qgeorouteparserosrmv5.cpp
+++ b/src/location/maps/qgeorouteparserosrmv5.cpp
@@ -769,7 +769,7 @@ static QString instructionText(const QJsonObject &step, const QJsonObject &maneu
return maneuverType + QLatin1String(" to/onto ") + wayName;
}
-static QGeoManeuver::InstructionDirection instructionDirection(const QJsonObject &maneuver)
+static QGeoManeuver::InstructionDirection instructionDirection(const QJsonObject &maneuver, QGeoRouteParser::TrafficSide trafficSide)
{
QString modifier;
if (maneuver.value(QLatin1String("modifier")).isString())
@@ -785,9 +785,15 @@ static QGeoManeuver::InstructionDirection instructionDirection(const QJsonObject
return QGeoManeuver::DirectionHardRight;
else if (modifier == QLatin1String("slight right"))
return QGeoManeuver::DirectionLightRight;
- else if (modifier == QLatin1String("uturn"))
- return QGeoManeuver::DirectionUTurnLeft; // This should rather be country-specific. In UK, f.ex. one should rather UTurn Right
- else if (modifier == QLatin1String("left"))
+ else if (modifier == QLatin1String("uturn")) {
+ switch (trafficSide) {
+ case QGeoRouteParser::RightHandTraffic:
+ return QGeoManeuver::DirectionUTurnLeft;
+ case QGeoRouteParser::LeftHandTraffic:
+ return QGeoManeuver::DirectionUTurnRight;
+ }
+ return QGeoManeuver::DirectionUTurnLeft;
+ } else if (modifier == QLatin1String("left"))
return QGeoManeuver::DirectionLeft;
else if (modifier == QLatin1String("sharp left"))
return QGeoManeuver::DirectionHardLeft;
@@ -855,7 +861,7 @@ QGeoRouteSegment QGeoRouteParserOsrmV5Private::parseStep(const QJsonObject &step
QString geometry = step.value(QLatin1String("geometry")).toString();
QList<QGeoCoordinate> path = decodePolyline(geometry);
- QGeoManeuver::InstructionDirection maneuverInstructionDirection = instructionDirection(maneuver);
+ QGeoManeuver::InstructionDirection maneuverInstructionDirection = instructionDirection(maneuver, trafficSide);
QString maneuverInstructionText = instructionText(step, maneuver, maneuverInstructionDirection);
diff --git a/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp
index e8db635f..29cf0167 100644
--- a/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp
@@ -238,7 +238,13 @@ QGeoRoutingManagerEngineMapbox::QGeoRoutingManagerEngineMapbox(const QVariantMap
QGeoRouteParserOsrmV5 *parser = new QGeoRouteParserOsrmV5(this);
parser->setExtension(new QGeoRouteParserOsrmV5ExtensionMapbox(m_accessToken, use_mapbox_text_instructions));
-
+ if (parameters.contains(QStringLiteral("mapbox.routing.traffic_side"))) {
+ QString trafficSide = parameters.value(QStringLiteral("mapbox.routing.traffic_side")).toString();
+ if (trafficSide == QStringLiteral("right"))
+ parser->setTrafficSide(QGeoRouteParser::RightHandTraffic);
+ else if (trafficSide == QStringLiteral("left"))
+ parser->setTrafficSide(QGeoRouteParser::LeftHandTraffic);
+ }
m_routeParser = parser;
*error = QGeoServiceProvider::NoError;
diff --git a/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp b/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp
index a79af1cb..b2f2f043 100644
--- a/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp
@@ -188,19 +188,18 @@ void QPlaceSearchReplyMapbox::onReplyFinished()
if (!categories.isEmpty()) {
const QList<QPlaceCategory> placeCategories = placeResult.place().categories();
+ bool categoryMatch = false;
if (!placeCategories.isEmpty()) {
- bool categoryMatch = false;
for (const QPlaceCategory &placeCategory : placeCategories) {
if (categories.contains(placeCategory)) {
categoryMatch = true;
break;
}
}
- if (!categoryMatch)
- continue;
}
+ if (!categoryMatch)
+ continue;
}
-
placeResult.setDistance(searchCenter.distanceTo(placeResult.place().location().coordinate()));
results.append(placeResult);
}
diff --git a/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp
index 12db22a9..29a35aaa 100644
--- a/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp
+++ b/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp
@@ -67,6 +67,13 @@ QGeoRoutingManagerEngineOsm::QGeoRoutingManagerEngineOsm(const QVariantMap &para
m_routeParser = new QGeoRouteParserOsrmV4(this);
else
m_routeParser = new QGeoRouteParserOsrmV5(this);
+ if (parameters.contains(QStringLiteral("osm.routing.traffic_side"))) {
+ QString trafficSide = parameters.value(QStringLiteral("mapbox.routing.traffic_side")).toString();
+ if (trafficSide == QStringLiteral("right"))
+ m_routeParser->setTrafficSide(QGeoRouteParser::RightHandTraffic);
+ else if (trafficSide == QStringLiteral("left"))
+ m_routeParser->setTrafficSide(QGeoRouteParser::LeftHandTraffic);
+ }
*error = QGeoServiceProvider::NoError;
errorString->clear();
diff --git a/src/plugins/position/android/jar/src/org/qtproject/qt5/android/positioning/QtPositioning.java b/src/plugins/position/android/jar/src/org/qtproject/qt5/android/positioning/QtPositioning.java
index 1ea0c071..d819e627 100644
--- a/src/plugins/position/android/jar/src/org/qtproject/qt5/android/positioning/QtPositioning.java
+++ b/src/plugins/position/android/jar/src/org/qtproject/qt5/android/positioning/QtPositioning.java
@@ -114,7 +114,7 @@ public class QtPositioning implements LocationListener
Log.w(TAG, "No locationManager available in QtPositioning");
return new int[0];
}
- List<String> providers = locationManager.getAllProviders();
+ List<String> providers = locationManager.getProviders(true);
int retList[] = new int[providers.size()];
for (int i = 0; i < providers.size(); i++) {
if (providers.get(i).equals(LocationManager.GPS_PROVIDER)) {
@@ -521,10 +521,9 @@ public class QtPositioning implements LocationListener
}
}
-
-
public static native void positionUpdated(Location update, int androidClassKey, boolean isSingleUpdate);
public static native void locationProvidersDisabled(int androidClassKey);
+ public static native void locationProvidersChanged(int androidClassKey);
public static native void satelliteUpdated(GpsSatellite[] update, int androidClassKey, boolean isSingleUpdate);
@Override
@@ -578,11 +577,13 @@ public class QtPositioning implements LocationListener
@Override
public void onProviderEnabled(String provider) {
Log.d(TAG, "Enabled provider: " + provider);
+ locationProvidersChanged(nativeClassReference);
}
@Override
public void onProviderDisabled(String provider) {
Log.d(TAG, "Disabled provider: " + provider);
+ locationProvidersChanged(nativeClassReference);
if (!expectedProvidersAvailable(expectedProviders))
locationProvidersDisabled(nativeClassReference);
}
diff --git a/src/plugins/position/android/src/jnipositioning.cpp b/src/plugins/position/android/src/jnipositioning.cpp
index 9bef8d36..0f358b42 100644
--- a/src/plugins/position/android/src/jnipositioning.cpp
+++ b/src/plugins/position/android/src/jnipositioning.cpp
@@ -51,8 +51,8 @@
#include "jnipositioning.h"
-static JavaVM *javaVM = 0;
-jclass positioningClass;
+static JavaVM *javaVM = nullptr;
+static jclass positioningClass;
static jmethodID providerListMethodId;
static jmethodID lastKnownPositionMethodId;
@@ -78,10 +78,10 @@ namespace AndroidPositioning {
AttachedJNIEnv()
{
attached = false;
- if (javaVM && javaVM->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) < 0) {
- if (javaVM->AttachCurrentThread(&jniEnv, NULL) < 0) {
+ if (javaVM && javaVM->GetEnv(reinterpret_cast<void**>(&jniEnv), JNI_VERSION_1_6) < 0) {
+ if (javaVM->AttachCurrentThread(&jniEnv, nullptr) < 0) {
__android_log_print(ANDROID_LOG_ERROR, logTag, "AttachCurrentThread failed");
- jniEnv = 0;
+ jniEnv = nullptr;
return;
}
attached = true;
@@ -109,7 +109,7 @@ namespace AndroidPositioning {
QGeoPositionInfoSourceAndroid *src = qobject_cast<QGeoPositionInfoSourceAndroid *>(obj);
Q_ASSERT(src);
do {
- key = QRandomGenerator::global()->generate();
+ key = qAbs(int(QRandomGenerator::global()->generate()));
} while (idToPosSource()->contains(key));
idToPosSource()->insert(key, src);
@@ -117,7 +117,7 @@ namespace AndroidPositioning {
QGeoSatelliteInfoSourceAndroid *src = qobject_cast<QGeoSatelliteInfoSourceAndroid *>(obj);
Q_ASSERT(src);
do {
- key = QRandomGenerator::global()->generate();
+ key = qAbs(int(QRandomGenerator::global()->generate()));
} while (idToSatSource()->contains(key));
idToSatSource()->insert(key, src);
@@ -142,16 +142,15 @@ namespace AndroidPositioning {
QGeoPositionInfoSource::PositioningMethods availableProviders()
{
- QGeoPositionInfoSource::PositioningMethods ret =
- static_cast<QGeoPositionInfoSource::PositioningMethods>(0);
+ QGeoPositionInfoSource::PositioningMethods ret = QGeoPositionInfoSource::NoPositioningMethods;
AttachedJNIEnv env;
if (!env.jniEnv)
return ret;
jintArray jProviders = static_cast<jintArray>(env.jniEnv->CallStaticObjectMethod(
positioningClass, providerListMethodId));
- jint *providers = env.jniEnv->GetIntArrayElements(jProviders, 0);
- const uint size = env.jniEnv->GetArrayLength(jProviders);
- for (uint i = 0; i < size; i++) {
+ jint *providers = env.jniEnv->GetIntArrayElements(jProviders, nullptr);
+ const int size = env.jniEnv->GetArrayLength(jProviders);
+ for (int i = 0; i < size; i++) {
switch (providers[i]) {
case PROVIDER_GPS:
ret |= QGeoPositionInfoSource::SatellitePositioningMethods;
@@ -182,17 +181,17 @@ namespace AndroidPositioning {
const char *name,
const char *sig)
{
- jmethodID id = 0;
- int offset_name = qstrlen(name);
- int offset_signal = qstrlen(sig);
- QByteArray key(offset_name + offset_signal, Qt::Uninitialized);
+ jmethodID id = nullptr;
+ uint offset_name = qstrlen(name);
+ uint offset_signal = qstrlen(sig);
+ QByteArray key(int(offset_name + offset_signal), Qt::Uninitialized);
memcpy(key.data(), name, offset_name);
memcpy(key.data()+offset_name, sig, offset_signal);
QHash<QByteArray, jmethodID>::iterator it = cachedMethodID->find(key);
if (it == cachedMethodID->end()) {
id = env->GetMethodID(clazz, name, sig);
if (env->ExceptionCheck()) {
- id = 0;
+ id = nullptr;
#ifdef QT_DEBUG
env->ExceptionDescribe();
#endif // QT_DEBUG
@@ -235,22 +234,38 @@ namespace AndroidPositioning {
jlong timestamp = jniEnv->CallLongMethod(location, mid);
info.setTimestamp(QDateTime::fromMSecsSinceEpoch(timestamp, Qt::UTC));
- //accuracy
+ //horizontal accuracy
mid = getCachedMethodID(jniEnv, thisClass, "hasAccuracy", "()Z");
attributeExists = jniEnv->CallBooleanMethod(location, mid);
if (attributeExists) {
mid = getCachedMethodID(jniEnv, thisClass, "getAccuracy", "()F");
jfloat accuracy = jniEnv->CallFloatMethod(location, mid);
- info.setAttribute(QGeoPositionInfo::HorizontalAccuracy, accuracy);
+ info.setAttribute(QGeoPositionInfo::HorizontalAccuracy, qreal(accuracy));
}
+ //vertical accuracy
+ mid = getCachedMethodID(jniEnv, thisClass, "hasVerticalAccuracy", "()Z");
+ if (mid) {
+ attributeExists = jniEnv->CallBooleanMethod(location, mid);
+ if (attributeExists) {
+ mid = getCachedMethodID(jniEnv, thisClass, "getVerticalAccuracyMeters", "()F");
+ if (mid) {
+ jfloat accuracy = jniEnv->CallFloatMethod(location, mid);
+ info.setAttribute(QGeoPositionInfo::VerticalAccuracy, qreal(accuracy));
+ }
+ }
+ }
+
+ if (!mid)
+ jniEnv->ExceptionClear();
+
//ground speed
mid = getCachedMethodID(jniEnv, thisClass, "hasSpeed", "()Z");
attributeExists = jniEnv->CallBooleanMethod(location, mid);
if (attributeExists) {
mid = getCachedMethodID(jniEnv, thisClass, "getSpeed", "()F");
jfloat speed = jniEnv->CallFloatMethod(location, mid);
- info.setAttribute(QGeoPositionInfo::GroundSpeed, speed);
+ info.setAttribute(QGeoPositionInfo::GroundSpeed, qreal(speed));
}
//bearing
@@ -259,7 +274,7 @@ namespace AndroidPositioning {
if (attributeExists) {
mid = getCachedMethodID(jniEnv, thisClass, "getBearing", "()F");
jfloat bearing = jniEnv->CallFloatMethod(location, mid);
- info.setAttribute(QGeoPositionInfo::Direction, bearing);
+ info.setAttribute(QGeoPositionInfo::Direction, qreal(bearing));
}
jniEnv->DeleteLocalRef(thisClass);
@@ -288,7 +303,7 @@ namespace AndroidPositioning {
//signal strength
jmethodID mid = getCachedMethodID(jniEnv, thisClass, "getSnr", "()F");
jfloat snr = jniEnv->CallFloatMethod(element, mid);
- info.setSignalStrength((int)snr);
+ info.setSignalStrength(int(snr));
//ignore any satellite with no signal whatsoever
if (qFuzzyIsNull(snr))
@@ -307,12 +322,12 @@ namespace AndroidPositioning {
//azimuth
mid = getCachedMethodID(jniEnv, thisClass, "getAzimuth", "()F");
jfloat azimuth = jniEnv->CallFloatMethod(element, mid);
- info.setAttribute(QGeoSatelliteInfo::Azimuth, azimuth);
+ info.setAttribute(QGeoSatelliteInfo::Azimuth, qreal(azimuth));
//elevation
mid = getCachedMethodID(jniEnv, thisClass, "getElevation", "()F");
jfloat elevation = jniEnv->CallFloatMethod(element, mid);
- info.setAttribute(QGeoSatelliteInfo::Elevation, elevation);
+ info.setAttribute(QGeoSatelliteInfo::Elevation, qreal(elevation));
//used in a fix
mid = getCachedMethodID(jniEnv, thisClass, "usedInFix", "()Z");
@@ -339,7 +354,7 @@ namespace AndroidPositioning {
jobject location = env.jniEnv->CallStaticObjectMethod(positioningClass,
lastKnownPositionMethodId,
fromSatellitePositioningMethodsOnly);
- if (location == 0)
+ if (location == nullptr)
return QGeoPositionInfo();
const QGeoPositionInfo info = positionInfoFromJavaLocation(env.jniEnv, location);
@@ -513,6 +528,18 @@ static void locationProvidersDisabled(JNIEnv *env, jobject /*thiz*/, jint androi
QMetaObject::invokeMethod(source, "locationProviderDisabled", Qt::AutoConnection);
}
+static void locationProvidersChanged(JNIEnv *env, jobject /*thiz*/, jint androidClassKey)
+{
+ Q_UNUSED(env);
+ QObject *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
+ if (!source) {
+ qWarning("locationProvidersChanged: source == 0");
+ return;
+ }
+
+ QMetaObject::invokeMethod(source, "locationProvidersChanged", Qt::AutoConnection);
+}
+
static void satelliteUpdated(JNIEnv *env, jobject /*thiz*/, jobjectArray satellites, jint androidClassKey, jboolean isSingleUpdate)
{
QList<QGeoSatelliteInfo> inUse;
@@ -520,7 +547,7 @@ static void satelliteUpdated(JNIEnv *env, jobject /*thiz*/, jobjectArray satelli
QGeoSatelliteInfoSourceAndroid *source = AndroidPositioning::idToSatSource()->value(androidClassKey);
if (!source) {
- qFatal("satelliteUpdated: source == 0");
+ qWarning("satelliteUpdated: source == 0");
return;
}
@@ -549,7 +576,8 @@ if (!VAR) { \
static JNINativeMethod methods[] = {
{"positionUpdated", "(Landroid/location/Location;IZ)V", (void *)positionUpdated},
{"locationProvidersDisabled", "(I)V", (void *) locationProvidersDisabled},
- {"satelliteUpdated", "([Landroid/location/GpsSatellite;IZ)V", (void *)satelliteUpdated}
+ {"satelliteUpdated", "([Landroid/location/GpsSatellite;IZ)V", (void *)satelliteUpdated},
+ {"locationProvidersChanged", "(I)V", (void *) locationProvidersChanged}
};
static bool registerNatives(JNIEnv *env)
@@ -587,8 +615,8 @@ Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/)
__android_log_print(ANDROID_LOG_INFO, logTag, "Positioning start");
UnionJNIEnvToVoid uenv;
- uenv.venv = NULL;
- javaVM = 0;
+ uenv.venv = nullptr;
+ javaVM = nullptr;
if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK) {
__android_log_print(ANDROID_LOG_FATAL, logTag, "GetEnv failed");
diff --git a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp b/src/plugins/position/android/src/qgeopositioninfosource_android.cpp
index 59b8beab..38778ec4 100644
--- a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp
+++ b/src/plugins/position/android/src/qgeopositioninfosource_android.cpp
@@ -206,6 +206,11 @@ void QGeoPositionInfoSourceAndroid::locationProviderDisabled()
setError(QGeoPositionInfoSource::ClosedError);
}
+void QGeoPositionInfoSourceAndroid::locationProvidersChanged()
+{
+ emit supportedPositioningMethodsChanged();
+}
+
void QGeoPositionInfoSourceAndroid::requestTimeout()
{
AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
diff --git a/src/plugins/position/android/src/qgeopositioninfosource_android_p.h b/src/plugins/position/android/src/qgeopositioninfosource_android_p.h
index dbb27f83..61e107b1 100644
--- a/src/plugins/position/android/src/qgeopositioninfosource_android_p.h
+++ b/src/plugins/position/android/src/qgeopositioninfosource_android_p.h
@@ -79,6 +79,7 @@ public Q_SLOTS:
void processSinglePositionUpdate(const QGeoPositionInfo& pInfo);
void locationProviderDisabled();
+ void locationProvidersChanged();
private Q_SLOTS:
void requestTimeout();
diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp
index 139a6b3d..b55d2ba3 100644
--- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp
+++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp
@@ -179,7 +179,6 @@ int QGeoPositionInfoSourceWinRT::init()
});
if (FAILED(hr)) {
setError(QGeoPositionInfoSource::UnknownSourceError);
- qErrnoWarning(hr, "Could not register status changed callback");
return -1;
}
@@ -342,15 +341,17 @@ bool QGeoPositionInfoSourceWinRT::startHandler()
// registered. That could have helped in the single update case
ComPtr<IAsyncOperation<Geoposition*>> op;
hr = d->locator->GetGeopositionAsync(&op);
+ RETURN_HR_IF_FAILED("Could not start position operation");
hr = d->locator->add_PositionChanged(Callback<GeoLocatorPositionHandler>(this,
&QGeoPositionInfoSourceWinRT::onPositionChanged).Get(),
&d->positionToken);
+ RETURN_HR_IF_FAILED("Could not add position handler");
+
return hr;
});
if (FAILED(hr)) {
setError(QGeoPositionInfoSource::UnknownSourceError);
- qErrnoWarning(hr, "Could not add position handler");
return false;
}
diff --git a/src/positioning/qgeocoordinate.cpp b/src/positioning/qgeocoordinate.cpp
index 80904d7c..f3d3ef9c 100644
--- a/src/positioning/qgeocoordinate.cpp
+++ b/src/positioning/qgeocoordinate.cpp
@@ -44,11 +44,28 @@
#include <QHash>
#include <QDataStream>
#include <QDebug>
+#include <QMetaType>
#include <qnumeric.h>
#include <qmath.h>
QT_BEGIN_NAMESPACE
+
+struct CoordinateStreamOperators
+{
+ CoordinateStreamOperators()
+ {
+#ifndef QT_NO_DATASTREAM
+ qRegisterMetaTypeStreamOperators<QGeoCoordinate>();
+#endif
+#ifndef QT_NO_DEBUG_STREAM
+ QMetaType::registerDebugStreamOperator<QGeoCoordinate>();
+#endif
+ }
+};
+Q_GLOBAL_STATIC(CoordinateStreamOperators, initStreamOperators);
+
+
static const double qgeocoordinate_EARTH_MEAN_RADIUS = 6371.0072;
@@ -201,6 +218,9 @@ QGeoMercatorCoordinatePrivate::~QGeoMercatorCoordinatePrivate()
QGeoCoordinate::QGeoCoordinate()
: d(new QGeoCoordinatePrivate)
{
+#ifndef QT_NO_DATASTREAM
+ initStreamOperators();
+#endif
}
/*!
@@ -215,6 +235,10 @@ QGeoCoordinate::QGeoCoordinate()
QGeoCoordinate::QGeoCoordinate(double latitude, double longitude)
: d(new QGeoCoordinatePrivate)
{
+#ifndef QT_NO_DATASTREAM
+ initStreamOperators();
+#endif
+
if (QLocationUtils::isValidLat(latitude) && QLocationUtils::isValidLong(longitude)) {
d->lat = latitude;
d->lng = longitude;
@@ -236,6 +260,10 @@ QGeoCoordinate::QGeoCoordinate(double latitude, double longitude)
QGeoCoordinate::QGeoCoordinate(double latitude, double longitude, double altitude)
: d(new QGeoCoordinatePrivate)
{
+#ifndef QT_NO_DATASTREAM
+ initStreamOperators();
+#endif
+
if (QLocationUtils::isValidLat(latitude) && QLocationUtils::isValidLong(longitude)) {
d->lat = latitude;
d->lng = longitude;
diff --git a/src/positioning/qgeopositioninfosource.cpp b/src/positioning/qgeopositioninfosource.cpp
index cafb4f8a..2e126175 100644
--- a/src/positioning/qgeopositioninfosource.cpp
+++ b/src/positioning/qgeopositioninfosource.cpp
@@ -241,8 +241,10 @@ int QGeoPositionInfoSource::updateInterval() const
If \a methods includes a method that is not supported by the source, the
unsupported method will be ignored.
- If \a methods does not include any methods supported by the source, the
- preferred methods will be set to the set of methods which the source supports.
+ If \a methods does not include a single method available/supported by the source, the
+ preferred methods will be set to the set of methods which the source has available.
+ If the source has no method availabe (e.g. because its Location service is turned off
+ or it does not offer a Location service), the passed \a methods are accepted as they are.
\b {Note:} When reimplementing this method, subclasses must call the
base method implementation to ensure preferredPositioningMethods() returns the correct value.
@@ -251,9 +253,13 @@ int QGeoPositionInfoSource::updateInterval() const
*/
void QGeoPositionInfoSource::setPreferredPositioningMethods(PositioningMethods methods)
{
- d->methods = methods & supportedPositioningMethods();
- if (d->methods == 0) {
- d->methods = supportedPositioningMethods();
+ if (supportedPositioningMethods() != QGeoPositionInfoSource::NoPositioningMethods) {
+ d->methods = methods & supportedPositioningMethods();
+ if (d->methods == 0) {
+ d->methods = supportedPositioningMethods();
+ }
+ } else { // avoid that turned of Location service blocks any changes to d->methods
+ d->methods = methods;
}
}
@@ -355,9 +361,40 @@ QStringList QGeoPositionInfoSource::availableSources()
/*!
\fn virtual PositioningMethods QGeoPositionInfoSource::supportedPositioningMethods() const = 0;
- Returns the positioning methods available to this source.
-
- \sa setPreferredPositioningMethods()
+ Returns the positioning methods available to this source. Availability is defined as being usable
+ at the time of calling this function. Therefore user settings like turned off location service or
+ limitations to Satellite-based position providers are reflected by this function. Runtime notifications
+ when the status changes can be obtained via \l supportedPositioningMethodsChanged().
+
+ Not all platforms distinguish the different positioning methods or communicate the current user
+ configuration of the device. The following table provides an overview of the current platform situation:
+
+ \table
+ \header
+ \li Platform
+ \li Brief Description
+ \row
+ \li Android
+ \li Individual provider status and general Location service state are known and communicated
+ when location service is active.
+ \row
+ \li GeoClue
+ \li Hardcoced to always return AllPositioningMethods.
+ \row
+ \li GeoClue2
+ \li Individual providers are not distinguishable but disabled Location services reflected.
+ \row
+ \li iOS/tvOS
+ \li Hardcoced to always return AllPositioningMethods.
+ \row
+ \li macOS
+ \li Hardcoced to always return AllPositioningMethods.
+ \row
+ \li Windows (UWP)
+ \li Individual providers are not distinguishable but disabled Location services reflected.
+ \endtable
+
+ \sa supportedPositioningMethodsChanged(), setPreferredPositioningMethods()
*/
@@ -479,7 +516,10 @@ QStringList QGeoPositionInfoSource::availableSources()
/*!
\fn void QGeoPositionInfoSource::supportedPositioningMethodsChanged()
- This signal is emitted after the supportedPositioningMethods change.
+ This signal is emitted when the supported positioning methods changed. The cause for a change could be
+ a user turning Location services on/off or restricting Location services to certain types (e.g. GPS only).
+ Note that changes to the supported positioning methods cannot be detected on all platforms.
+ \l supportedPositioningMethods() provides an overview of the current platform support.
\since Qt 5.12
*/
diff --git a/tests/applications/positioning_backend/logwidget.cpp b/tests/applications/positioning_backend/logwidget.cpp
new file mode 100644
index 00000000..5ec47230
--- /dev/null
+++ b/tests/applications/positioning_backend/logwidget.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "logwidget.h"
+#include <QVBoxLayout>
+
+LogWidget::LogWidget(QWidget *parent) : QWidget(parent)
+{
+ QVBoxLayout *verticalLayout = new QVBoxLayout(this);
+ verticalLayout->setSpacing(6);
+ verticalLayout->setContentsMargins(11, 11, 11, 11);
+ verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
+
+ editor = new QPlainTextEdit(this);
+ verticalLayout->addWidget(editor);
+}
+
+void LogWidget::appendLog(const QString &line)
+{
+ editor->appendPlainText(line);
+}
diff --git a/tests/applications/positioning_backend/logwidget.h b/tests/applications/positioning_backend/logwidget.h
new file mode 100644
index 00000000..f6a3eb44
--- /dev/null
+++ b/tests/applications/positioning_backend/logwidget.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LOGWIDGET_H
+#define LOGWIDGET_H
+
+#include <QtWidgets/qwidget.h>
+#include <QtWidgets/qplaintextedit.h>
+
+class LogWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit LogWidget(QWidget *parent = nullptr);
+
+ void appendLog(const QString &line);
+
+private:
+ QPlainTextEdit *editor;
+};
+
+#endif // LOGWIDGET_H
diff --git a/tests/applications/positioning_backend/main.cpp b/tests/applications/positioning_backend/main.cpp
index 930f1c9c..52115556 100644
--- a/tests/applications/positioning_backend/main.cpp
+++ b/tests/applications/positioning_backend/main.cpp
@@ -26,6 +26,7 @@
**
****************************************************************************/
#include "widget.h"
+#include "logwidget.h"
#include <QLabel>
#include <QApplication>
@@ -34,14 +35,16 @@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- Widget *w1 = new Widget;
- Widget *w2 = new Widget;
+ LogWidget *log = new LogWidget;
+ Widget *w1 = new Widget(log);
+ Widget *w2 = new Widget(log);
QTabWidget tabWidget;
tabWidget.setTabPosition(QTabWidget::South);
tabWidget.addTab(w1, "Instance 1");
tabWidget.addTab(w2, "Instance 2");
+ tabWidget.addTab(log, "Logs");
tabWidget.show();
return a.exec();
diff --git a/tests/applications/positioning_backend/positioning_backend.pro b/tests/applications/positioning_backend/positioning_backend.pro
index 410dbc86..4ba9e7c8 100644
--- a/tests/applications/positioning_backend/positioning_backend.pro
+++ b/tests/applications/positioning_backend/positioning_backend.pro
@@ -5,9 +5,11 @@ TEMPLATE = app
SOURCES += main.cpp\
- widget.cpp
+ widget.cpp \
+ logwidget.cpp
-HEADERS += widget.h
+HEADERS += widget.h \
+ logwidget.h
FORMS += widget.ui
diff --git a/tests/applications/positioning_backend/widget.cpp b/tests/applications/positioning_backend/widget.cpp
index 93a42a80..efdaebdd 100644
--- a/tests/applications/positioning_backend/widget.cpp
+++ b/tests/applications/positioning_backend/widget.cpp
@@ -30,8 +30,9 @@
#include <QGeoPositionInfoSource>
#include <QDebug>
-Widget::Widget(QWidget *parent) :
+Widget::Widget(LogWidget *logWidget, QWidget *parent) :
QWidget(parent),
+ log(logWidget),
ui(new Ui::Widget)
{
ui->setupUi(this);
@@ -53,6 +54,15 @@ Widget::Widget(QWidget *parent) :
connect(m_posSource, SIGNAL(error(QGeoPositionInfoSource::Error)),
this, SLOT(errorChanged(QGeoPositionInfoSource::Error)));
+ connect(m_posSource, &QGeoPositionInfoSource::supportedPositioningMethodsChanged,
+ this, [this]() {
+ auto methods = m_posSource->supportedPositioningMethods();
+ const QString status = QStringLiteral("Satellite: %1 ").arg(bool(methods & QGeoPositionInfoSource::SatellitePositioningMethods))
+ + QStringLiteral("Non-Satellite: %1").arg(bool(methods & QGeoPositionInfoSource::NonSatellitePositioningMethods));
+
+ qDebug() << "Available Positioning Methods Changed" << status;
+ log->appendLog(status);
+ });
}
void Widget::positionUpdated(QGeoPositionInfo gpsPos)
@@ -81,6 +91,8 @@ void Widget::positionUpdated(QGeoPositionInfo gpsPos)
ui->labelSpeed->setText(QString::number(gpsPos.attribute(QGeoPositionInfo::GroundSpeed)));
else
ui->labelSpeed->setText(QStringLiteral("N/A"));
+
+ log->appendLog(coord.toString());
}
void Widget::positionTimedOut()
diff --git a/tests/applications/positioning_backend/widget.h b/tests/applications/positioning_backend/widget.h
index fc04c423..b67e53b8 100644
--- a/tests/applications/positioning_backend/widget.h
+++ b/tests/applications/positioning_backend/widget.h
@@ -28,6 +28,8 @@
#ifndef WIDGET_H
#define WIDGET_H
+#include "logwidget.h"
+
#include <QWidget>
#include <QGeoPositionInfoSource>
@@ -40,7 +42,7 @@ class Widget : public QWidget
Q_OBJECT
public:
- explicit Widget(QWidget *parent = 0);
+ explicit Widget(LogWidget *log, QWidget *parent = nullptr);
~Widget();
public slots:
@@ -59,6 +61,7 @@ private slots:
void on_buttonUpdateSupported_clicked();
private:
+ LogWidget *log = nullptr;
Ui::Widget *ui;
QGeoPositionInfoSource *m_posSource;
};