summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--examples/positioning/weatherinfo/appmodel.cpp36
-rw-r--r--examples/positioning/weatherinfo/appmodel.h7
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroutemodel.cpp1
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroutemodel_p.h3
-rw-r--r--src/location/maps/qgeorouterequest.cpp2
-rw-r--r--src/location/maps/qgeorouterequest.h3
-rw-r--r--src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp19
-rw-r--r--src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp2
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp1
-rw-r--r--src/plugins/geoservices/nokia/qgeouriprovider.cpp3
-rw-r--r--src/plugins/position/android/src/jnipositioning.cpp6
-rw-r--r--src/positioning/qgeopath.cpp16
-rw-r--r--src/positioning/qgeopath.h1
-rw-r--r--src/positioning/qgeopath_p.h1
-rw-r--r--tests/auto/declarative_ui/tst_map_item_fit_viewport.qml4
-rw-r--r--tests/auto/qgeopath/tst_qgeopath.cpp27
-rw-r--r--tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp8
18 files changed, 90 insertions, 52 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 0f643096..4afd972d 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,4 +1,4 @@
load(qt_build_config)
CONFIG += warning_clean
-MODULE_VERSION = 5.9.2
+MODULE_VERSION = 5.10.0
diff --git a/examples/positioning/weatherinfo/appmodel.cpp b/examples/positioning/weatherinfo/appmodel.cpp
index 4d8806b8..f17d8141 100644
--- a/examples/positioning/weatherinfo/appmodel.cpp
+++ b/examples/positioning/weatherinfo/appmodel.cpp
@@ -47,7 +47,6 @@
#include <qnetworkconfigmanager.h>
#include <qnetworksession.h>
-#include <QSignalMapper>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
@@ -145,8 +144,6 @@ public:
WeatherData now;
QList<WeatherData*> forecast;
QQmlListProperty<WeatherData> *fcProp;
- QSignalMapper *geoReplyMapper;
- QSignalMapper *weatherReplyMapper, *forecastReplyMapper;
bool ready;
bool useGps;
QElapsedTimer throttle;
@@ -210,16 +207,6 @@ AppModel::AppModel(QObject *parent) :
forecastAt,
forecastClear);
- d->geoReplyMapper = new QSignalMapper(this);
- d->weatherReplyMapper = new QSignalMapper(this);
- d->forecastReplyMapper = new QSignalMapper(this);
-
- connect(d->geoReplyMapper, SIGNAL(mapped(QObject*)),
- this, SLOT(handleGeoNetworkData(QObject*)));
- connect(d->weatherReplyMapper, SIGNAL(mapped(QObject*)),
- this, SLOT(handleWeatherNetworkData(QObject*)));
- connect(d->forecastReplyMapper, SIGNAL(mapped(QObject*)),
- this, SLOT(handleForecastNetworkData(QObject*)));
connect(&d->delayedCityRequestTimer, SIGNAL(timeout()),
this, SLOT(queryCity()));
connect(&d->requestNewWeatherTimer, SIGNAL(timeout()),
@@ -312,9 +299,8 @@ void AppModel::queryCity()
QNetworkReply *rep = d->nam->get(QNetworkRequest(url));
// connect up the signal right away
- d->geoReplyMapper->setMapping(rep, rep);
- connect(rep, SIGNAL(finished()),
- d->geoReplyMapper, SLOT(map()));
+ connect(rep, &QNetworkReply::finished,
+ this, [this, rep]() { handleGeoNetworkData(rep); });
}
void AppModel::positionError(QGeoPositionInfoSource::Error e)
@@ -344,9 +330,8 @@ void AppModel::hadError(bool tryAgain)
d->delayedCityRequestTimer.start();
}
-void AppModel::handleGeoNetworkData(QObject *replyObj)
+void AppModel::handleGeoNetworkData(QNetworkReply *networkReply)
{
- QNetworkReply *networkReply = qobject_cast<QNetworkReply*>(replyObj);
if (!networkReply) {
hadError(false); // should retry?
return;
@@ -393,9 +378,8 @@ void AppModel::refreshWeather()
QNetworkReply *rep = d->nam->get(QNetworkRequest(url));
// connect up the signal right away
- d->weatherReplyMapper->setMapping(rep, rep);
- connect(rep, SIGNAL(finished()),
- d->weatherReplyMapper, SLOT(map()));
+ connect(rep, &QNetworkReply::finished,
+ this, [this, rep]() { handleWeatherNetworkData(rep); });
}
static QString niceTemperatureString(double t)
@@ -403,10 +387,9 @@ static QString niceTemperatureString(double t)
return QString::number(qRound(t-ZERO_KELVIN)) + QChar(0xB0);
}
-void AppModel::handleWeatherNetworkData(QObject *replyObj)
+void AppModel::handleWeatherNetworkData(QNetworkReply *networkReply)
{
qCDebug(requestsLog) << "got weather network data";
- QNetworkReply *networkReply = qobject_cast<QNetworkReply*>(replyObj);
if (!networkReply)
return;
@@ -452,14 +435,13 @@ void AppModel::handleWeatherNetworkData(QObject *replyObj)
QNetworkReply *rep = d->nam->get(QNetworkRequest(url));
// connect up the signal right away
- d->forecastReplyMapper->setMapping(rep, rep);
- connect(rep, SIGNAL(finished()), d->forecastReplyMapper, SLOT(map()));
+ connect(rep, &QNetworkReply::finished,
+ this, [this, rep]() { handleForecastNetworkData(rep); });
}
-void AppModel::handleForecastNetworkData(QObject *replyObj)
+void AppModel::handleForecastNetworkData(QNetworkReply *networkReply)
{
qCDebug(requestsLog) << "got forecast";
- QNetworkReply *networkReply = qobject_cast<QNetworkReply*>(replyObj);
if (!networkReply)
return;
diff --git a/examples/positioning/weatherinfo/appmodel.h b/examples/positioning/weatherinfo/appmodel.h
index 024f314f..9809284b 100644
--- a/examples/positioning/weatherinfo/appmodel.h
+++ b/examples/positioning/weatherinfo/appmodel.h
@@ -149,10 +149,9 @@ private slots:
void networkSessionOpened();
void positionUpdated(QGeoPositionInfo gpsPos);
void positionError(QGeoPositionInfoSource::Error e);
- // these would have QNetworkReply* params but for the signalmapper
- void handleGeoNetworkData(QObject *networkReply);
- void handleWeatherNetworkData(QObject *networkReply);
- void handleForecastNetworkData(QObject *networkReply);
+ void handleGeoNetworkData(QNetworkReply *networkReply);
+ void handleWeatherNetworkData(QNetworkReply *networkReply);
+ void handleForecastNetworkData(QNetworkReply *networkReply);
//! [3]
signals:
diff --git a/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp b/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
index 94bd63c8..0383c0c4 100644
--- a/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
+++ b/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
@@ -722,6 +722,7 @@ void QDeclarativeGeoRouteQuery::componentComplete()
\li RouteQuery.DirtRoadFeature - Consider dirt roads when planning the route
\li RouteQuery.ParksFeature - Consider parks when planning the route
\li RouteQuery.MotorPoolLaneFeature - Consider motor pool lanes when planning the route
+ \li RouteQuery.TrafficFeature - Consider traffic when planning the route
\endlist
\sa setFeatureWeight, featureWeight
diff --git a/src/location/declarativemaps/qdeclarativegeoroutemodel_p.h b/src/location/declarativemaps/qdeclarativegeoroutemodel_p.h
index 3dfd2ce6..18486ac8 100644
--- a/src/location/declarativemaps/qdeclarativegeoroutemodel_p.h
+++ b/src/location/declarativemaps/qdeclarativegeoroutemodel_p.h
@@ -238,7 +238,8 @@ public:
TunnelFeature = QGeoRouteRequest::TunnelFeature,
DirtRoadFeature = QGeoRouteRequest::DirtRoadFeature,
ParksFeature = QGeoRouteRequest::ParksFeature,
- MotorPoolLaneFeature = QGeoRouteRequest::MotorPoolLaneFeature
+ MotorPoolLaneFeature = QGeoRouteRequest::MotorPoolLaneFeature,
+ TrafficFeature = QGeoRouteRequest::TrafficFeature
};
Q_DECLARE_FLAGS(FeatureTypes, FeatureType)
diff --git a/src/location/maps/qgeorouterequest.cpp b/src/location/maps/qgeorouterequest.cpp
index 753d2ee9..a1b32d85 100644
--- a/src/location/maps/qgeorouterequest.cpp
+++ b/src/location/maps/qgeorouterequest.cpp
@@ -134,6 +134,8 @@ QT_BEGIN_NAMESPACE
Consider parks when planning the route.
\value MotorPoolLaneFeature
Consider motor pool lanes when planning the route.
+ \value TrafficFeature
+ Consider the current traffic situation when planning the route. Since QtLocation 5.10
*/
/*!
diff --git a/src/location/maps/qgeorouterequest.h b/src/location/maps/qgeorouterequest.h
index 6fcc7ad3..cf89d13d 100644
--- a/src/location/maps/qgeorouterequest.h
+++ b/src/location/maps/qgeorouterequest.h
@@ -70,7 +70,8 @@ public:
TunnelFeature = 0x00000010,
DirtRoadFeature = 0x00000020,
ParksFeature = 0x00000040,
- MotorPoolLaneFeature = 0x00000080
+ MotorPoolLaneFeature = 0x00000080,
+ TrafficFeature = 0x00000100
};
Q_DECLARE_FLAGS(FeatureTypes, FeatureType)
diff --git a/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp
index f5776852..78ccab8c 100644
--- a/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp
@@ -77,14 +77,21 @@ QGeoRouteReply* QGeoRoutingManagerEngineMapbox::calculateRoute(const QGeoRouteRe
QString url("https://api.mapbox.com/directions/v5/mapbox/");
QGeoRouteRequest::TravelModes travelModes = request.travelModes();
- if (travelModes.testFlag(QGeoRouteRequest::PedestrianTravel))
+ if (travelModes.testFlag(QGeoRouteRequest::PedestrianTravel)) {
url += "walking/";
- else
- if (travelModes.testFlag(QGeoRouteRequest::BicycleTravel))
+ } else if (travelModes.testFlag(QGeoRouteRequest::BicycleTravel)) {
url += "cycling/";
- else
- if (travelModes.testFlag(QGeoRouteRequest::CarTravel))
- url += "driving/";
+ } else if (travelModes.testFlag(QGeoRouteRequest::CarTravel)) {
+ const QList<QGeoRouteRequest::FeatureType> &featureTypes = request.featureTypes();
+ int trafficFeatureIdx = featureTypes.indexOf(QGeoRouteRequest::TrafficFeature);
+ QGeoRouteRequest::FeatureWeight trafficWeight = request.featureWeight(QGeoRouteRequest::TrafficFeature);
+ if (trafficFeatureIdx >= 0 &&
+ (trafficWeight == QGeoRouteRequest::AvoidFeatureWeight || trafficWeight == QGeoRouteRequest::DisallowFeatureWeight)) {
+ url += "driving-traffic/";
+ } else {
+ url += "driving/";
+ }
+ }
foreach (const QGeoCoordinate &c, request.waypoints()) {
url += QString("%1,%2;").arg(c.longitude()).arg(c.latitude());
diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp
index 3b9026ce..c82b98f3 100644
--- a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp
+++ b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp
@@ -425,7 +425,7 @@ void QGeoMapMapboxGL::copyrightsChanged(const QString &copyrightsHtml)
if (d->m_developmentMode) {
copyrightsHtmlFinal.prepend("<a href='https://www.mapbox.com/pricing'>"
- + tr("Development access token, do not use in production!") + "</a> - ");
+ + tr("Development access token, do not use in production.") + "</a> - ");
}
if (d->m_activeMapType.name().startsWith("mapbox://")) {
diff --git a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
index a33d1ba8..d7e4cf8d 100644
--- a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
@@ -360,6 +360,7 @@ QString QGeoRoutingManagerEngineNokia::modesRequestString(const QGeoRouteRequest
case QGeoRouteRequest::PublicTransitFeature:
case QGeoRouteRequest::ParksFeature:
case QGeoRouteRequest::MotorPoolLaneFeature:
+ case QGeoRouteRequest::TrafficFeature:
case QGeoRouteRequest::NoFeature:
break;
}
diff --git a/src/plugins/geoservices/nokia/qgeouriprovider.cpp b/src/plugins/geoservices/nokia/qgeouriprovider.cpp
index 80b47f31..f36a6694 100644
--- a/src/plugins/geoservices/nokia/qgeouriprovider.cpp
+++ b/src/plugins/geoservices/nokia/qgeouriprovider.cpp
@@ -37,6 +37,7 @@
#include <QMap>
#include <QVariant>
+#include <QRandomGenerator>
#include <QSet>
#include <QString>
@@ -60,7 +61,7 @@ QGeoUriProvider::QGeoUriProvider(
QString QGeoUriProvider::getCurrentHost() const
{
if (m_maxSubdomains) {
- QString result(m_firstSubdomain.toLatin1() + qrand() % m_maxSubdomains);
+ QString result(m_firstSubdomain.toLatin1() + QRandomGenerator::bounded(m_maxSubdomains));
result += '.' + m_currentHost;
return result;
}
diff --git a/src/plugins/position/android/src/jnipositioning.cpp b/src/plugins/position/android/src/jnipositioning.cpp
index 9bd49e90..e79e64d5 100644
--- a/src/plugins/position/android/src/jnipositioning.cpp
+++ b/src/plugins/position/android/src/jnipositioning.cpp
@@ -40,6 +40,7 @@
#include <QDateTime>
#include <QDebug>
#include <QMap>
+#include <QRandomGenerator>
#include <QtGlobal>
#include <QtCore/private/qjnihelpers_p.h>
#include <android/log.h>
@@ -100,7 +101,6 @@ namespace AndroidPositioning {
{
static bool firstInit = true;
if (firstInit) {
- qsrand( QDateTime::currentMSecsSinceEpoch() / 1000 );
firstInit = false;
}
@@ -109,7 +109,7 @@ namespace AndroidPositioning {
QGeoPositionInfoSourceAndroid *src = qobject_cast<QGeoPositionInfoSourceAndroid *>(obj);
Q_ASSERT(src);
do {
- key = qrand();
+ key = QRandomGenerator::get32();
} 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 = qrand();
+ key = QRandomGenerator::get32();
} while (idToSatSource()->contains(key));
idToSatSource()->insert(key, src);
diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp
index ad3536af..858dc0bd 100644
--- a/src/positioning/qgeopath.cpp
+++ b/src/positioning/qgeopath.cpp
@@ -247,6 +247,17 @@ double QGeoPath::length(int indexFrom, int indexTo) const
}
/*!
+ Returns the number of elements in the path.
+
+ \since 5.10
+*/
+int QGeoPath::size() const
+{
+ Q_D(const QGeoPath);
+ return d->size();
+}
+
+/*!
Appends \a coordinate to the path.
*/
void QGeoPath::addCoordinate(const QGeoCoordinate &coordinate)
@@ -415,6 +426,11 @@ double QGeoPathPrivate::length(int indexFrom, int indexTo) const
return len;
}
+int QGeoPathPrivate::size() const
+{
+ return m_path.size();
+}
+
/*!
Returns true if coordinate is present in m_path.
*/
diff --git a/src/positioning/qgeopath.h b/src/positioning/qgeopath.h
index 09a53a49..ad41c23c 100644
--- a/src/positioning/qgeopath.h
+++ b/src/positioning/qgeopath.h
@@ -78,6 +78,7 @@ public:
Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude);
Q_INVOKABLE QGeoPath translated(double degreesLatitude, double degreesLongitude) const;
Q_INVOKABLE double length(int indexFrom = 0, int indexTo = -1) const;
+ Q_INVOKABLE int size() const;
Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate);
Q_INVOKABLE void insertCoordinate(int index, const QGeoCoordinate &coordinate);
Q_INVOKABLE void replaceCoordinate(int index, const QGeoCoordinate &coordinate);
diff --git a/src/positioning/qgeopath_p.h b/src/positioning/qgeopath_p.h
index 2256796d..48334017 100644
--- a/src/positioning/qgeopath_p.h
+++ b/src/positioning/qgeopath_p.h
@@ -85,6 +85,7 @@ public:
qreal width() const;
void setWidth(const qreal &width);
double length(int indexFrom, int indexTo) const;
+ int size() const;
void addCoordinate(const QGeoCoordinate &coordinate);
void insertCoordinate(int index, const QGeoCoordinate &coordinate);
void replaceCoordinate(int index, const QGeoCoordinate &coordinate);
diff --git a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
index adf9c347..8d1ee42b 100644
--- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
+++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
@@ -572,13 +572,13 @@ Item {
}
function calculate_fit_circle_bounds() {
- var circleDiagonal = Math.sqrt(2 * fitCircle.radius * fitCircle.radius)
+ var circleDiagonal = Math.sqrt(2) * fitCircle.radius
fitCircleTopLeft = fitCircle.center.atDistanceAndAzimuth(circleDiagonal,-45)
fitCircleBottomRight = fitCircle.center.atDistanceAndAzimuth(circleDiagonal,135)
}
function calculate_bounds(){
- var circleDiagonal = Math.sqrt(2 * preMapCircle.radius * preMapCircle.radius)
+ var circleDiagonal = Math.sqrt(2) * preMapCircle.radius
var itemTopLeft = preMapCircle.center.atDistanceAndAzimuth(circleDiagonal,-45)
var itemBottomRight = preMapCircle.center.atDistanceAndAzimuth(circleDiagonal,135)
diff --git a/tests/auto/qgeopath/tst_qgeopath.cpp b/tests/auto/qgeopath/tst_qgeopath.cpp
index 9244394a..86ff137d 100644
--- a/tests/auto/qgeopath/tst_qgeopath.cpp
+++ b/tests/auto/qgeopath/tst_qgeopath.cpp
@@ -47,6 +47,7 @@ private slots:
void path();
void width();
+ void size();
void translate_data();
void translate();
@@ -188,6 +189,32 @@ void tst_QGeoPath::width()
QCOMPARE(p.width(), qreal(10.0));
}
+void tst_QGeoPath::size()
+{
+ QList<QGeoCoordinate> coords;
+
+ QGeoPath p1(coords, 3);
+ QCOMPARE(p1.size(), coords.size());
+
+ coords.append(QGeoCoordinate(1,1));
+ QGeoPath p2(coords, 3);
+ QCOMPARE(p2.size(), coords.size());
+
+ coords.append(QGeoCoordinate(2,2));
+ QGeoPath p3(coords, 3);
+ QCOMPARE(p3.size(), coords.size());
+
+ coords.append(QGeoCoordinate(3,0));
+ QGeoPath p4(coords, 3);
+ QCOMPARE(p4.size(), coords.size());
+
+ p4.removeCoordinate(2);
+ QCOMPARE(p4.size(), coords.size() - 1);
+
+ p4.removeCoordinate(coords.first());
+ QCOMPARE(p4.size(), coords.size() - 2);
+}
+
void tst_QGeoPath::translate_data()
{
QTest::addColumn<QGeoCoordinate>("c1");
diff --git a/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp b/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp
index e0004596..e4bb755d 100644
--- a/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp
+++ b/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp
@@ -41,8 +41,6 @@ QDeclarativeLocationTestModel::QDeclarativeLocationTestModel(QObject *parent):
crazyLevel_(0),
crazyMode_(false)
{
- // seed crazy random generator
- qsrand(QTime(0,0,0).secsTo(QTime::currentTime()) + QCoreApplication::applicationPid());
timer_.setSingleShot(true);
connect(&timer_, SIGNAL(timeout()), this, SLOT(timerFired()));
}
@@ -63,7 +61,7 @@ void QDeclarativeLocationTestModel::timerFired()
repopulate();
if (crazyMode_) {
//qDebug() << "raw randomw value: " << qrand();
- int delay = (qAbs(qrand()) % crazyLevel_); // writing software is exact science
+ int delay = (QRandomGenerator::bounded(uint(INT_MAX) + 1) % crazyLevel_); // writing software is exact science
delay = qMax(1000, delay); // 3 ms at minimum
qDebug() << "starting timer with : " << delay;
timer_.start(delay);
@@ -164,7 +162,7 @@ void QDeclarativeLocationTestModel::repopulate()
}
int datacount = datacount_;
if (crazyMode_)
- datacount = (qAbs(qrand()) % datacount_);
+ datacount = QRandomGenerator::bounded(datacount_);
for (int i = 0; i < datacount; ++i) {
DataObject* dataobject = new DataObject;
@@ -206,7 +204,7 @@ void QDeclarativeLocationTestModel::scheduleRepopulation()
if (crazyMode_) {
// start generating arbitrary amount of data at arbitrary intervals
- int delay = (qAbs(qrand()) % crazyLevel_); // writing software is exact science
+ int delay = QRandomGenerator::bounded(crazyLevel_); // writing software is exact science
delay = qMax(3, delay); // 3 ms at minimum
qDebug() << "starting timer with : " << delay;
timer_.start(delay);