summaryrefslogtreecommitdiff
path: root/src/location/declarativemaps
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-09-11 16:02:55 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-09-11 16:03:23 +0200
commit5f26c3afbacd370eca53692eb3c9327c072d5fcf (patch)
tree1a875cee2fa1a85f9b61143875f72f5c8a7259b5 /src/location/declarativemaps
parent8ac6377e62af803b567449cdf30c669b92114cc4 (diff)
parentdcc9ec9e9ab3eaada5c68896833c14f905084922 (diff)
downloadqtlocation-5f26c3afbacd370eca53692eb3c9327c072d5fcf.tar.gz
Merge remote-tracking branch 'origin/dev' into wip/navigation
Change-Id: I764e0c54168b4d4f4fc029d69a10e915332c457d
Diffstat (limited to 'src/location/declarativemaps')
-rw-r--r--src/location/declarativemaps/qdeclarativecirclemapitem.cpp10
-rw-r--r--src/location/declarativemaps/qdeclarativecirclemapitem_p.h8
-rw-r--r--src/location/declarativemaps/qdeclarativegeocodemodel.cpp3
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp16
-rw-r--r--src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp59
-rw-r--r--src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h5
-rw-r--r--src/location/declarativemaps/qquickgeomapgesturearea.cpp6
7 files changed, 86 insertions, 21 deletions
diff --git a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
index 5f002bf9..91328dc7 100644
--- a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
@@ -262,7 +262,7 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QList<QDoubleVector2D
sourceBounds_ = screenBounds_;
}
-static bool crossEarthPole(const QGeoCoordinate &center, qreal distance)
+bool QDeclarativeCircleMapItem::crossEarthPole(const QGeoCoordinate &center, qreal distance)
{
qreal poleLat = 90;
QGeoCoordinate northPole = QGeoCoordinate(poleLat, center.longitude());
@@ -275,7 +275,7 @@ static bool crossEarthPole(const QGeoCoordinate &center, qreal distance)
return false;
}
-static void calculatePeripheralPoints(QList<QGeoCoordinate> &path,
+void QDeclarativeCircleMapItem::calculatePeripheralPoints(QList<QGeoCoordinate> &path,
const QGeoCoordinate &center,
qreal distance,
int steps,
@@ -644,9 +644,9 @@ void QDeclarativeCircleMapItem::updateCirclePathForRendering(QList<QDoubleVector
const QGeoCoordinate &center,
qreal distance)
{
- qreal poleLat = 90;
- qreal distanceToNorthPole = center.distanceTo(QGeoCoordinate(poleLat, 0));
- qreal distanceToSouthPole = center.distanceTo(QGeoCoordinate(-poleLat, 0));
+ const qreal poleLat = 90;
+ const qreal distanceToNorthPole = center.distanceTo(QGeoCoordinate(poleLat, 0));
+ const qreal distanceToSouthPole = center.distanceTo(QGeoCoordinate(-poleLat, 0));
bool crossNorthPole = distanceToNorthPole < distance;
bool crossSouthPole = distanceToSouthPole < distance;
diff --git a/src/location/declarativemaps/qdeclarativecirclemapitem_p.h b/src/location/declarativemaps/qdeclarativecirclemapitem_p.h
index 15774427..c117b444 100644
--- a/src/location/declarativemaps/qdeclarativecirclemapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativecirclemapitem_p.h
@@ -96,6 +96,12 @@ public:
const QGeoShape &geoShape() const Q_DECL_OVERRIDE;
QGeoMap::ItemType itemType() const Q_DECL_OVERRIDE;
+ static bool crossEarthPole(const QGeoCoordinate &center, qreal distance);
+ static void calculatePeripheralPoints(QList<QGeoCoordinate> &path, const QGeoCoordinate &center,
+ qreal distance, int steps, QGeoCoordinate &leftBound);
+ bool preserveCircleGeometry(QList<QDoubleVector2D> &path, const QGeoCoordinate &center,
+ qreal distance);
+
Q_SIGNALS:
void centerChanged(const QGeoCoordinate &center);
void radiusChanged(qreal radius);
@@ -111,8 +117,6 @@ protected Q_SLOTS:
private:
void updateCirclePath();
- bool preserveCircleGeometry(QList<QDoubleVector2D> &path, const QGeoCoordinate &center,
- qreal distance);
void updateCirclePathForRendering(QList<QDoubleVector2D> &path, const QGeoCoordinate &center,
qreal distance);
diff --git a/src/location/declarativemaps/qdeclarativegeocodemodel.cpp b/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
index ee435a5a..3e2a1aea 100644
--- a/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
+++ b/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
@@ -319,6 +319,9 @@ void QDeclarativeGeocodeModel::pluginReady()
this, SLOT(geocodeFinished(QGeoCodeReply*)));
connect(geocodingManager, SIGNAL(error(QGeoCodeReply*,QGeoCodeReply::Error,QString)),
this, SLOT(geocodeError(QGeoCodeReply*,QGeoCodeReply::Error,QString)));
+
+ if (complete_ && autoUpdate_)
+ update();
}
/*!
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 37cfc303..9b19a0ac 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -553,26 +553,26 @@ QQuickGeoMapGestureArea *QDeclarativeGeoMap::gesture()
*/
void QDeclarativeGeoMap::populateMap()
{
- QObjectList kids = children();
- QList<QQuickItem *> quickKids = childItems();
- for (int i=0; i < quickKids.count(); ++i)
- kids.append(quickKids.at(i));
+ QSet<QObject *> kids = children().toSet();
+ const QList<QQuickItem *> quickKids = childItems();
+ for (QQuickItem *ite: quickKids)
+ kids.insert(ite);
- for (int i = 0; i < kids.size(); ++i) {
+ for (QObject *k : qAsConst(kids)) {
// dispatch items appropriately
- QDeclarativeGeoMapItemView *mapView = qobject_cast<QDeclarativeGeoMapItemView *>(kids.at(i));
+ QDeclarativeGeoMapItemView *mapView = qobject_cast<QDeclarativeGeoMapItemView *>(k);
if (mapView) {
m_mapViews.append(mapView);
setupMapView(mapView);
continue;
}
- QDeclarativeGeoMapItemBase *mapItem = qobject_cast<QDeclarativeGeoMapItemBase *>(kids.at(i));
+ QDeclarativeGeoMapItemBase *mapItem = qobject_cast<QDeclarativeGeoMapItemBase *>(k);
if (mapItem) {
addMapItem(mapItem);
continue;
}
// Allow to add to the map Map items contained inside a parent QQuickItem, but only those at one level of nesting.
- QDeclarativeGeoMapItemGroup *itemGroup = qobject_cast<QDeclarativeGeoMapItemGroup *>(kids.at(i));
+ QDeclarativeGeoMapItemGroup *itemGroup = qobject_cast<QDeclarativeGeoMapItemGroup *>(k);
if (itemGroup) {
addMapItemGroup(itemGroup);
continue;
diff --git a/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp b/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp
index 4b8b2d7c..9e4fee8a 100644
--- a/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp
+++ b/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp
@@ -113,12 +113,42 @@ void QDeclarativeGeoServiceProvider::setName(const QString &name)
return;
name_ = name;
+
+ if (complete_)
+ tryAttach();
+
+ emit nameChanged(name_);
+}
+
+/*!
+ \internal
+*/
+bool QDeclarativeGeoServiceProvider::parametersReady() {
+ for (const QDeclarativeGeoServiceProviderParameter *p: qAsConst(parameters_)) {
+ if (!p->isInitialized())
+ return false;
+ }
+ return true;
+}
+
+/*!
+ \internal
+*/
+void QDeclarativeGeoServiceProvider::tryAttach()
+{
+ if (!parametersReady())
+ return;
+
delete sharedProvider_;
+ sharedProvider_ = nullptr;
+
+ if (name_.isEmpty())
+ return;
+
sharedProvider_ = new QGeoServiceProvider(name_, parameterMap());
sharedProvider_->setLocale(locales_.at(0));
sharedProvider_->setAllowExperimental(experimental_);
- emit nameChanged(name_);
emit attached();
}
@@ -147,11 +177,17 @@ QStringList QDeclarativeGeoServiceProvider::availableServiceProviders()
void QDeclarativeGeoServiceProvider::componentComplete()
{
complete_ = true;
- if (!name_.isEmpty()) {
- return;
+
+ for (QDeclarativeGeoServiceProviderParameter *p: qAsConst(parameters_)) {
+ if (!p->isInitialized()) {
+ connect(p, &QDeclarativeGeoServiceProviderParameter::initialized,
+ this, &QDeclarativeGeoServiceProvider::tryAttach);
+ }
}
- if (!prefer_.isEmpty()
+ if (!name_.isEmpty()) {
+ tryAttach();
+ } else if (!prefer_.isEmpty()
|| required_->mappingRequirements() != NoMappingFeatures
|| required_->routingRequirements() != NoRoutingFeatures
|| required_->geocodingRequirements() != NoGeocodingFeatures
@@ -796,15 +832,18 @@ QDeclarativeGeoServiceProviderParameter::~QDeclarativeGeoServiceProviderParamete
\qmlproperty string PluginParameter::name
This property holds the name of the plugin parameter as a single formatted string.
+ This property is a write-once property.
*/
void QDeclarativeGeoServiceProviderParameter::setName(const QString &name)
{
- if (name_ == name)
+ if (!name_.isEmpty() || name.isEmpty())
return;
name_ = name;
emit nameChanged(name_);
+ if (value_.isValid())
+ emit initialized();
}
QString QDeclarativeGeoServiceProviderParameter::name() const
@@ -816,15 +855,18 @@ QString QDeclarativeGeoServiceProviderParameter::name() const
\qmlproperty QVariant PluginParameter::value
This property holds the value of the plugin parameter which support different types of values (variant).
+ This property is a write-once property.
*/
void QDeclarativeGeoServiceProviderParameter::setValue(const QVariant &value)
{
- if (value_ == value)
+ if (value_.isValid() || !value.isValid() || value.isNull())
return;
value_ = value;
emit valueChanged(value_);
+ if (!name_.isEmpty())
+ emit initialized();
}
QVariant QDeclarativeGeoServiceProviderParameter::value() const
@@ -832,6 +874,11 @@ QVariant QDeclarativeGeoServiceProviderParameter::value() const
return value_;
}
+bool QDeclarativeGeoServiceProviderParameter::isInitialized() const
+{
+ return !name_.isEmpty() && value_.isValid();
+}
+
/*******************************************************************************
*******************************************************************************/
diff --git a/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h b/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h
index 426c6b4d..c1ad4987 100644
--- a/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h
+++ b/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h
@@ -78,9 +78,12 @@ public:
void setValue(const QVariant &value);
QVariant value() const;
+ bool isInitialized() const;
+
Q_SIGNALS:
void nameChanged(const QString &name);
void valueChanged(const QVariant &value);
+ void initialized();
private:
QString name_;
@@ -210,6 +213,8 @@ Q_SIGNALS:
void allowExperimentalChanged(bool allow);
private:
+ bool parametersReady();
+ void tryAttach();
static void parameter_append(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> *prop, QDeclarativeGeoServiceProviderParameter *mapObject);
static int parameter_count(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> *prop);
static QDeclarativeGeoServiceProviderParameter *parameter_at(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> *prop, int index);
diff --git a/src/location/declarativemaps/qquickgeomapgesturearea.cpp b/src/location/declarativemaps/qquickgeomapgesturearea.cpp
index 99b65766..b1878f00 100644
--- a/src/location/declarativemaps/qquickgeomapgesturearea.cpp
+++ b/src/location/declarativemaps/qquickgeomapgesturearea.cpp
@@ -974,14 +974,20 @@ void QQuickGeoMapGestureArea::handleWheelEvent(QWheelEvent *event)
// Not using AltModifier as, for some reason, it causes angleDelta to be 0
if (event->modifiers() & Qt::ShiftModifier && rotationEnabled()) {
+ emit rotationStarted(&m_pinch.m_event);
// First set bearing
const double bearingDelta = event->angleDelta().y() * qreal(0.05);
m_declarativeMap->setBearing(m_declarativeMap->bearing() + bearingDelta);
// then reanchor
m_declarativeMap->setCenter(m_map->geoProjection().anchorCoordinateToPoint(wheelGeoPos, preZoomPoint));
+ emit rotationUpdated(&m_pinch.m_event);
+ emit rotationFinished(&m_pinch.m_event);
} else if (event->modifiers() & Qt::ControlModifier && tiltEnabled()) {
+ emit tiltStarted(&m_pinch.m_event);
const double tiltDelta = event->angleDelta().y() * qreal(0.05);
m_declarativeMap->setTilt(m_declarativeMap->tilt() + tiltDelta);
+ emit tiltUpdated(&m_pinch.m_event);
+ emit tiltFinished(&m_pinch.m_event);
} else if (pinchEnabled()) {
const double zoomLevelDelta = event->angleDelta().y() * qreal(0.001);
// Gesture area should always honor maxZL, but Map might not.