From ee700d2eeb4508aa5356ddef11bf11964c5d9283 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 19 Oct 2018 09:24:36 +0200 Subject: Mapbox: Only include matching categories in the results If an entry in the results had no categories specified at all then it would end up including this in the results even if a specific category was requested to match against. Change-Id: I506b40b73ec07608bd2b2562d92065376fbb67c9 Reviewed-by: Paolo Angelelli --- src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 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); } -- cgit v1.2.1 From 25c6840ff6585ca9f7ab1c168cdcdd18a68c7885 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 8 Nov 2018 11:27:24 +0100 Subject: Bump version Change-Id: I9eb138dde3677e25a6c40681bd2e1f7fa4765d10 --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index d478439a..634dfd52 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,4 +1,4 @@ load(qt_build_config) CONFIG += warning_clean -MODULE_VERSION = 5.11.2 +MODULE_VERSION = 5.11.3 -- cgit v1.2.1 From 85df79b094d1097108a28424d6f9b3b76b3aee62 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Thu, 8 Nov 2018 15:26:57 +0900 Subject: Fix unstable rotation gesture Order of touch events are not sorted on some platform. When touch point 1 and 2 are swapped, map is rotated 180 degrees in a moment Change-Id: I9c308b805a6ca54519f26a9ff19217de7f947c17 Reviewed-by: Paolo Angelelli --- src/location/declarativemaps/qquickgeomapgesturearea.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/location/declarativemaps/qquickgeomapgesturearea.cpp b/src/location/declarativemaps/qquickgeomapgesturearea.cpp index c6f4b42f..576aeeea 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(); -- cgit v1.2.1 From d9985cd5a308cece06a88e6203529837f00b33aa Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Wed, 3 Oct 2018 12:56:18 +0200 Subject: Fix missing geometry update when changing border width In this case, only border geometry was marked dirty, producing a misplaced polygon. Fixes: QTBUG-70886 Change-Id: Ied39e523a584976871a655e436daf8c2700458b6 Reviewed-by: Alex Blasche --- src/location/declarativemaps/qdeclarativepolygonmapitem.cpp | 13 ++----------- src/location/declarativemaps/qdeclarativepolygonmapitem_p.h | 1 - 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp index c0d7f24b..e9f91e45 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 83983651..60e81b08 100644 --- a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h +++ b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h @@ -118,7 +118,6 @@ protected: protected Q_SLOTS: void markSourceDirtyAndUpdate(); - void handleBorderUpdated(); virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) override; private: -- cgit v1.2.1 From ffac0dc5a60c93663f6a4ea5483422c58cdb52b6 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 16 Nov 2018 09:22:25 +0200 Subject: Add changes file for Qt 5.11.3 + ce1767d724e26012cfcd2eae0143ec9a87984046 Use the correct name for the resource when building statically + 8a7bde9b93208259de65d6b1aef21d21b495b6d7 If a category has UnspecifiedVisibility then we should still match + f9a1c4a18a3421617e28d2c26d30b011d22a0229 Amend 8a7bde9b93 to correctly account for the UnspecifiedVisibility case + 6b109d09982e09940dc8e777430a04410d7b6550 Fix crash when calling QGeoPath::length on empty QGeoPath instance + ee700d2eeb4508aa5356ddef11bf11964c5d9283 Mapbox: Only include matching categories in the results + 25c6840ff6585ca9f7ab1c168cdcdd18a68c7885 Bump version Change-Id: Ie25e5020441b8e0b2b2dcb8f2fc56d68681c69a0 Reviewed-by: Kai Koehne --- dist/changes-5.11.3 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 dist/changes-5.11.3 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. + -- cgit v1.2.1 From b4beb74d93fee205b624c0f0ae6ea39d88d471ac Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Wed, 28 Nov 2018 10:44:35 +0100 Subject: Fix compilation with GCC < 5.0 Apparently unable to resolve QPointers to pointers Change-Id: I04b3b7698ea083f83bc2713530656ca8b3f3ac28 Fixes: QTBUG-69512 Reviewed-by: Alex Blasche --- src/location/declarativemaps/qdeclarativegeomap.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp index 09f9d01c..d8d01b66 100644 --- a/src/location/declarativemaps/qdeclarativegeomap.cpp +++ b/src/location/declarativemaps/qdeclarativegeomap.cpp @@ -694,11 +694,11 @@ void QDeclarativeGeoMap::mappingManagerInitialized() QImage copyrightImage; if (!m_initialized && width() > 0 && height() > 0) { QMetaObject::Connection copyrightStringCatcherConnection = - connect(m_map, + connect(m_map.data(), QOverload::of(&QGeoMap::copyrightsChanged), [©rightString](const QString ©){ copyrightString = copy; }); QMetaObject::Connection copyrightImageCatcherConnection = - connect(m_map, + connect(m_map.data(), QOverload::of(&QGeoMap::copyrightsChanged), [©rightImage](const QImage ©){ copyrightImage = copy; }); m_map->setViewportSize(QSize(width(), height())); @@ -709,9 +709,9 @@ void QDeclarativeGeoMap::mappingManagerInitialized() /* COPYRIGHT SIGNALS REWIRING */ - connect(m_map, SIGNAL(copyrightsChanged(QImage)), + connect(m_map.data(), SIGNAL(copyrightsChanged(QImage)), this, SIGNAL(copyrightsChanged(QImage))); - connect(m_map, SIGNAL(copyrightsChanged(QString)), + connect(m_map.data(), SIGNAL(copyrightsChanged(QString)), this, SIGNAL(copyrightsChanged(QString))); if (!copyrightString.isEmpty()) emit m_map->copyrightsChanged(copyrightString); @@ -719,8 +719,8 @@ void QDeclarativeGeoMap::mappingManagerInitialized() emit m_map->copyrightsChanged(copyrightImage); - connect(m_map, &QGeoMap::sgNodeChanged, this, &QQuickItem::update); - connect(m_map, &QGeoMap::cameraCapabilitiesChanged, this, &QDeclarativeGeoMap::onCameraCapabilitiesChanged); + connect(m_map.data(), &QGeoMap::sgNodeChanged, this, &QQuickItem::update); + connect(m_map.data(), &QGeoMap::cameraCapabilitiesChanged, this, &QDeclarativeGeoMap::onCameraCapabilitiesChanged); // This prefetches a buffer around the map m_map->prefetchData(); -- cgit v1.2.1 From faaa6521dc37fcf4d989f94b6d2a373974357629 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 7 Dec 2018 14:17:32 +0100 Subject: Fix warnings in jnipositioning.cpp Since Android uses a new NDK/compiler since 5.12 there were many more warnings which had serious implications. Examples are potentially flawed downcasts, nullptr warnings and old style casting operators. Change-Id: I53989fa9120c8b7e865d23255d1fcdf229e7f2f3 Reviewed-by: Paolo Angelelli --- .../position/android/src/jnipositioning.cpp | 55 +++++++++++----------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/src/plugins/position/android/src/jnipositioning.cpp b/src/plugins/position/android/src/jnipositioning.cpp index 9bef8d36..c333a9c6 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(&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(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(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(0); + QGeoPositionInfoSource::PositioningMethods ret = QGeoPositionInfoSource::NoPositioningMethods; AttachedJNIEnv env; if (!env.jniEnv) return ret; jintArray jProviders = static_cast(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::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 @@ -241,16 +240,18 @@ namespace AndroidPositioning { 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)); } + + //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 +260,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 +289,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 +308,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 +340,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); @@ -520,7 +521,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; } @@ -587,8 +588,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"); -- cgit v1.2.1 From fa56cc36c287108a095f006fa2083796610afe27 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 7 Dec 2018 14:16:44 +0100 Subject: Ignore Android specific build files They make it impossible to find any other file. Change-Id: I9abe8ea08befab52c00e1d1e60262c637905fbbc Reviewed-by: Paolo Angelelli --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) 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 -- cgit v1.2.1 From 2bb003b7b158890e87731b1a85f3b71008d6284f Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 11 Dec 2018 10:31:42 +0100 Subject: Add ability to visually log position updates in test app This makes it much easier to check received positions outside of debug/console output. Regular updates cannot be received inside a building which means a device can be taken out of the office for further testing without the need to have a developer machine attached. Change-Id: I1a54a1b2fa269ec4ab75aacc4531158a02345382 Reviewed-by: Oliver Wolff --- .../applications/positioning_backend/logwidget.cpp | 46 +++++++++++++++++++++ tests/applications/positioning_backend/logwidget.h | 47 ++++++++++++++++++++++ tests/applications/positioning_backend/main.cpp | 7 +++- .../positioning_backend/positioning_backend.pro | 6 ++- tests/applications/positioning_backend/widget.cpp | 5 ++- tests/applications/positioning_backend/widget.h | 5 ++- 6 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 tests/applications/positioning_backend/logwidget.cpp create mode 100644 tests/applications/positioning_backend/logwidget.h 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 + +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 +#include + +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 #include @@ -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..ae39187d 100644 --- a/tests/applications/positioning_backend/widget.cpp +++ b/tests/applications/positioning_backend/widget.cpp @@ -30,8 +30,9 @@ #include #include -Widget::Widget(QWidget *parent) : +Widget::Widget(LogWidget *logWidget, QWidget *parent) : QWidget(parent), + log(logWidget), ui(new Ui::Widget) { ui->setupUi(this); @@ -81,6 +82,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 #include @@ -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; }; -- cgit v1.2.1 From a4442abdc034de7984e003c821939ce1b1976593 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 12 Dec 2018 13:01:40 +0100 Subject: Collect vertical position accurancy details Android's platform API supports this piece of information since API version 26. Fixes: QTBUG-64689 Change-Id: I09cce4979f3f754cb9af11281de2fe0050b74da1 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/position/android/src/jnipositioning.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/plugins/position/android/src/jnipositioning.cpp b/src/plugins/position/android/src/jnipositioning.cpp index c333a9c6..7d138ce4 100644 --- a/src/plugins/position/android/src/jnipositioning.cpp +++ b/src/plugins/position/android/src/jnipositioning.cpp @@ -234,7 +234,7 @@ 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) { @@ -243,7 +243,21 @@ namespace AndroidPositioning { 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"); -- cgit v1.2.1 From 550abd7159306e5e68f3b73f70319d9fa19bd186 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 14 Dec 2018 15:11:37 +0100 Subject: Enable QVariant::save for QGeoCoordinate Fixes: QTBUG-62682 Fixes: QTBUG-68331 Change-Id: Ibd08934e2b6da06a6b6ff24419e53b87fb2eaa20 Reviewed-by: Paolo Angelelli Reviewed-by: Simon Hausmann --- src/positioning/qgeocoordinate.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/positioning/qgeocoordinate.cpp b/src/positioning/qgeocoordinate.cpp index 80904d7c..414125ca 100644 --- a/src/positioning/qgeocoordinate.cpp +++ b/src/positioning/qgeocoordinate.cpp @@ -44,11 +44,23 @@ #include #include #include +#include #include #include QT_BEGIN_NAMESPACE +#ifndef QT_NO_DATASTREAM +struct CoordinateStreamOperators +{ + CoordinateStreamOperators() + { + qRegisterMetaTypeStreamOperators(); + } +}; +Q_GLOBAL_STATIC(CoordinateStreamOperators, initStreamOperators); +#endif + static const double qgeocoordinate_EARTH_MEAN_RADIUS = 6371.0072; @@ -201,6 +213,9 @@ QGeoMercatorCoordinatePrivate::~QGeoMercatorCoordinatePrivate() QGeoCoordinate::QGeoCoordinate() : d(new QGeoCoordinatePrivate) { +#ifndef QT_NO_DATASTREAM + initStreamOperators(); +#endif } /*! @@ -215,6 +230,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 +255,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; -- cgit v1.2.1 From 100e0416e7faff954221df9ef97920ba512712c0 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 17 Dec 2018 13:34:04 +0100 Subject: Register QGeoCoordinate debug streaming operator This enables the following code: QGeoCoordinate coord(foo, bar); QVariant v; v.setValue(coord) qDebug() << v; Change-Id: I3cc66c359d6be8b8ab9471170ae8763e08c3b3e9 Reviewed-by: Paolo Angelelli --- src/positioning/qgeocoordinate.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/positioning/qgeocoordinate.cpp b/src/positioning/qgeocoordinate.cpp index 414125ca..f3d3ef9c 100644 --- a/src/positioning/qgeocoordinate.cpp +++ b/src/positioning/qgeocoordinate.cpp @@ -50,16 +50,21 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_DATASTREAM + struct CoordinateStreamOperators { CoordinateStreamOperators() { +#ifndef QT_NO_DATASTREAM qRegisterMetaTypeStreamOperators(); +#endif +#ifndef QT_NO_DEBUG_STREAM + QMetaType::registerDebugStreamOperator(); +#endif } }; Q_GLOBAL_STATIC(CoordinateStreamOperators, initStreamOperators); -#endif + static const double qgeocoordinate_EARTH_MEAN_RADIUS = 6371.0072; -- cgit v1.2.1 From 1e24cec7e3ebf5f62f5440d848caf6cd9db1e456 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Tue, 11 Dec 2018 15:21:35 +0900 Subject: Introduce a map plugin parameter to decide U-Turn direction When "uturn" comes from OSRM, Qt returns UTurnLeft since Right Hand Traffic is in use in most countries. This commit allows qml to set traffic side to return correct u-turn direction. Task-number: QTBUG-72462 Change-Id: Ifaa002b063159b4e4ee563d007721ba7a4a587a4 Reviewed-by: Paolo Angelelli --- src/location/maps/qgeorouteparser.cpp | 16 +++++++++++++++- src/location/maps/qgeorouteparser_p.h | 15 ++++++++++++++- src/location/maps/qgeorouteparser_p_p.h | 2 ++ src/location/maps/qgeorouteparserosrmv4.cpp | 21 ++++++++++++++------- src/location/maps/qgeorouteparserosrmv5.cpp | 16 +++++++++++----- .../mapbox/qgeoroutingmanagerenginemapbox.cpp | 8 +++++++- .../geoservices/osm/qgeoroutingmanagerengineosm.cpp | 7 +++++++ 7 files changed, 70 insertions(+), 15 deletions(-) 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 &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 &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 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 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 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 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/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 ¶ 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(); -- cgit v1.2.1 From 04ce8e7f5b7476a08d4f85287e5afb9976ec2d8c Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 19 Dec 2018 14:07:45 +0100 Subject: Fix QGeoPositionInfoSource::supportedPositioningMethods() on Android So far this method returned all existing positioning methods and not the available methods. Availability is defined by customer settings like turning location off or only enabling GPS based positioning. Task-number: QTBUG-66427 Change-Id: Id5b58ee4cc0274bae90ed2e363cb5cf2a287dc05 Reviewed-by: Oliver Wolff Reviewed-by: Timur Pocheptsov Reviewed-by: Paolo Angelelli --- .../jar/src/org/qtproject/qt5/android/positioning/QtPositioning.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..1a53512d 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 providers = locationManager.getAllProviders(); + List 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)) { -- cgit v1.2.1 From 00db28fe2905c6f9b10da65cc777962c373333a6 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 19 Dec 2018 14:55:33 +0100 Subject: Improve QGeoPositionInfoSource::supportedPositioningMethods() docs In particular the differing levels of support on various platforms needed documentation. Task-number: QTBUG-66427 Change-Id: I4c390d14ad69e2f1630e883c8f0a34cbca028a03 Reviewed-by: BogDan Vatra Reviewed-by: Timur Pocheptsov --- src/positioning/qgeopositioninfosource.cpp | 42 +++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/positioning/qgeopositioninfosource.cpp b/src/positioning/qgeopositioninfosource.cpp index cafb4f8a..0230e4ca 100644 --- a/src/positioning/qgeopositioninfosource.cpp +++ b/src/positioning/qgeopositioninfosource.cpp @@ -355,9 +355,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 +510,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 */ -- cgit v1.2.1 From 3c3be256cc1658b0d02047b158228fd55d04e2a0 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 19 Dec 2018 15:59:46 +0100 Subject: Ensure QGeoPositionInfoSource::supportedPositioningMethodsChanged() on Android This signal was added in Qt 5.12 but never emitted on Android. Due to implementation issues this signal is emitted for each provider change (e.g. twice if network and gps provider were disabled when the entire location service is disabled) Task-number: QTBUG-66427 Change-Id: I820b3187bfd8b8ab4facb053e2019e4f5c9736d0 Reviewed-by: Oliver Wolff --- .../qtproject/qt5/android/positioning/QtPositioning.java | 5 +++-- src/plugins/position/android/src/jnipositioning.cpp | 15 ++++++++++++++- .../android/src/qgeopositioninfosource_android.cpp | 5 +++++ .../android/src/qgeopositioninfosource_android_p.h | 1 + 4 files changed, 23 insertions(+), 3 deletions(-) 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 1a53512d..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 @@ -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 7d138ce4..0f358b42 100644 --- a/src/plugins/position/android/src/jnipositioning.cpp +++ b/src/plugins/position/android/src/jnipositioning.cpp @@ -528,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 inUse; @@ -564,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) 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(); -- cgit v1.2.1 From b14145e3fe1bda9af80b043a3b0642510435fc7f Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 19 Dec 2018 16:18:34 +0100 Subject: Prevent potential blockage of setPreferredPositioningMethods() This is useful because on several platforms supportedPositioningMethods() returns NoPositioningMethods while the user has disabled the Location service. At the same time the platforms can only support dynamic supportedPositioningMethodsChanged() notifications after startUpdates() was called. Blocking changes to this property would have been counterproductive as startUpdates() would always fail and notification would not be possible. This affects at least WinRT and Android and Apple platforms need still further investigation. Task-number: QTBUG-66427 Change-Id: Ie03a3ef9c9476d7be3547661eaa87678fdb7b39c Reviewed-by: Oliver Wolff --- src/positioning/qgeopositioninfosource.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/positioning/qgeopositioninfosource.cpp b/src/positioning/qgeopositioninfosource.cpp index 0230e4ca..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; } } -- cgit v1.2.1 From 420128331deef9dd963c9455cab6ef47a8f20a5c Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 20 Dec 2018 15:48:59 +0100 Subject: Enable testing of QGeoPositionSourceInfo::supportedPositioningMethodsChanged() This signal is new and is observable as part of the test application now. Task-number: QTBUG-66427 Change-Id: I3859381f4804112cbf44a365d0c9bb357d068119 Reviewed-by: Oliver Wolff --- tests/applications/positioning_backend/widget.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/applications/positioning_backend/widget.cpp b/tests/applications/positioning_backend/widget.cpp index ae39187d..efdaebdd 100644 --- a/tests/applications/positioning_backend/widget.cpp +++ b/tests/applications/positioning_backend/widget.cpp @@ -54,6 +54,15 @@ Widget::Widget(LogWidget *logWidget, 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) -- cgit v1.2.1 From 81a9c22e75f37c8878d41fa2df249ae20bc44adb Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 3 Jan 2019 10:45:00 +0100 Subject: winrt: Minor improvements in error handling - If more than 1 action is done inside runOnXamlThread any error should cause a "top level" error. - If every possible error inside runOnXamlThread gives a proper error message we do not need another error message outside of the block. Change-Id: I910f9e4bc7984e1c7e1f358eee975738ffa3bb2f Reviewed-by: Andre de la Rocha Reviewed-by: Alex Blasche --- src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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> op; hr = d->locator->GetGeopositionAsync(&op); + RETURN_HR_IF_FAILED("Could not start position operation"); hr = d->locator->add_PositionChanged(Callback(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; } -- cgit v1.2.1 From b1fe421e9a64d57a6135a95453caf847ab6e6e78 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Mon, 7 Jan 2019 09:29:29 +0200 Subject: Bump version Change-Id: Ifc3f75ab0164e3a973e263b68659a7e7dd40d74e --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. -- cgit v1.2.1 From 1688c44d223145abfdca19a7b31faecbafb0d315 Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Sun, 6 Jan 2019 11:36:08 +0100 Subject: Fix MapItemView attempting to instantiate items with map not set This case was not a problem when the only incubation mode was Asynchronous, because the test for m_map was done in createdItem. Now that Synchronous is supported too, this check has to be done earlier or else instantiated items will never be added to the map. Change-Id: Ifaa033fb0b64cabe74df395fcb387d162cd02b80 Reviewed-by: BogDan Vatra --- src/location/declarativemaps/qdeclarativegeomapitemview.cpp | 3 +++ 1 file changed, 3 insertions(+) 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 -- cgit v1.2.1