summaryrefslogtreecommitdiff
path: root/src/location
diff options
context:
space:
mode:
Diffstat (limited to 'src/location')
-rw-r--r--src/location/declarativemaps/qdeclarativegeocodemodel.cpp11
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp207
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap_p.h12
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp71
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h12
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitembase.cpp11
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapquickitem_p.h2
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem.cpp2
-rw-r--r--src/location/maps/qgeomap.cpp19
-rw-r--r--src/location/maps/qgeomap_p.h2
-rw-r--r--src/location/maps/qgeomap_p_p.h4
-rw-r--r--src/location/maps/qgeorouteparserosrmv5.cpp2
-rw-r--r--src/location/maps/qgeotiledmap.cpp16
-rw-r--r--src/location/maps/qgeotiledmap_p.h2
14 files changed, 224 insertions, 149 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeocodemodel.cpp b/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
index b64b2545..9a9a2555 100644
--- a/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
+++ b/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
@@ -385,12 +385,13 @@ void QDeclarativeGeocodeModel::geocodeFinished(QGeoCodeReply *reply)
{
if (reply != reply_ || reply->error() != QGeoCodeReply::NoError)
return;
+
+ reply->deleteLater();
+ reply_ = 0;
int oldCount = declarativeLocations_.count();
setLocations(reply->locations());
setError(NoError, QString());
setStatus(QDeclarativeGeocodeModel::Ready);
- reply->deleteLater();
- reply_ = 0;
emit locationsChanged();
if (oldCount != declarativeLocations_.count())
emit countChanged();
@@ -405,7 +406,9 @@ void QDeclarativeGeocodeModel::geocodeError(QGeoCodeReply *reply,
{
if (reply != reply_)
return;
- Q_UNUSED(error);
+
+ reply->deleteLater();
+ reply_ = 0;
int oldCount = declarativeLocations_.count();
if (oldCount > 0) {
// Reset the model
@@ -415,8 +418,6 @@ void QDeclarativeGeocodeModel::geocodeError(QGeoCodeReply *reply,
}
setError(static_cast<QDeclarativeGeocodeModel::GeocodeError>(error), errorString);
setStatus(QDeclarativeGeocodeModel::Error);
- reply->deleteLater();
- reply_ = 0;
}
/*!
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 1bf5ea87..5c916fb2 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -52,6 +52,7 @@
#include <QtQuick/QSGRectangleNode>
#include <QtQuick/private/qquickwindow_p.h>
#include <QtQml/qqmlinfo.h>
+#include <QtQuick/private/qquickitem_p.h>
#include <cmath>
#ifndef M_PI
@@ -199,8 +200,6 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
setFlags(QQuickItem::ItemHasContents | QQuickItem::ItemClipsChildrenToShape);
setFiltersChildMouseEvents(true);
- connect(this, SIGNAL(childrenChanged()), this, SLOT(onMapChildrenChanged()), Qt::QueuedConnection);
-
m_activeMapType = new QDeclarativeGeoMapType(QGeoMapType(QGeoMapType::NoMap,
tr("No Map"),
tr("No Map"),
@@ -266,7 +265,8 @@ QDeclarativeGeoMap::~QDeclarativeGeoMap()
}
m_mapItemGroups.clear();
- delete m_copyrights.data();
+ if (m_copyrights.data())
+ delete m_copyrights.data();
m_copyrights.clear();
for (auto obj: qAsConst(m_pendingMapObjects))
@@ -275,71 +275,6 @@ QDeclarativeGeoMap::~QDeclarativeGeoMap()
delete m_map; // map objects get reset here
}
-/*!
- \internal
-*/
-void QDeclarativeGeoMap::onMapChildrenChanged()
-{
- if (!m_componentCompleted || !m_map)
- return;
-
- int maxChildZ = 0;
- QObjectList kids = children();
- bool foundCopyrights = false;
-
- for (int i = 0; i < kids.size(); ++i) {
- QDeclarativeGeoMapCopyrightNotice *copyrights = qobject_cast<QDeclarativeGeoMapCopyrightNotice *>(kids.at(i));
- if (copyrights) {
- foundCopyrights = true;
- } else {
- QDeclarativeGeoMapItemBase *mapItem = qobject_cast<QDeclarativeGeoMapItemBase *>(kids.at(i));
- if (mapItem) {
- if (mapItem->z() > maxChildZ)
- maxChildZ = mapItem->z();
- }
- }
- }
-
- QDeclarativeGeoMapCopyrightNotice *copyrights = m_copyrights.data();
- // if copyrights object not found within the map's children
- if (!foundCopyrights) {
- // if copyrights object was deleted!
- if (!copyrights) {
- // create a new one and set its parent, re-assign it to the weak pointer, then connect the copyrights-change signal
- m_copyrights = new QDeclarativeGeoMapCopyrightNotice(this);
- m_copyrights->onCopyrightsStyleSheetChanged(m_map->copyrightsStyleSheet());
-
- copyrights = m_copyrights.data();
-
- connect(m_map, SIGNAL(copyrightsChanged(QImage)),
- copyrights, SLOT(copyrightsChanged(QImage)));
- connect(m_map, SIGNAL(copyrightsChanged(QImage)),
- this, SIGNAL(copyrightsChanged(QImage)));
-
- connect(m_map, SIGNAL(copyrightsChanged(QString)),
- copyrights, SLOT(copyrightsChanged(QString)));
- connect(m_map, SIGNAL(copyrightsChanged(QString)),
- this, SIGNAL(copyrightsChanged(QString)));
-
- connect(m_map, SIGNAL(copyrightsStyleSheetChanged(QString)),
- copyrights, SLOT(onCopyrightsStyleSheetChanged(QString)));
-
- connect(copyrights, SIGNAL(linkActivated(QString)),
- this, SIGNAL(copyrightLinkActivated(QString)));
-
- // set visibility of copyright notice
- copyrights->setCopyrightsVisible(m_copyrightsVisible);
-
- } else {
- // just re-set its parent.
- copyrights->setParent(this);
- }
- }
-
- // put the copyrights notice object at the highest z order
- copyrights->setCopyrightsZ(maxChildZ + 1);
-}
-
static QDeclarativeGeoMapType *findMapType(const QList<QDeclarativeGeoMapType *> &types, const QGeoMapType &type)
{
for (int i = 0; i < types.size(); ++i)
@@ -456,7 +391,7 @@ void QDeclarativeGeoMap::initialize()
emit mapReadyChanged(true);
- if (m_copyrights)
+ if (m_copyrights) // To not update during initialize()
update();
}
@@ -757,7 +692,6 @@ void QDeclarativeGeoMap::onCameraCapabilitiesChanged(const QGeoCameraCapabilitie
}
}
-
/*!
\internal
this function will only be ever called once
@@ -769,6 +703,12 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
if (!m_map)
return;
+ /* COPY NOTICE SETUP */
+ m_copyrights = new QDeclarativeGeoMapCopyrightNotice(this);
+ m_copyrights->setCopyrightsZ(m_maxChildZ + 1);
+ m_copyrights->setCopyrightsVisible(m_copyrightsVisible);
+ m_copyrights->setMapSource(this);
+
m_gestureArea->setMap(m_map);
QList<QGeoMapType> types = m_mappingManager->supportedMapTypes();
@@ -817,40 +757,26 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
QOverload<const QImage &>::of(&QGeoMap::copyrightsChanged),
[&copyrightImage](const QImage &copy){ copyrightImage = copy; });
m_map->setViewportSize(QSize(width(), height()));
- initialize();
+ initialize(); // This emits the caught signals above
QObject::disconnect(copyrightStringCatcherConnection);
QObject::disconnect(copyrightImageCatcherConnection);
}
- m_copyrights = new QDeclarativeGeoMapCopyrightNotice(this);
- m_copyrights->onCopyrightsStyleSheetChanged(m_map->copyrightsStyleSheet());
- connect(m_map, SIGNAL(copyrightsChanged(QImage)),
- m_copyrights.data(), SLOT(copyrightsChanged(QImage)));
+ /* COPYRIGHT SIGNALS REWIRING */
connect(m_map, SIGNAL(copyrightsChanged(QImage)),
this, SIGNAL(copyrightsChanged(QImage)));
-
- connect(m_map, SIGNAL(copyrightsChanged(QString)),
- m_copyrights.data(), SLOT(copyrightsChanged(QString)));
connect(m_map, SIGNAL(copyrightsChanged(QString)),
this, SIGNAL(copyrightsChanged(QString)));
-
if (!copyrightString.isEmpty())
emit m_map->copyrightsChanged(copyrightString);
else if (!copyrightImage.isNull())
emit m_map->copyrightsChanged(copyrightImage);
- connect(m_map, SIGNAL(copyrightsStyleSheetChanged(QString)),
- m_copyrights.data(), SLOT(onCopyrightsStyleSheetChanged(QString)));
- connect(m_copyrights.data(), SIGNAL(linkActivated(QString)),
- this, SIGNAL(copyrightLinkActivated(QString)));
connect(m_map, &QGeoMap::sgNodeChanged, this, &QQuickItem::update);
connect(m_map, &QGeoMap::cameraCapabilitiesChanged, this, &QDeclarativeGeoMap::onCameraCapabilitiesChanged);
- // set visibility of copyright notice
- m_copyrights->setCopyrightsVisible(m_copyrightsVisible);
-
// This prefetches a buffer around the map
m_map->prefetchData();
@@ -1209,7 +1135,7 @@ void QDeclarativeGeoMap::setMinimumFieldOfView(qreal minimumFieldOfView, bool us
}
/*!
- \qmlproperty bool QtLocation::Map::minimumFieldOfView
+ \qmlproperty real QtLocation::Map::minimumFieldOfView
This property holds the minimum valid field of view for the map, in degrees.
@@ -1246,7 +1172,7 @@ void QDeclarativeGeoMap::setMaximumFieldOfView(qreal maximumFieldOfView, bool us
}
/*!
- \qmlproperty bool QtLocation::Map::maximumFieldOfView
+ \qmlproperty real QtLocation::Map::maximumFieldOfView
This property holds the maximum valid field of view for the map, in degrees.
@@ -1264,7 +1190,7 @@ qreal QDeclarativeGeoMap::maximumFieldOfView() const
}
/*!
- \qmlproperty bool QtLocation::Map::minimumTilt
+ \qmlproperty real QtLocation::Map::minimumTilt
This property holds the minimum valid tilt for the map, in degrees.
@@ -1301,7 +1227,7 @@ void QDeclarativeGeoMap::setMaximumTilt(qreal maximumTilt, bool userSet)
}
/*!
- \qmlproperty bool QtLocation::Map::maximumTilt
+ \qmlproperty real QtLocation::Map::maximumTilt
This property holds the maximum valid tilt for the map, in degrees.
@@ -1469,7 +1395,7 @@ QColor QDeclarativeGeoMap::color() const
}
/*!
- \qmlproperty color QtLocation::Map::mapReady
+ \qmlproperty bool QtLocation::Map::mapReady
This property holds whether the map has been successfully initialized and is ready to be used.
Some methods, such as \l fromCoordinate and \l toCoordinate, will not work before the map is ready.
@@ -1711,6 +1637,27 @@ QGeoMap *QDeclarativeGeoMap::map() const
return m_map;
}
+void QDeclarativeGeoMap::itemChange(ItemChange change, const ItemChangeData &value)
+{
+ if (change == ItemChildAddedChange) {
+ QQuickItem *child = value.item;
+ QQuickItem *mapItem = qobject_cast<QDeclarativeGeoMapItemBase *>(child);
+ if (!mapItem)
+ mapItem = qobject_cast<QDeclarativeGeoMapItemGroup *>(child);
+
+ if (mapItem) {
+ qreal z = mapItem->z();
+ if (z > m_maxChildZ) { // Ignore children removal
+ m_maxChildZ = z;
+ // put the copyrights notice object at the highest z order
+ if (m_copyrights)
+ m_copyrights->setCopyrightsZ(m_maxChildZ + 1);
+ }
+ }
+ }
+ QQuickItem::itemChange(change, value);
+}
+
/*!
\internal
*/
@@ -1743,6 +1690,32 @@ bool QDeclarativeGeoMap::isInteractive()
return (m_gestureArea->enabled() && m_gestureArea->acceptedGestures()) || m_gestureArea->isActive();
}
+void QDeclarativeGeoMap::attachCopyrightNotice(bool initialVisibility)
+{
+ if (initialVisibility) {
+ ++m_copyNoticesVisible;
+ if (m_map)
+ m_map->setCopyrightVisible(m_copyNoticesVisible > 0);
+ }
+}
+
+void QDeclarativeGeoMap::detachCopyrightNotice(bool currentVisibility)
+{
+ if (currentVisibility) {
+ --m_copyNoticesVisible;
+ if (m_map)
+ m_map->setCopyrightVisible(m_copyNoticesVisible > 0);
+ }
+}
+
+void QDeclarativeGeoMap::onAttachedCopyrightNoticeVisibilityChanged()
+{
+ QDeclarativeGeoMapCopyrightNotice *copy = static_cast<QDeclarativeGeoMapCopyrightNotice *>(sender());
+ m_copyNoticesVisible += ( int(copy->copyrightsVisible()) * 2 - 1);
+ if (m_map)
+ m_map->setCopyrightVisible(m_copyNoticesVisible > 0);
+}
+
/*!
\internal
*/
@@ -2262,10 +2235,10 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine, bool onlyVisib
if (m_mapItems.size() == 0)
return;
- double minX = 0;
- double maxX = 0;
- double minY = 0;
- double maxY = 0;
+ double minX = qInf();
+ double maxX = -qInf();
+ double minY = qInf();
+ double maxY = -qInf();
double topLeftX = 0;
double topLeftY = 0;
double bottomRightX = 0;
@@ -2282,13 +2255,11 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine, bool onlyVisib
continue;
// skip quick items in the first pass and refine the fit later
- if (refine) {
- QDeclarativeGeoMapQuickItem *quickItem =
- qobject_cast<QDeclarativeGeoMapQuickItem*>(item);
- if (quickItem) {
+ QDeclarativeGeoMapQuickItem *quickItem =
+ qobject_cast<QDeclarativeGeoMapQuickItem*>(item);
+ if (refine && quickItem) {
haveQuickItem = true;
continue;
- }
}
// Force map items to update immediately. Needed to ensure correct item size and positions
// when recursively calling this function.
@@ -2296,25 +2267,35 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine, bool onlyVisib
// in relation to
// a) fitViewportToMapItems
// b) presence of MouseArea
+ //
+ // This is also legacy code. It must be updated to not operate on screen sizes.
if (item->isPolishScheduled())
item->updatePolish();
- topLeftX = item->position().x();
- topLeftY = item->position().y();
- bottomRightX = topLeftX + item->width();
- bottomRightY = topLeftY + item->height();
+ if (quickItem && quickItem->matrix_ && !quickItem->matrix_->m_matrix.isIdentity()) {
+ // TODO: recalculate the center/zoom level so that the item becomes projectable again
+ if (quickItem->zoomLevel() == 0.0) // the item is unprojectable, should be skipped.
+ continue;
- if (itemCount == 0) {
- minX = topLeftX;
- maxX = bottomRightX;
- minY = topLeftY;
- maxY = bottomRightY;
+ QRectF brect = item->boundingRect();
+ brect = quickItem->matrix_->m_matrix.mapRect(brect);
+ QPointF transformedPosition = quickItem->matrix_->m_matrix * item->position();
+ topLeftX = transformedPosition.x();
+ topLeftY = transformedPosition.y();
+ bottomRightX = topLeftX + brect.width();
+ bottomRightY = topLeftY + brect.height();
} else {
- minX = qMin(minX, topLeftX);
- maxX = qMax(maxX, bottomRightX);
- minY = qMin(minY, topLeftY);
- maxY = qMax(maxY, bottomRightY);
+ topLeftX = item->position().x();
+ topLeftY = item->position().y();
+ bottomRightX = topLeftX + item->width();
+ bottomRightY = topLeftY + item->height();
}
+
+ minX = qMin(minX, topLeftX);
+ maxX = qMax(maxX, bottomRightX);
+ minY = qMin(minY, topLeftY);
+ maxY = qMax(maxY, bottomRightY);
+
++itemCount;
}
diff --git a/src/location/declarativemaps/qdeclarativegeomap_p.h b/src/location/declarativemaps/qdeclarativegeomap_p.h
index ac3afd2c..0d5ae481 100644
--- a/src/location/declarativemaps/qdeclarativegeomap_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomap_p.h
@@ -61,6 +61,7 @@
#include <QtGui/QColor>
#include <QtPositioning/qgeorectangle.h>
#include <QtLocation/private/qgeomap_p.h>
+#include <QtQuick/private/qquickitemchangelistener_p.h>
QT_BEGIN_NAMESPACE
@@ -196,6 +197,9 @@ public:
QGeoServiceProvider::Error error() const;
QGeoMap* map() const;
+ // From QQuickItem
+ void itemChange(ItemChange, const ItemChangeData &) override;
+
Q_SIGNALS:
void pluginChanged(QDeclarativeGeoServiceProvider *plugin);
void zoomLevelChanged(qreal zoomLevel);
@@ -247,9 +251,9 @@ protected:
private Q_SLOTS:
void mappingManagerInitialized();
void pluginReady();
- void onMapChildrenChanged();
void onSupportedMapTypesChanged();
void onCameraCapabilitiesChanged(const QGeoCameraCapabilities &oldCameraCapabilities);
+ void onAttachedCopyrightNoticeVisibilityChanged();
private:
void setupMapView(QDeclarativeGeoMapItemView *view);
@@ -258,6 +262,8 @@ private:
void fitViewportToMapItemsRefine(bool refine, bool onlyVisible);
void fitViewportToGeoShape();
bool isInteractive();
+ void attachCopyrightNotice(bool initialVisibility);
+ void detachCopyrightNotice(bool currentVisibility);
private:
QDeclarativeGeoServiceProvider *m_plugin;
@@ -296,6 +302,10 @@ private:
qreal m_userMinimumFieldOfView;
qreal m_userMaximumFieldOfView;
+ int m_copyNoticesVisible = 0;
+ qreal m_maxChildZ = 0;
+
+
friend class QDeclarativeGeoMapItem;
friend class QDeclarativeGeoMapItemView;
friend class QQuickGeoMapGestureArea;
diff --git a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp
index 3e68ac97..7edfc9ff 100644
--- a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp
@@ -43,9 +43,17 @@
#include <QtQuick/private/qquickanchors_p.h>
#include <QtQuick/private/qquickanchors_p_p.h>
#include <QtLocation/private/qdeclarativegeomap_p.h>
+#include <QtQuick/private/qquickpainteditem_p.h>
QT_BEGIN_NAMESPACE
+class QDeclarativeGeoMapCopyrightNoticePrivate: public QQuickPaintedItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeGeoMapCopyrightNotice)
+public:
+ virtual void setVisible(bool visible);
+};
+
/*!
\qmltype MapCopyrightNotice
\instantiates QDeclarativeGeoMapCopyrightNotice
@@ -99,6 +107,7 @@ QDeclarativeGeoMapCopyrightNotice::QDeclarativeGeoMapCopyrightNotice(QQuickItem
QDeclarativeGeoMapCopyrightNotice::~QDeclarativeGeoMapCopyrightNotice()
{
+ setMapSource(nullptr);
}
void QDeclarativeGeoMapCopyrightNotice::anchorToBottomLeft()
@@ -112,35 +121,41 @@ void QDeclarativeGeoMapCopyrightNotice::anchorToBottomLeft()
}
}
-void QDeclarativeGeoMapCopyrightNotice::setMapSource(QDeclarativeGeoMap *mapSource)
+void QDeclarativeGeoMapCopyrightNotice::setMapSource(QDeclarativeGeoMap *map)
{
- if (m_mapSource == mapSource)
+ if (m_mapSource == map)
return;
if (m_mapSource) {
// disconnect this object from current map source
+ m_mapSource->detachCopyrightNotice(copyrightsVisible());
m_mapSource->disconnect(this);
m_mapSource->m_map->disconnect(this);
- m_copyrightsHtml->clear();
+ if (m_copyrightsHtml)
+ m_copyrightsHtml->clear();
m_copyrightsImage = QImage();
m_mapSource = nullptr;
}
- if (mapSource) {
- m_mapSource = mapSource;
+ if (map) {
+ m_mapSource = map;
+ m_mapSource->attachCopyrightNotice(copyrightsVisible());
+ connect(this, &QDeclarativeGeoMapCopyrightNotice::copyrightsVisibleChanged,
+ mapSource(), &QDeclarativeGeoMap::onAttachedCopyrightNoticeVisibilityChanged);
+
// First update the copyright. Only Image will do here, no need to store HTML right away.
- if (mapSource->m_copyrights && !mapSource->m_copyrights->m_copyrightsImage.isNull())
- m_copyrightsImage = mapSource->m_copyrights->m_copyrightsImage;
+ if (m_mapSource->m_copyrights && !m_mapSource->m_copyrights->m_copyrightsImage.isNull())
+ m_copyrightsImage = m_mapSource->m_copyrights->m_copyrightsImage;
- connect(m_mapSource, SIGNAL(copyrightsChanged(QImage)),
+ connect(mapSource(), SIGNAL(copyrightsChanged(QImage)),
this, SLOT(copyrightsChanged(QImage)));
- connect(m_mapSource, SIGNAL(copyrightsChanged(QString)),
+ connect(mapSource(), SIGNAL(copyrightsChanged(QString)),
this, SLOT(copyrightsChanged(QString)));
if (m_mapSource->m_map)
connectMap();
else
- connect(m_mapSource, &QDeclarativeGeoMap::mapReadyChanged, this, &QDeclarativeGeoMapCopyrightNotice::connectMap);
+ connect(mapSource(), &QDeclarativeGeoMap::mapReadyChanged, this, &QDeclarativeGeoMapCopyrightNotice::connectMap);
}
}
@@ -149,7 +164,7 @@ void QDeclarativeGeoMapCopyrightNotice::connectMap()
connect(m_mapSource->m_map, SIGNAL(copyrightsStyleSheetChanged(QString)),
this, SLOT(onCopyrightsStyleSheetChanged(QString)));
connect(this, SIGNAL(linkActivated(QString)),
- m_mapSource, SIGNAL(copyrightLinkActivated(QString)));
+ mapSource(), SIGNAL(copyrightLinkActivated(QString)));
onCopyrightsStyleSheetChanged(m_mapSource->m_map->copyrightsStyleSheet());
@@ -159,7 +174,7 @@ void QDeclarativeGeoMapCopyrightNotice::connectMap()
QDeclarativeGeoMap *QDeclarativeGeoMapCopyrightNotice::mapSource()
{
- return m_mapSource;
+ return m_mapSource.data();
}
QString QDeclarativeGeoMapCopyrightNotice::styleSheet() const
@@ -253,20 +268,36 @@ void QDeclarativeGeoMapCopyrightNotice::createCopyright()
m_copyrightsHtml->setDocumentMargin(0);
}
+void QDeclarativeGeoMapCopyrightNoticePrivate::setVisible(bool visible)
+{
+ Q_Q(QDeclarativeGeoMapCopyrightNotice);
+ q->m_copyrightsVisible = visible;
+ QQuickItemPrivate::setVisible(visible);
+}
+
/*!
\internal
*/
void QDeclarativeGeoMapCopyrightNotice::setCopyrightsVisible(bool visible)
{
+ Q_D(QDeclarativeGeoMapCopyrightNotice);
+ if (visible == m_copyrightsVisible)
+ return;
+
m_copyrightsVisible = visible;
+ d->QQuickItemPrivate::setVisible(!m_copyrightsImage.isNull() && visible);
+ emit copyrightsVisibleChanged();
+}
- setVisible(!m_copyrightsImage.isNull() && visible);
+bool QDeclarativeGeoMapCopyrightNotice::copyrightsVisible() const
+{
+ return m_copyrightsVisible;
}
/*!
\internal
*/
-void QDeclarativeGeoMapCopyrightNotice::setCopyrightsZ(int copyrightsZ)
+void QDeclarativeGeoMapCopyrightNotice::setCopyrightsZ(qreal copyrightsZ)
{
setZ(copyrightsZ);
update();
@@ -277,6 +308,7 @@ void QDeclarativeGeoMapCopyrightNotice::setCopyrightsZ(int copyrightsZ)
*/
void QDeclarativeGeoMapCopyrightNotice::copyrightsChanged(const QImage &copyrightsImage)
{
+ Q_D(QDeclarativeGeoMapCopyrightNotice);
delete m_copyrightsHtml;
m_copyrightsHtml = 0;
@@ -286,20 +318,19 @@ void QDeclarativeGeoMapCopyrightNotice::copyrightsChanged(const QImage &copyrigh
setKeepMouseGrab(false);
setAcceptedMouseButtons(Qt::NoButton);
- setVisible(m_copyrightsVisible);
+ d->QQuickItemPrivate::setVisible(m_copyrightsVisible && !m_copyrightsImage.isNull());
update();
}
void QDeclarativeGeoMapCopyrightNotice::copyrightsChanged(const QString &copyrightsHtml)
{
+ Q_D(QDeclarativeGeoMapCopyrightNotice);
if (copyrightsHtml.isEmpty()) {
- setVisible(false);
+ d->QQuickItemPrivate::setVisible(false);
return;
- } else if (!m_copyrightsVisible) {
- setVisible(false);
- } else {
- setVisible(true);
+ } else {
+ d->QQuickItemPrivate::setVisible(m_copyrightsVisible);
}
// Divfy, so we can style the background. The extra <span> is a
diff --git a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h
index 7189e65c..0cf06d12 100644
--- a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h
@@ -52,13 +52,14 @@
#include <QtLocation/private/qlocationglobal_p.h>
#include <QtGui/QImage>
+#include <QPointer>
#include <QtQuick/QQuickPaintedItem>
QT_BEGIN_NAMESPACE
class QTextDocument;
class QDeclarativeGeoMap;
-
+class QDeclarativeGeoMapCopyrightNoticePrivate;
class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoMapCopyrightNotice : public QQuickPaintedItem
{
Q_OBJECT
@@ -69,9 +70,10 @@ public:
QDeclarativeGeoMapCopyrightNotice(QQuickItem *parent = nullptr);
~QDeclarativeGeoMapCopyrightNotice();
- void setCopyrightsZ(int copyrightsZ);
+ void setCopyrightsZ(qreal copyrightsZ);
void setCopyrightsVisible(bool visible);
+ bool copyrightsVisible() const;
void anchorToBottomLeft();
void setMapSource(QDeclarativeGeoMap *mapSource);
@@ -90,6 +92,7 @@ signals:
void mapSourceChanged();
void backgroundColorChanged(const QColor &color);
void styleSheetChanged(const QString &styleSheet);
+ void copyrightsVisibleChanged();
protected:
void paint(QPainter *painter) override;
@@ -106,10 +109,13 @@ private:
QImage m_copyrightsImage;
QString m_activeAnchor;
bool m_copyrightsVisible;
- QDeclarativeGeoMap *m_mapSource;
+ QPointer<QDeclarativeGeoMap> m_mapSource;
QColor m_backgroundColor;
QString m_styleSheet;
bool m_userDefinedStyleSheet;
+
+ Q_DISABLE_COPY(QDeclarativeGeoMapCopyrightNotice)
+ Q_DECLARE_PRIVATE(QDeclarativeGeoMapCopyrightNotice)
};
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativegeomapitembase.cpp b/src/location/declarativemaps/qdeclarativegeomapitembase.cpp
index fed0a74b..7b3950db 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitembase.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapitembase.cpp
@@ -222,9 +222,14 @@ bool QDeclarativeGeoMapItemBase::childMouseEventFilter(QQuickItem *item, QEvent
{
Q_UNUSED(item)
if (event->type() == QEvent::MouseButtonPress && !contains(static_cast<QMouseEvent*>(event)->pos())) {
- // This is an evil hack: in case of items that are not rectangles, we never accept the event.
- // Instead the events are now delivered to QDeclarativeGeoMapItemBase which doesn't to anything with them.
- // The map below it still works since it filters events and steals the events at some point.
+ // In case of items that are not rectangles, this filter is used to test if the event has landed
+ // inside the actual item shape.
+ // If so, the method returns true, meaning that it prevents the event delivery to child "*item" (for example,
+ // a mouse area that is on top of this map item).
+ // However, this method sets "accepted" to false, so that the event can still be passed further up,
+ // specifically to the parent Map, that is a sort of flickable.
+ // Otherwise, if the event is not contained within the map item, the method returns false, meaning the event
+ // is delivered to the child *item (like the mouse area associated).
event->setAccepted(false);
return true;
}
diff --git a/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h b/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h
index 3e757371..8e2c2785 100644
--- a/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h
@@ -126,6 +126,8 @@ private:
bool mapAndSourceItemSet_;
bool updatingGeometry_;
QMapQuickItemMatrix4x4 *matrix_;
+
+ friend class QDeclarativeGeoMap;
};
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
index aa3a3bd9..5eda137c 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
@@ -304,7 +304,7 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map)
screenIndices_.clear();
for (const auto &p : poly)
screenVertices_ << QPointF(p[0], p[1]);
- std::vector<N> indices = mapbox::earcut<N>(polygon);
+ std::vector<N> indices = qt_mapbox::earcut<N>(polygon);
for (const auto &i: indices)
screenIndices_ << quint32(i);
}
diff --git a/src/location/maps/qgeomap.cpp b/src/location/maps/qgeomap.cpp
index d21c8b11..af40b33b 100644
--- a/src/location/maps/qgeomap.cpp
+++ b/src/location/maps/qgeomap.cpp
@@ -308,6 +308,15 @@ void QGeoMap::setAcceptedGestures(bool pan, bool flick, bool pinch, bool rotate,
Q_UNUSED(tilt)
}
+void QGeoMap::setCopyrightVisible(bool visible)
+{
+ Q_D(QGeoMap);
+ if (d->m_copyrightVisible == visible)
+ return;
+
+ d->m_copyrightVisible = visible;
+}
+
QGeoMapPrivate::QGeoMapPrivate(QGeoMappingManagerEngine *engine, QGeoProjection *geoProjection)
: QObjectPrivate(),
m_geoProjection(geoProjection),
@@ -395,4 +404,14 @@ double QGeoMapPrivate::mapHeight() const
return 0; // override this for maps supporting other projections
}
+void QGeoMapPrivate::setCopyrightVisible(bool visible)
+{
+ m_copyrightVisible = visible;
+}
+
+bool QGeoMapPrivate::copyrightVisible() const
+{
+ return m_copyrightVisible;
+}
+
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomap_p.h b/src/location/maps/qgeomap_p.h
index 835a946a..8e4a8839 100644
--- a/src/location/maps/qgeomap_p.h
+++ b/src/location/maps/qgeomap_p.h
@@ -150,6 +150,8 @@ public:
virtual bool anchorCoordinateToPoint(const QGeoCoordinate &coordinate, const QPointF &anchorPoint);
virtual bool fitViewportToGeoRectangle(const QGeoRectangle &rectangle);
+ virtual void setCopyrightVisible(bool visible);
+
protected:
QGeoMap(QGeoMapPrivate &dd, QObject *parent = 0);
void setCameraData(const QGeoCameraData &cameraData);
diff --git a/src/location/maps/qgeomap_p_p.h b/src/location/maps/qgeomap_p_p.h
index 615571d1..ff7ca318 100644
--- a/src/location/maps/qgeomap_p_p.h
+++ b/src/location/maps/qgeomap_p_p.h
@@ -100,6 +100,9 @@ protected:
virtual double mapWidth() const;
virtual double mapHeight() const;
+ virtual void setCopyrightVisible(bool visible);
+ virtual bool copyrightVisible() const;
+
protected:
QSize m_viewportSize;
QGeoProjection *m_geoProjection;
@@ -109,6 +112,7 @@ protected:
QList<QGeoMapParameter *> m_mapParameters;
QList<QDeclarativeGeoMapItemBase *> m_mapItems;
QGeoCameraCapabilities m_cameraCapabilities;
+ bool m_copyrightVisible = true;
};
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeorouteparserosrmv5.cpp b/src/location/maps/qgeorouteparserosrmv5.cpp
index df6c65ef..63610485 100644
--- a/src/location/maps/qgeorouteparserosrmv5.cpp
+++ b/src/location/maps/qgeorouteparserosrmv5.cpp
@@ -976,7 +976,7 @@ QUrl QGeoRouteParserOsrmV5Private::requestUrl(const QGeoRouteRequest &request, c
routingUrl.append(QLatin1Char(';'));
bearings.append(QLatin1Char(';'));
}
- routingUrl.append(QString::number(c.longitude())).append(QLatin1Char(',')).append(QString::number(c.latitude()));
+ routingUrl.append(QString::number(c.longitude(), 'f', 7)).append(QLatin1Char(',')).append(QString::number(c.latitude(), 'f', 7));
if (metadata.size() > i) {
const QVariantMap &meta = metadata.at(i);
if (meta.contains(QStringLiteral("bearing"))) {
diff --git a/src/location/maps/qgeotiledmap.cpp b/src/location/maps/qgeotiledmap.cpp
index 81eb3b14..f903b94e 100644
--- a/src/location/maps/qgeotiledmap.cpp
+++ b/src/location/maps/qgeotiledmap.cpp
@@ -150,6 +150,17 @@ QGeoMap::Capabilities QGeoTiledMap::capabilities() const
| SupportsAnchoringCoordinate);
}
+void QGeoTiledMap::setCopyrightVisible(bool visible)
+{
+ Q_D(QGeoTiledMap);
+ if (visible == d->m_copyrightVisible)
+ return;
+
+ QGeoMap::setCopyrightVisible(visible);
+ if (visible)
+ evaluateCopyrights(d->m_mapScene->visibleTiles());
+}
+
void QGeoTiledMap::clearScene(int mapId)
{
Q_D(QGeoTiledMap);
@@ -326,7 +337,7 @@ void QGeoTiledMapPrivate::updateScene()
bool newTilesIntroduced = !m_mapScene->visibleTiles().contains(tiles);
m_mapScene->setVisibleTiles(tiles);
- if (newTilesIntroduced)
+ if (newTilesIntroduced && m_copyrightVisible)
q->evaluateCopyrights(tiles);
// don't request tiles that are already built and textured
@@ -388,7 +399,8 @@ void QGeoTiledMapPrivate::changeViewportSize(const QSize& size)
m_cache->setMinTextureUsage(newSize);
}
- q->evaluateCopyrights(m_visibleTiles->createTiles());
+ if (m_copyrightVisible)
+ q->evaluateCopyrights(m_mapScene->visibleTiles());
updateScene();
}
diff --git a/src/location/maps/qgeotiledmap_p.h b/src/location/maps/qgeotiledmap_p.h
index ad3c9af9..a162bdbc 100644
--- a/src/location/maps/qgeotiledmap_p.h
+++ b/src/location/maps/qgeotiledmap_p.h
@@ -88,6 +88,8 @@ public:
void clearData() override;
Capabilities capabilities() const override;
+ void setCopyrightVisible(bool visible) override;
+
public Q_SLOTS:
virtual void clearScene(int mapId);