summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-12-01 23:00:31 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-12-01 23:00:31 +0100
commit99a1ba7c488939f606628593e7d21e42aa583502 (patch)
tree4ed34a0bc7500a9a429d8009f4777fb7250ab65f
parentf87ba0409856a678e8a940b70f7452c3a1b730c3 (diff)
parenteea315187d1add70aaf69745c031b8d6342b2303 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: src/imports/location/qdeclarativegeomap.cpp src/imports/location/qdeclarativegeomap_p.h Change-Id: Iaf232acbe9098eb1b57f571638dd37f75b2ff345
-rw-r--r--dist/changes-5.5.154
-rw-r--r--examples/location/mapviewer/map/MapComponent.qml2
-rw-r--r--src/imports/location/location.cpp2
-rw-r--r--src/imports/location/qdeclarativecirclemapitem.cpp32
-rw-r--r--src/imports/location/qdeclarativecirclemapitem_p.h6
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp130
-rw-r--r--src/imports/location/qdeclarativegeomap_p.h14
-rw-r--r--src/imports/location/qdeclarativegeomapitembase.cpp12
-rw-r--r--src/imports/location/qdeclarativegeomapitembase_p.h5
-rw-r--r--src/imports/location/qdeclarativegeomapquickitem.cpp30
-rw-r--r--src/imports/location/qdeclarativegeomapquickitem_p.h2
-rw-r--r--src/imports/location/qdeclarativepolygonmapitem.cpp19
-rw-r--r--src/imports/location/qdeclarativepolygonmapitem_p.h2
-rw-r--r--src/imports/location/qdeclarativepolylinemapitem.cpp17
-rw-r--r--src/imports/location/qdeclarativepolylinemapitem_p.h2
-rw-r--r--src/imports/location/qdeclarativerectanglemapitem.cpp34
-rw-r--r--src/imports/location/qdeclarativerectanglemapitem_p.h4
-rw-r--r--src/imports/location/qdeclarativeroutemapitem.cpp7
-rw-r--r--src/imports/location/qdeclarativeroutemapitem_p.h3
-rw-r--r--src/imports/location/qquickgeomapgesturearea.cpp184
-rw-r--r--src/imports/location/qquickgeomapgesturearea_p.h64
-rw-r--r--src/location/doc/qtlocation.qdocconf2
-rw-r--r--src/location/doc/src/qtlocation-changes.qdoc18
-rw-r--r--src/location/maps/maps.pri6
-rw-r--r--src/location/maps/qabstractgeotilecache.cpp147
-rw-r--r--src/location/maps/qabstractgeotilecache_p.h124
-rw-r--r--src/location/maps/qgeofiletilecache.cpp (renamed from src/location/maps/qgeotilecache.cpp)131
-rw-r--r--src/location/maps/qgeofiletilecache_p.h (renamed from src/location/maps/qgeotilecache_p.h)73
-rw-r--r--src/location/maps/qgeomapscene.cpp2
-rw-r--r--src/location/maps/qgeotiledmap.cpp4
-rw-r--r--src/location/maps/qgeotiledmap_p.h4
-rw-r--r--src/location/maps/qgeotiledmap_p_p.h4
-rw-r--r--src/location/maps/qgeotiledmappingmanagerengine.cpp13
-rw-r--r--src/location/maps/qgeotiledmappingmanagerengine_p.h7
-rw-r--r--src/location/maps/qgeotiledmappingmanagerengine_p_p.h4
-rw-r--r--src/location/maps/qgeotilefetcher_p_p.h1
-rw-r--r--src/location/maps/qgeotilerequestmanager.cpp2
-rw-r--r--src/location/maps/qgeotilerequestmanager_p.h1
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp13
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp15
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.h2
-rw-r--r--src/plugins/position/simulator/simulator.pro3
-rw-r--r--src/positioning/doc/qtpositioning.qdocconf2
-rw-r--r--src/positioning/positioning.pro7
-rw-r--r--src/positioning/qlocationdata_simulator.cpp (renamed from src/plugins/position/simulator/qlocationdata_simulator.cpp)0
-rw-r--r--src/positioning/qlocationdata_simulator_p.h (renamed from src/plugins/position/simulator/qlocationdata_simulator_p.h)21
-rw-r--r--src/positioning/qpositioningglobal_p.h45
-rw-r--r--tests/auto/declarative_core/tst_geocoding.qml75
-rw-r--r--tests/auto/declarative_ui/tst_map_coordinateanimation.qml8
-rw-r--r--tests/auto/declarative_ui/tst_map_error.qml10
-rw-r--r--tests/auto/declarative_ui/tst_map_flick.qml106
-rw-r--r--tests/auto/declarative_ui/tst_map_item.qml43
-rw-r--r--tests/auto/declarative_ui/tst_map_item_details.qml17
-rw-r--r--tests/auto/declarative_ui/tst_map_item_fit_viewport.qml10
-rw-r--r--tests/auto/declarative_ui/tst_map_mouse.qml54
-rw-r--r--tests/auto/geotestplugin/qgeotilefetcher_test.h63
-rw-r--r--tests/auto/qgeomapscene/tst_qgeomapscene.cpp2
57 files changed, 994 insertions, 670 deletions
diff --git a/dist/changes-5.5.1 b/dist/changes-5.5.1
new file mode 100644
index 00000000..8b2ce351
--- /dev/null
+++ b/dist/changes-5.5.1
@@ -0,0 +1,54 @@
+Qt 5.5.1 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with Qt 5.5.0.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+ http://doc.qt.io/qt-5.5/
+
+The Qt version 5.5 series is binary compatible with the 5.4.x series.
+Applications compiled for 5.4 will continue to run with 5.5.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+ http://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* Library *
+****************************************************************************
+
+QtLocation
+-----------
+
+ - Fixed change signal emission for Map.activeMapType property.
+ - Improved places-list and places-map examples.
+ - [QTBUG-47188] Fixed incorrect naming of OSM plugin's parameter.
+ The documentation mandates the osm prefix which was not used in
+ the case of the geocoding.host, useragent and routing.host parameters.
+ The required osm.places.host parameter was not handled at all.
+ - [QTBUG-47322] Added support for zoom level 19 to OSM plugin.
+ - Fixed an issue where the incorrect prefetch algorithm was used for map
+ tile fetching.
+
+QtPositioning
+-------------
+
+ - Improved minor documentation issues.
+
+****************************************************************************
+* Platform Specific Changes *
+****************************************************************************
+
+Windows
+-------
+
+ - Added missing QtQuick.Controls import to mapviewer example.
+
+Linux/gcc
+---------
+
+ - [QTBUG-47427] Fixed compile issue in geoclue plugin when using gcc 4.5.
diff --git a/examples/location/mapviewer/map/MapComponent.qml b/examples/location/mapviewer/map/MapComponent.qml
index ece4798b..d2d526d1 100644
--- a/examples/location/mapviewer/map/MapComponent.qml
+++ b/examples/location/mapviewer/map/MapComponent.qml
@@ -269,7 +269,7 @@ Map {
//! [mapnavigation]
// Enable pan, flick, and pinch gestures to zoom in and out
- gesture.activeGestures: MapGestureArea.PanGesture | MapGestureArea.FlickGesture | MapGestureArea.ZoomGesture
+ gesture.acceptedGestures: MapGestureArea.PanGesture | MapGestureArea.FlickGesture | MapGestureArea.PinchGesture
gesture.flickDeceleration: 3000
gesture.enabled: true
//! [mapnavigation]
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index c19a4065..dbeb3c5d 100644
--- a/src/imports/location/location.cpp
+++ b/src/imports/location/location.cpp
@@ -108,7 +108,7 @@ public:
qmlRegisterType<QDeclarativeGeoRoute >(uri, major, minor, "Route"); // data type
qmlRegisterType<QDeclarativeGeoRouteSegment >(uri, major, minor, "RouteSegment");
qmlRegisterType<QDeclarativeGeoManeuver >(uri, major, minor, "RouteManeuver");
- qmlRegisterUncreatableType<QDeclarativeGeoMapPinchEvent >(uri, major, minor, "MapPinchEvent",
+ qmlRegisterUncreatableType<QGeoMapPinchEvent >(uri, major, minor, "MapPinchEvent",
QStringLiteral("(Map)PinchEvent is not intended instantiable by developer."));
qmlRegisterUncreatableType<QQuickGeoMapGestureArea>(uri, major, minor, "MapGestureArea",
QStringLiteral("(Map)GestureArea is not intended instantiable by developer."));
diff --git a/src/imports/location/qdeclarativecirclemapitem.cpp b/src/imports/location/qdeclarativecirclemapitem.cpp
index 92977179..eb3de7a2 100644
--- a/src/imports/location/qdeclarativecirclemapitem.cpp
+++ b/src/imports/location/qdeclarativecirclemapitem.cpp
@@ -35,7 +35,6 @@
****************************************************************************/
#include "qdeclarativecirclemapitem_p.h"
-#include "qdeclarativegeomapquickitem_p.h"
#include "qdeclarativepolygonmapitem_p.h"
#include "qgeocameracapabilities_p.h"
#include "qgeoprojection_p.h"
@@ -302,9 +301,9 @@ QDeclarativeCircleMapItem::QDeclarativeCircleMapItem(QQuickItem *parent)
{
setFlag(ItemHasContents, true);
QObject::connect(&border_, SIGNAL(colorChanged(QColor)),
- this, SLOT(updateMapItemAssumeDirty()));
+ this, SLOT(markSourceDirtyAndUpdate()));
QObject::connect(&border_, SIGNAL(widthChanged(qreal)),
- this, SLOT(updateMapItemAssumeDirty()));
+ this, SLOT(markSourceDirtyAndUpdate()));
// assume that circles are not self-intersecting
// to speed up processing
@@ -335,21 +334,18 @@ QDeclarativeMapLineProperties *QDeclarativeCircleMapItem::border()
return &border_;
}
-void QDeclarativeCircleMapItem::updateMapItemAssumeDirty()
+void QDeclarativeCircleMapItem::markSourceDirtyAndUpdate()
{
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
}
void QDeclarativeCircleMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map)
{
QDeclarativeGeoMapItemBase::setMap(quickMap,map);
- if (map) {
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
- }
+ if (map)
+ markSourceDirtyAndUpdate();
}
/*!
@@ -365,10 +361,7 @@ void QDeclarativeCircleMapItem::setCenter(const QGeoCoordinate &center)
return;
center_ = center;
-
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
+ markSourceDirtyAndUpdate();
emit centerChanged(center_);
}
@@ -389,7 +382,7 @@ void QDeclarativeCircleMapItem::setColor(const QColor &color)
return;
color_ = color;
dirtyMaterial_ = true;
- updateMapItem();
+ update();
emit colorChanged(color_);
}
@@ -411,9 +404,7 @@ void QDeclarativeCircleMapItem::setRadius(qreal radius)
return;
radius_ = radius;
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
+ markSourceDirtyAndUpdate();
emit radiusChanged(radius);
}
@@ -459,7 +450,7 @@ QSGNode *QDeclarativeCircleMapItem::updateMapItemPaintNode(QSGNode *oldNode, Upd
/*!
\internal
*/
-void QDeclarativeCircleMapItem::updateMapItem()
+void QDeclarativeCircleMapItem::updatePolish()
{
if (!map() || !center().isValid())
return;
@@ -501,7 +492,6 @@ void QDeclarativeCircleMapItem::updateMapItem()
}
setPositionOnMap(circlePath_.at(0), geometry_.firstPointOffset());
- update();
}
/*!
@@ -541,7 +531,7 @@ void QDeclarativeCircleMapItem::afterViewportChanged(const QGeoMapViewportChange
geometry_.markScreenDirty();
borderGeometry_.markScreenDirty();
- updateMapItem();
+ polishAndUpdate();
}
/*!
diff --git a/src/imports/location/qdeclarativecirclemapitem_p.h b/src/imports/location/qdeclarativecirclemapitem_p.h
index fb786e08..9b142309 100644
--- a/src/imports/location/qdeclarativecirclemapitem_p.h
+++ b/src/imports/location/qdeclarativecirclemapitem_p.h
@@ -56,8 +56,6 @@
QT_BEGIN_NAMESPACE
-class QDeclarativeGeoMapQuickItem;
-
class QGeoMapCircleGeometry : public QGeoMapPolygonGeometry
{
public:
@@ -101,10 +99,10 @@ Q_SIGNALS:
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void updatePolish() Q_DECL_OVERRIDE;
protected Q_SLOTS:
- virtual void updateMapItem() Q_DECL_OVERRIDE;
- void updateMapItemAssumeDirty();
+ void markSourceDirtyAndUpdate();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
private:
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index 026a515a..67f723b9 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -179,6 +179,7 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
m_map(0),
m_error(QGeoServiceProvider::NoError),
m_zoomLevel(8.0),
+ m_color(QColor::fromRgbF(0.9, 0.9, 0.9)),
m_componentCompleted(false),
m_mappingManagerInitialized(false),
m_pendingFitViewport(false),
@@ -422,9 +423,11 @@ QSGNode *QDeclarativeGeoMap::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa
QSGSimpleRectNode *root = static_cast<QSGSimpleRectNode *>(oldNode);
if (!root)
- root = new QSGSimpleRectNode(boundingRect(), QColor::fromRgbF(0.9, 0.9, 0.9));
- else
+ root = new QSGSimpleRectNode(boundingRect(), m_color);
+ else {
root->setRect(boundingRect());
+ root->setColor(m_color);
+ }
QSGNode *content = root->childCount() ? root->firstChild() : 0;
content = m_map->updateSceneGraph(content, window());
@@ -773,6 +776,28 @@ bool QDeclarativeGeoMap::copyrightsVisible() const
}
+
+/*!
+ \qmlproperty color QtLocation::Map::color
+
+ This property holds the background color of the map element.
+
+ \since 5.6
+*/
+void QDeclarativeGeoMap::setColor(const QColor &color)
+{
+ if (color != m_color) {
+ m_color = color;
+ update();
+ emit colorChanged(m_color);
+ }
+}
+
+QColor QDeclarativeGeoMap::color() const
+{
+ return m_color;
+}
+
void QDeclarativeGeoMap::fitViewportToGeoShape()
{
if (!m_map) return;
@@ -888,18 +913,6 @@ QPointF QDeclarativeGeoMap::fromCoordinate(const QGeoCoordinate &coordinate, boo
}
/*!
- \qmlmethod QtLocation::Map::toScreenPosition(coordinate coordinate)
- \obsolete
-
- This function is missed named and is equilavent to \l {fromCoordinate}, which should be used
- instead.
-*/
-QPointF QDeclarativeGeoMap::toScreenPosition(const QGeoCoordinate &coordinate) const
-{
- return fromCoordinate(coordinate);
-}
-
-/*!
\qmlmethod void QtLocation::Map::pan(int dx, int dy)
Starts panning the map by \a dx pixels along the x-axis and
@@ -999,7 +1012,7 @@ void QDeclarativeGeoMap::wheelEvent(QWheelEvent *event)
bool QDeclarativeGeoMap::isInteractive()
{
- return (m_gestureArea->enabled() && m_gestureArea->activeGestures()) || m_gestureArea->isActive();
+ return (m_gestureArea->enabled() && m_gestureArea->acceptedGestures()) || m_gestureArea->isActive();
}
/*!
@@ -1199,89 +1212,6 @@ void QDeclarativeGeoMap::geometryChanged(const QRectF &newGeometry, const QRectF
}
-// TODO Remove this function -> BC break
-/*!
- \qmlmethod void QtLocation::Map::fitViewportToGeoShape(QGeoShape shape)
-
- \internal
-
- Fits the current viewport to the boundary of the shape. The camera is positioned
- in the center of the shape, and at the largest integral zoom level possible which
- allows the whole shape to be visible on screen
-
-*/
-void QDeclarativeGeoMap::fitViewportToGeoShape(const QVariant &variantShape)
-{
- if (!m_map || !m_mappingManagerInitialized)
- return;
-
- QGeoShape shape;
-
- if (variantShape.userType() == qMetaTypeId<QGeoRectangle>())
- shape = variantShape.value<QGeoRectangle>();
- else if (variantShape.userType() == qMetaTypeId<QGeoCircle>())
- shape = variantShape.value<QGeoCircle>();
- else if (variantShape.userType() == qMetaTypeId<QGeoShape>())
- shape = variantShape.value<QGeoShape>();
-
- if (!shape.isValid())
- return;
-
- double bboxWidth;
- double bboxHeight;
- QGeoCoordinate centerCoordinate;
-
- switch (shape.type()) {
- case QGeoShape::RectangleType:
- {
- QGeoRectangle rect = shape;
- QDoubleVector2D topLeftPoint = m_map->coordinateToItemPosition(rect.topLeft(), false);
- QDoubleVector2D botRightPoint = m_map->coordinateToItemPosition(rect.bottomRight(), false);
- bboxWidth = qAbs(topLeftPoint.x() - botRightPoint.x());
- bboxHeight = qAbs(topLeftPoint.y() - botRightPoint.y());
- centerCoordinate = rect.center();
- break;
- }
- case QGeoShape::CircleType:
- {
- QGeoCircle circle = shape;
- centerCoordinate = circle.center();
- QGeoCoordinate edge = centerCoordinate.atDistanceAndAzimuth(circle.radius(), 90);
- QDoubleVector2D centerPoint = m_map->coordinateToItemPosition(centerCoordinate, false);
- QDoubleVector2D edgePoint = m_map->coordinateToItemPosition(edge, false);
- bboxWidth = qAbs(centerPoint.x() - edgePoint.x()) * 2;
- bboxHeight = bboxWidth;
- break;
- }
- case QGeoShape::UnknownType:
- //Fallthrough to default
- default:
- return;
- }
-
- // position camera to the center of bounding box
- setProperty("center", QVariant::fromValue(centerCoordinate));
-
- //If the shape is empty we just change centerposition, not zoom
- if (bboxHeight == 0 && bboxWidth == 0)
- return;
-
- // adjust zoom
- double bboxWidthRatio = bboxWidth / (bboxWidth + bboxHeight);
- double mapWidthRatio = width() / (width() + height());
- double zoomRatio;
-
- if (bboxWidthRatio > mapWidthRatio)
- zoomRatio = bboxWidth / width();
- else
- zoomRatio = bboxHeight / height();
-
- qreal newZoom = std::log10(zoomRatio) / std::log10(0.5);
-
- newZoom = std::floor(qMax(minimumZoomLevel(), (m_map->mapController()->zoom() + newZoom)));
- setProperty("zoomLevel", QVariant::fromValue(newZoom));
-}
-
/*!
\qmlmethod void QtLocation::Map::fitViewportToMapItems()
@@ -1333,6 +1263,10 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine)
continue;
}
}
+ // Force map items to update immediately. Needed to ensure correct item size and positions
+ // when recursively calling this function.
+ if (item->isPolishScheduled())
+ item->updatePolish();
topLeftX = item->position().x();
topLeftY = item->position().y();
diff --git a/src/imports/location/qdeclarativegeomap_p.h b/src/imports/location/qdeclarativegeomap_p.h
index 9db3b199..69d4687d 100644
--- a/src/imports/location/qdeclarativegeomap_p.h
+++ b/src/imports/location/qdeclarativegeomap_p.h
@@ -55,6 +55,7 @@
#include <QtQuick/QQuickItem>
#include <QtCore/QPointer>
#include <QtCore/QMutex>
+#include <QtGui/QColor>
#include <QtPositioning/qgeoshape.h>
QT_BEGIN_NAMESPACE
@@ -80,6 +81,7 @@ class QDeclarativeGeoMap : public QQuickItem
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
Q_PROPERTY(QGeoShape visibleRegion READ visibleRegion WRITE setVisibleRegion)
Q_PROPERTY(bool copyrightsVisible READ copyrightsVisible WRITE setCopyrightsVisible NOTIFY copyrightsVisibleChanged)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Q_INTERFACES(QQmlParserStatus)
public:
@@ -111,6 +113,9 @@ public:
void setCopyrightsVisible(bool visible);
bool copyrightsVisible() const;
+ void setColor(const QColor &color);
+ QColor color() const;
+
QQmlListProperty<QDeclarativeGeoMapType> supportedMapTypes();
Q_INVOKABLE void removeMapItem(QDeclarativeGeoMapItemBase *item);
@@ -121,13 +126,8 @@ public:
Q_INVOKABLE QGeoCoordinate toCoordinate(const QPointF &position, bool clipToViewPort = true) const;
Q_INVOKABLE QPointF fromCoordinate(const QGeoCoordinate &coordinate, bool clipToViewPort = true) const;
-#if QT_DEPRECATED_SINCE(5,5)
- QT_DEPRECATED Q_INVOKABLE QPointF toScreenPosition(const QGeoCoordinate &coordinate) const;
-#endif
-
QQuickGeoMapGestureArea *gesture();
- Q_INVOKABLE void fitViewportToGeoShape(const QVariant &shape);
Q_INVOKABLE void fitViewportToMapItems();
Q_INVOKABLE void pan(int dx, int dy);
Q_INVOKABLE void prefetchData(); // optional hint for prefetch
@@ -147,6 +147,7 @@ Q_SIGNALS:
void errorChanged();
void copyrightLinkActivated(const QString &link);
void copyrightsVisibleChanged(bool visible);
+ void colorChanged(const QColor &color);
protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE ;
@@ -196,9 +197,10 @@ private:
QString m_errorString;
QGeoServiceProvider::Error m_error;
qreal m_zoomLevel;
+ QGeoShape m_region;
+ QColor m_color;
bool m_componentCompleted;
bool m_mappingManagerInitialized;
- QGeoShape m_region;
bool m_pendingFitViewport;
bool m_copyrightsVisible;
diff --git a/src/imports/location/qdeclarativegeomapitembase.cpp b/src/imports/location/qdeclarativegeomapitembase.cpp
index e76c11b0..cde00abf 100644
--- a/src/imports/location/qdeclarativegeomapitembase.cpp
+++ b/src/imports/location/qdeclarativegeomapitembase.cpp
@@ -39,6 +39,7 @@
#include <QtQml/QQmlInfo>
#include <QtQuick/QSGOpacityNode>
#include <QtQuick/private/qquickmousearea_p.h>
+#include <QtQuick/private/qquickitem_p.h>
QT_BEGIN_NAMESPACE
@@ -248,6 +249,17 @@ QSGNode *QDeclarativeGeoMapItemBase::updateMapItemPaintNode(QSGNode *oldNode, Up
return 0;
}
+bool QDeclarativeGeoMapItemBase::isPolishScheduled() const
+{
+ return QQuickItemPrivate::get(this)->polishScheduled;
+}
+
+void QDeclarativeGeoMapItemBase::polishAndUpdate()
+{
+ polish();
+ update();
+}
+
#include "moc_qdeclarativegeomapitembase_p.cpp"
diff --git a/src/imports/location/qdeclarativegeomapitembase_p.h b/src/imports/location/qdeclarativegeomapitembase_p.h
index d4ad34c5..c7793fbd 100644
--- a/src/imports/location/qdeclarativegeomapitembase_p.h
+++ b/src/imports/location/qdeclarativegeomapitembase_p.h
@@ -89,13 +89,14 @@ public:
virtual QSGNode *updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *);
protected Q_SLOTS:
- virtual void updateMapItem() = 0;
virtual void afterChildrenChanged();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) = 0;
+ void polishAndUpdate();
protected:
float zoomLevelOpacity() const;
bool childMouseEventFilter(QQuickItem *item, QEvent *event);
+ bool isPolishScheduled() const;
private Q_SLOTS:
void baseCameraDataChanged(const QGeoCameraData &camera);
@@ -106,6 +107,8 @@ private:
QSizeF lastSize_;
QGeoCameraData lastCameraData_;
+
+ friend class QDeclarativeGeoMap;
};
QT_END_NAMESPACE
diff --git a/src/imports/location/qdeclarativegeomapquickitem.cpp b/src/imports/location/qdeclarativegeomapquickitem.cpp
index 81f88dac..ca67b183 100644
--- a/src/imports/location/qdeclarativegeomapquickitem.cpp
+++ b/src/imports/location/qdeclarativegeomapquickitem.cpp
@@ -146,8 +146,7 @@ void QDeclarativeGeoMapQuickItem::setCoordinate(const QGeoCoordinate &coordinate
coordinate_ = coordinate;
- updateMapItem();
-
+ polishAndUpdate();
emit coordinateChanged();
}
@@ -158,10 +157,11 @@ void QDeclarativeGeoMapQuickItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *
{
QDeclarativeGeoMapItemBase::setMap(quickMap,map);
if (map && quickMap) {
- QObject::connect(quickMap, SIGNAL(heightChanged()), this, SLOT(updateMapItem()));
- QObject::connect(quickMap, SIGNAL(widthChanged()), this, SLOT(updateMapItem()));
- QObject::connect(map, SIGNAL(cameraDataChanged(QGeoCameraData)), this, SLOT(updateMapItem()));
- updateMapItem();
+ connect(quickMap, SIGNAL(heightChanged()), this, SLOT(polishAndUpdate()));
+ connect(quickMap, SIGNAL(widthChanged()), this, SLOT(polishAndUpdate()));
+ connect(map, SIGNAL(cameraDataChanged(QGeoCameraData)),
+ this, SLOT(polishAndUpdate()));
+ polishAndUpdate();
}
}
@@ -203,8 +203,7 @@ void QDeclarativeGeoMapQuickItem::setSourceItem(QQuickItem *sourceItem)
return;
sourceItem_ = sourceItem;
- updateMapItem();
-
+ polishAndUpdate();
emit sourceItemChanged();
}
@@ -249,7 +248,7 @@ void QDeclarativeGeoMapQuickItem::setAnchorPoint(const QPointF &anchorPoint)
if (anchorPoint == anchorPoint_)
return;
anchorPoint_ = anchorPoint;
- updateMapItem();
+ polishAndUpdate();
emit anchorPointChanged();
}
@@ -281,7 +280,7 @@ void QDeclarativeGeoMapQuickItem::setZoomLevel(qreal zoomLevel)
if (zoomLevel == zoomLevel_)
return;
zoomLevel_ = zoomLevel;
- updateMapItem();
+ polishAndUpdate();
emit zoomLevelChanged();
}
@@ -293,7 +292,7 @@ qreal QDeclarativeGeoMapQuickItem::zoomLevel() const
/*!
\internal
*/
-void QDeclarativeGeoMapQuickItem::updateMapItem()
+void QDeclarativeGeoMapQuickItem::updatePolish()
{
if (!quickMap() && sourceItem_) {
mapAndSourceItemSet_ = false;
@@ -311,13 +310,13 @@ void QDeclarativeGeoMapQuickItem::updateMapItem()
sourceItem_.data()->setParentItem(opacityContainer_);
sourceItem_.data()->setTransformOrigin(QQuickItem::TopLeft);
connect(sourceItem_.data(), SIGNAL(xChanged()),
- this, SLOT(updateMapItem()));
+ this, SLOT(polishAndUpdate()));
connect(sourceItem_.data(), SIGNAL(yChanged()),
- this, SLOT(updateMapItem()));
+ this, SLOT(polishAndUpdate()));
connect(sourceItem_.data(), SIGNAL(widthChanged()),
- this, SLOT(updateMapItem()));
+ this, SLOT(polishAndUpdate()));
connect(sourceItem_.data(), SIGNAL(heightChanged()),
- this, SLOT(updateMapItem()));
+ this, SLOT(polishAndUpdate()));
}
QScopedValueRollback<bool> rollback(updatingGeometry_);
@@ -330,7 +329,6 @@ void QDeclarativeGeoMapQuickItem::updateMapItem()
setWidth(sourceItem_.data()->width());
setHeight(sourceItem_.data()->height());
setPositionOnMap(coordinate(), scaleFactor() * anchorPoint_);
- update();
}
/*!
diff --git a/src/imports/location/qdeclarativegeomapquickitem_p.h b/src/imports/location/qdeclarativegeomapquickitem_p.h
index af9f6ec6..0410f060 100644
--- a/src/imports/location/qdeclarativegeomapquickitem_p.h
+++ b/src/imports/location/qdeclarativegeomapquickitem_p.h
@@ -90,9 +90,9 @@ Q_SIGNALS:
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void updatePolish() Q_DECL_OVERRIDE;
protected Q_SLOTS:
- virtual void updateMapItem() Q_DECL_OVERRIDE;
virtual void afterChildrenChanged() Q_DECL_OVERRIDE;
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
diff --git a/src/imports/location/qdeclarativepolygonmapitem.cpp b/src/imports/location/qdeclarativepolygonmapitem.cpp
index 9a71614f..6fdef816 100644
--- a/src/imports/location/qdeclarativepolygonmapitem.cpp
+++ b/src/imports/location/qdeclarativepolygonmapitem.cpp
@@ -332,7 +332,7 @@ QDeclarativePolygonMapItem::QDeclarativePolygonMapItem(QQuickItem *parent)
void QDeclarativePolygonMapItem::handleBorderUpdated()
{
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
}
QDeclarativePolygonMapItem::~QDeclarativePolygonMapItem()
@@ -367,7 +367,7 @@ void QDeclarativePolygonMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *m
if (map) {
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
}
}
@@ -423,7 +423,7 @@ void QDeclarativePolygonMapItem::setPath(const QJSValue &value)
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -441,7 +441,7 @@ void QDeclarativePolygonMapItem::addCoordinate(const QGeoCoordinate &coordinate)
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -465,7 +465,7 @@ void QDeclarativePolygonMapItem::removeCoordinate(const QGeoCoordinate &coordina
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -489,7 +489,7 @@ void QDeclarativePolygonMapItem::setColor(const QColor &color)
color_ = color;
dirtyMaterial_ = true;
- updateMapItem();
+ update();
emit colorChanged(color_);
}
@@ -519,7 +519,7 @@ QSGNode *QDeclarativePolygonMapItem::updateMapItemPaintNode(QSGNode *oldNode, Up
/*!
\internal
*/
-void QDeclarativePolygonMapItem::updateMapItem()
+void QDeclarativePolygonMapItem::updatePolish()
{
if (!map() || path_.count() == 0)
return;
@@ -546,7 +546,6 @@ void QDeclarativePolygonMapItem::updateMapItem()
setHeight(combined.height());
setPositionOnMap(path_.at(0), -1 * geometry_.sourceBoundingBox().topLeft());
- update();
}
/*!
@@ -582,7 +581,7 @@ void QDeclarativePolygonMapItem::afterViewportChanged(const QGeoMapViewportChang
borderGeometry_.setPreserveGeometry(true, borderGeometry_.geoLeftBound());
geometry_.markScreenDirty();
borderGeometry_.markScreenDirty();
- updateMapItem();
+ polishAndUpdate();
}
/*!
@@ -639,7 +638,7 @@ void QDeclarativePolygonMapItem::geometryChanged(const QRectF &newGeometry, cons
borderGeometry_.setPreserveGeometry(true, leftBoundCoord);
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
diff --git a/src/imports/location/qdeclarativepolygonmapitem_p.h b/src/imports/location/qdeclarativepolygonmapitem_p.h
index 86a9ec4c..8b803b1d 100644
--- a/src/imports/location/qdeclarativepolygonmapitem_p.h
+++ b/src/imports/location/qdeclarativepolygonmapitem_p.h
@@ -111,9 +111,9 @@ Q_SIGNALS:
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void updatePolish() Q_DECL_OVERRIDE;
protected Q_SLOTS:
- virtual void updateMapItem() Q_DECL_OVERRIDE;
void handleBorderUpdated();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
diff --git a/src/imports/location/qdeclarativepolylinemapitem.cpp b/src/imports/location/qdeclarativepolylinemapitem.cpp
index 9201701c..71a205d3 100644
--- a/src/imports/location/qdeclarativepolylinemapitem.cpp
+++ b/src/imports/location/qdeclarativepolylinemapitem.cpp
@@ -472,7 +472,7 @@ void QDeclarativePolylineMapItem::updateAfterLinePropertiesChanged()
{
// mark dirty just in case we're a width change
geometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
}
/*!
@@ -483,7 +483,7 @@ void QDeclarativePolylineMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *
QDeclarativeGeoMapItemBase::setMap(quickMap,map);
if (map) {
geometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
}
}
@@ -546,7 +546,7 @@ void QDeclarativePolylineMapItem::setPathFromGeoList(const QList<QGeoCoordinate>
path_ = path;
geometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -563,7 +563,7 @@ void QDeclarativePolylineMapItem::addCoordinate(const QGeoCoordinate &coordinate
path_.append(coordinate);
geometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -586,7 +586,7 @@ void QDeclarativePolylineMapItem::removeCoordinate(const QGeoCoordinate &coordin
path_.removeAt(index);
geometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -652,7 +652,7 @@ void QDeclarativePolylineMapItem::geometryChanged(const QRectF &newGeometry, con
+ newCoordinate.longitude() - firstLongitude));
geometry_.setPreserveGeometry(true, leftBoundCoord);
geometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -688,13 +688,13 @@ void QDeclarativePolylineMapItem::afterViewportChanged(const QGeoMapViewportChan
}
geometry_.setPreserveGeometry(true, geometry_.geoLeftBound());
geometry_.markScreenDirty();
- updateMapItem();
+ polishAndUpdate();
}
/*!
\internal
*/
-void QDeclarativePolylineMapItem::updateMapItem()
+void QDeclarativePolylineMapItem::updatePolish()
{
if (!map() || path_.count() == 0)
return;
@@ -709,7 +709,6 @@ void QDeclarativePolylineMapItem::updateMapItem()
setHeight(geometry_.sourceBoundingBox().height());
setPositionOnMap(path_.at(0), -1 * geometry_.sourceBoundingBox().topLeft());
- update();
}
/*!
diff --git a/src/imports/location/qdeclarativepolylinemapitem_p.h b/src/imports/location/qdeclarativepolylinemapitem_p.h
index 6eeeb11f..a7b7f167 100644
--- a/src/imports/location/qdeclarativepolylinemapitem_p.h
+++ b/src/imports/location/qdeclarativepolylinemapitem_p.h
@@ -132,9 +132,9 @@ Q_SIGNALS:
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
void setPathFromGeoList(const QList<QGeoCoordinate> &path);
+ void updatePolish() Q_DECL_OVERRIDE;
protected Q_SLOTS:
- virtual void updateMapItem() Q_DECL_OVERRIDE;
void updateAfterLinePropertiesChanged();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
diff --git a/src/imports/location/qdeclarativerectanglemapitem.cpp b/src/imports/location/qdeclarativerectanglemapitem.cpp
index 2dbb630b..c28bcf3e 100644
--- a/src/imports/location/qdeclarativerectanglemapitem.cpp
+++ b/src/imports/location/qdeclarativerectanglemapitem.cpp
@@ -177,9 +177,9 @@ QDeclarativeRectangleMapItem::QDeclarativeRectangleMapItem(QQuickItem *parent)
{
setFlag(ItemHasContents, true);
QObject::connect(&border_, SIGNAL(colorChanged(QColor)),
- this, SLOT(updateMapItemAssumeDirty()));
+ this, SLOT(markSourceDirtyAndUpdate()));
QObject::connect(&border_, SIGNAL(widthChanged(qreal)),
- this, SLOT(updateMapItemAssumeDirty()));
+ this, SLOT(markSourceDirtyAndUpdate()));
}
QDeclarativeRectangleMapItem::~QDeclarativeRectangleMapItem()
@@ -192,11 +192,8 @@ QDeclarativeRectangleMapItem::~QDeclarativeRectangleMapItem()
void QDeclarativeRectangleMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map)
{
QDeclarativeGeoMapItemBase::setMap(quickMap,map);
- if (map) {
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
- }
+ if (map)
+ markSourceDirtyAndUpdate();
}
/*!
@@ -229,9 +226,7 @@ void QDeclarativeRectangleMapItem::setTopLeft(const QGeoCoordinate &topLeft)
topLeft_ = topLeft;
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
+ markSourceDirtyAndUpdate();
emit topLeftChanged(topLeft_);
}
@@ -243,11 +238,11 @@ QGeoCoordinate QDeclarativeRectangleMapItem::topLeft()
/*!
\internal
*/
-void QDeclarativeRectangleMapItem::updateMapItemAssumeDirty()
+void QDeclarativeRectangleMapItem::markSourceDirtyAndUpdate()
{
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
}
/*!
@@ -263,9 +258,7 @@ void QDeclarativeRectangleMapItem::setBottomRight(const QGeoCoordinate &bottomRi
bottomRight_ = bottomRight;
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
+ markSourceDirtyAndUpdate();
emit bottomRightChanged(bottomRight_);
}
@@ -291,7 +284,7 @@ void QDeclarativeRectangleMapItem::setColor(const QColor &color)
return;
color_ = color;
dirtyMaterial_ = true;
- updateMapItem();
+ polishAndUpdate();
emit colorChanged(color_);
}
@@ -333,7 +326,7 @@ QSGNode *QDeclarativeRectangleMapItem::updateMapItemPaintNode(QSGNode *oldNode,
/*!
\internal
*/
-void QDeclarativeRectangleMapItem::updateMapItem()
+void QDeclarativeRectangleMapItem::updatePolish()
{
if (!map() || !topLeft().isValid() || !bottomRight().isValid())
return;
@@ -368,7 +361,6 @@ void QDeclarativeRectangleMapItem::updateMapItem()
}
setPositionOnMap(pathClosed.at(0), geometry_.firstPointOffset());
- update();
}
/*!
@@ -404,7 +396,7 @@ void QDeclarativeRectangleMapItem::afterViewportChanged(const QGeoMapViewportCha
borderGeometry_.setPreserveGeometry(true, borderGeometry_.geoLeftBound());
geometry_.markScreenDirty();
borderGeometry_.markScreenDirty();
- updateMapItem();
+ polishAndUpdate();
}
/*!
@@ -448,9 +440,7 @@ void QDeclarativeRectangleMapItem::geometryChanged(const QRectF &newGeometry, co
bottomRight_ = newBottomRight;
geometry_.setPreserveGeometry(true, newTopLeft);
borderGeometry_.setPreserveGeometry(true, newTopLeft);
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
+ markSourceDirtyAndUpdate();
emit topLeftChanged(topLeft_);
emit bottomRightChanged(bottomRight_);
}
diff --git a/src/imports/location/qdeclarativerectanglemapitem_p.h b/src/imports/location/qdeclarativerectanglemapitem_p.h
index d4c319ab..fb9936b0 100644
--- a/src/imports/location/qdeclarativerectanglemapitem_p.h
+++ b/src/imports/location/qdeclarativerectanglemapitem_p.h
@@ -105,10 +105,10 @@ Q_SIGNALS:
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void updatePolish() Q_DECL_OVERRIDE;
protected Q_SLOTS:
- virtual void updateMapItem() Q_DECL_OVERRIDE;
- void updateMapItemAssumeDirty();
+ void markSourceDirtyAndUpdate();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
private:
diff --git a/src/imports/location/qdeclarativeroutemapitem.cpp b/src/imports/location/qdeclarativeroutemapitem.cpp
index 78485cc0..19930cc3 100644
--- a/src/imports/location/qdeclarativeroutemapitem.cpp
+++ b/src/imports/location/qdeclarativeroutemapitem.cpp
@@ -119,12 +119,19 @@ void QDeclarativeRouteMapItem::setRoute(QDeclarativeGeoRoute *route)
route_ = route;
+ connect(route_, SIGNAL(pathChanged()), this, SLOT(updateRoutePath()));
+
if (route_)
setPathFromGeoList(route_->routePath());
emit routeChanged(route_);
}
+void QDeclarativeRouteMapItem::updateRoutePath()
+{
+ setPathFromGeoList(route_->routePath());
+}
+
/*!
\internal void QDeclarativeRouteMapItem::setPath(const QJSValue &value)
diff --git a/src/imports/location/qdeclarativeroutemapitem_p.h b/src/imports/location/qdeclarativeroutemapitem_p.h
index 9bb3a443..3acac3cc 100644
--- a/src/imports/location/qdeclarativeroutemapitem_p.h
+++ b/src/imports/location/qdeclarativeroutemapitem_p.h
@@ -74,6 +74,9 @@ public:
Q_SIGNALS:
void routeChanged(const QDeclarativeGeoRoute *route);
+private slots:
+ void updateRoutePath();
+
protected:
void setPath(const QJSValue &value) Q_DECL_OVERRIDE;
diff --git a/src/imports/location/qquickgeomapgesturearea.cpp b/src/imports/location/qquickgeomapgesturearea.cpp
index baa9e702..70dffc19 100644
--- a/src/imports/location/qquickgeomapgesturearea.cpp
+++ b/src/imports/location/qquickgeomapgesturearea.cpp
@@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmltype MapPinchEvent
- \instantiates QDeclarativeGeoMapPinchEvent
+ \instantiates QGeoMapPinchEvent
\inqmlmodule QtLocation
\brief MapPinchEvent type provides basic information about pinch event.
@@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE
without its parent Map.
The two most commonly used properties of the MapGestureArea are the \l enabled
- and \l activeGestures properties. Both of these must be set before a
+ and \l acceptedGestures properties. Both of these must be set before a
MapGestureArea will have any effect upon interaction with the Map.
The \l flickDeceleration property controls how quickly the map pan slows after contact
is released while panning the map.
@@ -172,13 +172,13 @@ QT_BEGIN_NAMESPACE
\section2 Example Usage
- The following example enables the zoom and pan gestures on the map, but not flicking. So the
+ The following example enables the pinch and pan gestures on the map, but not flicking. So the
map scrolling will halt immediately on releasing the mouse button / touch.
\code
Map {
gesture.enabled: true
- gesture.activeGestures: MapGestureArea.ZoomGesture | MapGestureArea.PanGesture
+ gesture.acceptedGestures: MapGestureArea.PinchGesture | MapGestureArea.PanGesture
}
\endcode
@@ -190,56 +190,23 @@ QT_BEGIN_NAMESPACE
\qmlproperty bool QtLocation::MapGestureArea::enabled
This property holds whether the gestures are enabled.
- Note: disabling gestures during an active gesture does not have effect on
- the potentially active current gesture.
-*/
-
-
-/*!
- \qmlproperty bool QtLocation::MapGestureArea::panEnabled
-
- This property holds whether the pan gestures are enabled.
- Note: disabling gestures during an active gesture does not have effect on
- the potentially active current gesture.
*/
/*!
- \qmlproperty bool QtLocation::MapGestureArea::pinchEnabled
+ \qmlproperty bool QtLocation::MapGestureArea::pinchActive
- This property holds whether the pinch gestures are enabled.
- Note: disabling gestures during an active gesture does not have effect on
- the potentially active current gesture.
+ This read-only property holds whether pinch gesture is active.
*/
/*!
- \qmlproperty bool QtLocation::MapGestureArea::isPinchActive
+ \qmlproperty bool QtLocation::MapGestureArea::panActive
- This read-only property holds whether any pinch gesture is active.
-*/
-
-/*!
- \qmlproperty bool QtLocation::MapGestureArea::isPanActive
-
- This read-only property holds whether any pan gesture (panning or flicking) is active.
+ This read-only property holds whether pan gesture is active.
\note Change notifications for this property were introduced in Qt 5.5.
*/
/*!
- \qmlproperty enumeration QtLocation::MapGestureArea::activeGestures
-
- This property holds the gestures that will be active. By default
- the zoom, pan and flick gestures are enabled.
-
- \list
- \li MapGestureArea.NoGesture - Don't support any additional gestures (value: 0x0000).
- \li MapGestureArea.ZoomGesture - Support the map zoom gesture (value: 0x0001).
- \li MapGestureArea.PanGesture - Support the map pan gesture (value: 0x0002).
- \li MapGestureArea.FlickGesture - Support the map flick gesture (value: 0x0004).
- \endlist
-*/
-
-/*!
\qmlproperty real QtLocation::MapGestureArea::maximumZoomLevelChange
This property holds the maximum zoom level change per pinch, essentially
@@ -292,7 +259,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtLocation::MapGestureArea::panStarted()
- This signal is emitted when the view begins moving due to user
+ This signal is emitted when the map begins to move due to user
interaction. Typically this means that the user is dragging a finger -
or a mouse with one of more mouse buttons pressed - on the map.
@@ -302,9 +269,9 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtLocation::MapGestureArea::panFinished()
- This signal is emitted when the view stops moving due to user
+ This signal is emitted when the map stops moving due to user
interaction. If a flick was generated, this signal is
- emitted when the flick stops. If a flick was not
+ emitted before flick starts. If a flick was not
generated, this signal is emitted when the
user stops dragging - that is a mouse or touch release.
@@ -315,8 +282,8 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtLocation::MapGestureArea::flickStarted()
- This signal is emitted when the view is flicked. A flick
- starts from the point that the mouse or touch is released,
+ This signal is emitted when the map is flicked. A flick
+ starts from the point where the mouse or touch was released,
while still in motion.
The corresponding handler is \c onFlichStarted.
@@ -325,8 +292,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtLocation::MapGestureArea::flickFinished()
- This signal is emitted when the view stops moving due to a flick.
- The order of panFinished() and flickFinished() is not specified.
+ This signal is emitted when the map stops moving due to a flick.
The corresponding handler is \c onFlickFinished.
*/
@@ -336,8 +302,9 @@ QQuickGeoMapGestureArea::QQuickGeoMapGestureArea(QDeclarativeGeoMap *map)
m_map(0),
m_declarativeMap(map),
m_enabled(true),
- m_activeGestures(ZoomGesture | PanGesture | FlickGesture),
- m_preventStealing(false)
+ m_acceptedGestures(PinchGesture | PanGesture | FlickGesture),
+ m_preventStealing(false),
+ m_panEnabled(true)
{
m_flick.m_enabled = true,
m_flick.m_maxVelocity = QML_MAP_FLICK_DEFAULTMAXVELOCITY;
@@ -401,22 +368,36 @@ QQuickGeoMapGestureArea::~QQuickGeoMapGestureArea()
}
/*!
- \internal
+ \qmlproperty enumeration QtLocation::MapGestureArea::acceptedGestures
+
+ This property holds the gestures that will be active. By default
+ the zoom, pan and flick gestures are enabled.
+
+ \list
+ \li MapGestureArea.NoGesture - Don't support any additional gestures (value: 0x0000).
+ \li MapGestureArea.PinchGesture - Support the map pinch gesture (value: 0x0001).
+ \li MapGestureArea.PanGesture - Support the map pan gesture (value: 0x0002).
+ \li MapGestureArea.FlickGesture - Support the map flick gesture (value: 0x0004).
+ \endlist
*/
-QQuickGeoMapGestureArea::ActiveGestures QQuickGeoMapGestureArea::activeGestures() const
+
+QQuickGeoMapGestureArea::AcceptedGestures QQuickGeoMapGestureArea::acceptedGestures() const
{
- return m_activeGestures;
+ return m_acceptedGestures;
}
-/*!
- \internal
-*/
-void QQuickGeoMapGestureArea::setActiveGestures(ActiveGestures activeGestures)
+
+void QQuickGeoMapGestureArea::setAcceptedGestures(AcceptedGestures acceptedGestures)
{
- if (activeGestures == m_activeGestures)
+ if (acceptedGestures == m_acceptedGestures)
return;
- m_activeGestures = activeGestures;
- emit activeGesturesChanged();
+ m_acceptedGestures = acceptedGestures;
+
+ setPanEnabled(acceptedGestures & GeoMapGesture::PanGesture);
+ setFlickEnabled(acceptedGestures & GeoMapGesture::FlickGesture);
+ setPinchEnabled(acceptedGestures & GeoMapGesture::PinchGesture);
+
+ emit acceptedGesturesChanged();
}
/*!
@@ -451,6 +432,17 @@ void QQuickGeoMapGestureArea::setEnabled(bool enabled)
if (enabled == m_enabled)
return;
m_enabled = enabled;
+
+ if (enabled) {
+ setPanEnabled(m_acceptedGestures & GeoMapGesture::PanGesture);
+ setFlickEnabled(m_acceptedGestures & GeoMapGesture::FlickGesture);
+ setPinchEnabled(m_acceptedGestures & GeoMapGesture::PinchGesture);
+ } else {
+ setPanEnabled(false);
+ setFlickEnabled(false);
+ setPinchEnabled(false);
+ }
+
emit enabledChanged();
}
@@ -471,7 +463,6 @@ void QQuickGeoMapGestureArea::setPinchEnabled(bool enabled)
if (enabled == m_pinch.m_enabled)
return;
m_pinch.m_enabled = enabled;
- emit pinchEnabledChanged();
}
/*!
@@ -479,7 +470,7 @@ void QQuickGeoMapGestureArea::setPinchEnabled(bool enabled)
*/
bool QQuickGeoMapGestureArea::panEnabled() const
{
- return m_flick.m_enabled;
+ return m_panEnabled;
}
/*!
@@ -489,8 +480,7 @@ void QQuickGeoMapGestureArea::setPanEnabled(bool enabled)
{
if (enabled == m_flick.m_enabled)
return;
- m_flick.m_enabled = enabled;
- emit panEnabledChanged();
+ m_panEnabled = enabled;
// unlike the pinch, the pan existing functionality is to stop immediately
if (!enabled)
@@ -499,6 +489,28 @@ void QQuickGeoMapGestureArea::setPanEnabled(bool enabled)
/*!
\internal
+*/
+bool QQuickGeoMapGestureArea::flickEnabled() const
+{
+ return m_flick.m_enabled;
+}
+
+/*!
+ \internal
+*/
+void QQuickGeoMapGestureArea::setFlickEnabled(bool enabled)
+{
+ if (enabled == m_flick.m_enabled)
+ return;
+ m_flick.m_enabled = enabled;
+ // unlike the pinch, the flick existing functionality is to stop immediately
+ if (!enabled) {
+ stopFlick();
+ }
+}
+
+/*!
+ \internal
Used internally to set the minimum zoom level of the gesture area.
The caller is responsible to only send values that are valid
for the map plugin. Negative values are ignored.
@@ -761,14 +773,14 @@ void QQuickGeoMapGestureArea::update()
touchPointStateMachine();
// Parallel state machine for pinch
- if (isPinchActive() || (m_enabled && m_pinch.m_enabled && (m_activeGestures & (ZoomGesture))))
+ if (isPinchActive() || (m_enabled && m_pinch.m_enabled && (m_acceptedGestures & (PinchGesture))))
pinchStateMachine();
// Parallel state machine for pan (since you can pan at the same time as pinching)
// The stopPan function ensures that pan stops immediately when disabled,
// but the line below allows pan continue its current gesture if you disable
// the whole gesture (enabled_ flag), this keeps the enabled_ consistent with the pinch
- if (isPanActive() || (m_enabled && m_flick.m_enabled && (m_activeGestures & (PanGesture | FlickGesture))))
+ if (isPanActive() || (m_enabled && m_flick.m_enabled && (m_acceptedGestures & (PanGesture | FlickGesture))))
panStateMachine();
}
@@ -1019,7 +1031,7 @@ void QQuickGeoMapGestureArea::updatePinch()
m_pinch.m_lastAngle = m_twoTouchAngle;
emit pinchUpdated(&m_pinch.m_event);
- if (m_activeGestures & ZoomGesture) {
+ if (m_acceptedGestures & PinchGesture) {
// Take maximum and minimumzoomlevel into account
qreal perPinchMinimumZoomLevel = qMax(m_pinch.m_zoom.m_start - m_pinch.m_zoom.maximumChange, m_pinch.m_zoom.m_minimum);
qreal perPinchMaximumZoomLevel = qMin(m_pinch.m_zoom.m_start + m_pinch.m_zoom.maximumChange, m_pinch.m_zoom.m_maximum);
@@ -1067,22 +1079,25 @@ void QQuickGeoMapGestureArea::panStateMachine()
break;
case panActive:
if (m_allPoints.count() == 0) {
- m_flickState = flickActive;
if (!tryStartFlick())
{
m_flickState = flickInactive;
// mark as inactive for use by camera
if (m_pinchState == pinchInactive) {
m_declarativeMap->setKeepMouseGrab(m_preventStealing);
- emit panFinished();
m_map->prefetchData();
}
+ emit panFinished();
+ } else {
+ m_flickState = flickActive;
+ emit panFinished();
+ emit flickStarted();
}
}
break;
case flickActive:
if (m_allPoints.count() > 0) { // re touched before movement ended
- endFlick();
+ stopFlick();
m_declarativeMap->setKeepMouseGrab(true);
m_flickState = panActive;
}
@@ -1111,7 +1126,7 @@ void QQuickGeoMapGestureArea::panStateMachine()
*/
bool QQuickGeoMapGestureArea::canStartPan()
{
- if (m_allPoints.count() == 0 || (m_activeGestures & PanGesture) == 0)
+ if (m_allPoints.count() == 0 || (m_acceptedGestures & PanGesture) == 0)
return false;
// Check if thresholds for normal panning are met.
@@ -1145,7 +1160,7 @@ void QQuickGeoMapGestureArea::updatePan()
*/
bool QQuickGeoMapGestureArea::tryStartFlick()
{
- if ((m_activeGestures & FlickGesture) == 0)
+ if ((m_acceptedGestures & FlickGesture) == 0)
return false;
// if we drag then pause before release we should not cause a flick.
qreal velocityX = 0.0;
@@ -1218,16 +1233,15 @@ void QQuickGeoMapGestureArea::startFlick(int dx, int dy, int timeMs)
m_flick.m_animation->setFrom(animationStartCoordinate);
m_flick.m_animation->setTo(animationEndCoordinate);
m_flick.m_animation->start();
- emit flickStarted();
}
void QQuickGeoMapGestureArea::stopPan()
{
- m_velocityX = 0;
- m_velocityY = 0;
if (m_flickState == flickActive) {
- endFlick();
+ stopFlick();
} else if (m_flickState == panActive) {
+ m_velocityX = 0;
+ m_velocityY = 0;
m_flickState = flickInactive;
m_declarativeMap->setKeepMouseGrab(m_preventStealing);
emit panFinished();
@@ -1239,8 +1253,10 @@ void QQuickGeoMapGestureArea::stopPan()
/*!
\internal
*/
-void QQuickGeoMapGestureArea::endFlick()
+void QQuickGeoMapGestureArea::stopFlick()
{
+ m_velocityX = 0;
+ m_velocityY = 0;
if (m_flick.m_animation->isRunning())
m_flick.m_animation->stop();
else
@@ -1250,17 +1266,13 @@ void QQuickGeoMapGestureArea::endFlick()
void QQuickGeoMapGestureArea::handleFlickAnimationStopped()
{
m_declarativeMap->setKeepMouseGrab(m_preventStealing);
- emit panFinished();
- emit flickFinished();
- m_flickState = flickInactive;
- emit panActiveChanged();
- m_map->prefetchData();
+ if (m_flickState == flickActive) {
+ m_flickState = flickInactive;
+ emit flickFinished();
+ m_map->prefetchData();
+ }
}
-
-
-
-
#include "moc_qquickgeomapgesturearea_p.cpp"
QT_END_NAMESPACE
diff --git a/src/imports/location/qquickgeomapgesturearea_p.h b/src/imports/location/qquickgeomapgesturearea_p.h
index 43bb2ce5..cfd8738e 100644
--- a/src/imports/location/qquickgeomapgesturearea_p.h
+++ b/src/imports/location/qquickgeomapgesturearea_p.h
@@ -64,7 +64,7 @@ class QTouchEvent;
class QWheelEvent;
class QGeoMap;
-class QDeclarativeGeoMapPinchEvent : public QObject
+class QGeoMapPinchEvent : public QObject
{
Q_OBJECT
@@ -76,13 +76,13 @@ class QDeclarativeGeoMapPinchEvent : public QObject
Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
public:
- QDeclarativeGeoMapPinchEvent(const QPointF &center, qreal angle,
+ QGeoMapPinchEvent(const QPointF &center, qreal angle,
const QPointF &point1, const QPointF &point2,
int pointCount = 0, bool accepted = true)
: QObject(), m_center(center), m_angle(angle),
m_point1(point1), m_point2(point2),
m_pointCount(pointCount), m_accepted(accepted) {}
- QDeclarativeGeoMapPinchEvent()
+ QGeoMapPinchEvent()
: QObject(),
m_angle(0.0),
m_pointCount(0),
@@ -113,32 +113,32 @@ private:
class QQuickGeoMapGestureArea: public QQuickItem
{
Q_OBJECT
- Q_ENUMS(ActiveGesture)
- Q_FLAGS(ActiveGestures)
+ Q_ENUMS(GeoMapGesture)
+ Q_FLAGS(AcceptedGestures)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
- Q_PROPERTY(bool pinchEnabled READ pinchEnabled WRITE setPinchEnabled NOTIFY pinchEnabledChanged)
- Q_PROPERTY(bool panEnabled READ panEnabled WRITE setPanEnabled NOTIFY panEnabledChanged)
- Q_PROPERTY(bool isPinchActive READ isPinchActive NOTIFY pinchActiveChanged)
- Q_PROPERTY(bool isPanActive READ isPanActive NOTIFY panActiveChanged)
- Q_PROPERTY(ActiveGestures activeGestures READ activeGestures WRITE setActiveGestures NOTIFY activeGesturesChanged)
+ Q_PROPERTY(bool pinchActive READ isPinchActive NOTIFY pinchActiveChanged)
+ Q_PROPERTY(bool panActive READ isPanActive NOTIFY panActiveChanged)
+ Q_PROPERTY(AcceptedGestures acceptedGestures READ acceptedGestures WRITE setAcceptedGestures NOTIFY acceptedGesturesChanged)
Q_PROPERTY(qreal maximumZoomLevelChange READ maximumZoomLevelChange WRITE setMaximumZoomLevelChange NOTIFY maximumZoomLevelChangeChanged)
Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged REVISION 1)
+
public:
QQuickGeoMapGestureArea(QDeclarativeGeoMap *map);
~QQuickGeoMapGestureArea();
- enum ActiveGesture {
+ enum GeoMapGesture {
NoGesture = 0x0000,
- ZoomGesture = 0x0001,
+ PinchGesture = 0x0001,
PanGesture = 0x0002,
FlickGesture = 0x004
};
- Q_DECLARE_FLAGS(ActiveGestures, ActiveGesture)
- ActiveGestures activeGestures() const;
- void setActiveGestures(ActiveGestures activeGestures);
+ Q_DECLARE_FLAGS(AcceptedGestures, GeoMapGesture)
+
+ AcceptedGestures acceptedGestures() const;
+ void setAcceptedGestures(AcceptedGestures acceptedGestures);
bool isPinchActive() const;
bool isPanActive() const;
@@ -147,12 +147,6 @@ public:
bool enabled() const;
void setEnabled(bool enabled);
- // backwards compatibility
- bool pinchEnabled() const;
- void setPinchEnabled(bool enabled);
- bool panEnabled() const;
- void setPanEnabled(bool enabled);
-
qreal maximumZoomLevelChange() const;
void setMaximumZoomLevelChange(qreal maxChange);
@@ -183,16 +177,11 @@ Q_SIGNALS:
void pinchActiveChanged();
void enabledChanged();
void maximumZoomLevelChangeChanged();
- void activeGesturesChanged();
+ void acceptedGesturesChanged();
void flickDecelerationChanged();
-
- // backwards compatibility
- void pinchEnabledChanged();
- void panEnabledChanged();
-
- void pinchStarted(QDeclarativeGeoMapPinchEvent *pinch);
- void pinchUpdated(QDeclarativeGeoMapPinchEvent *pinch);
- void pinchFinished(QDeclarativeGeoMapPinchEvent *pinch);
+ void pinchStarted(QGeoMapPinchEvent *pinch);
+ void pinchUpdated(QGeoMapPinchEvent *pinch);
+ void pinchFinished(QGeoMapPinchEvent *pinch);
void panStarted();
void panFinished();
void flickStarted();
@@ -222,7 +211,15 @@ private:
void updatePan();
bool tryStartFlick();
void startFlick(int dx, int dy, int timeMs = 0);
- void endFlick();
+ void stopFlick();
+
+ bool pinchEnabled() const;
+ void setPinchEnabled(bool enabled);
+ bool panEnabled() const;
+ void setPanEnabled(bool enabled);
+ bool flickEnabled() const;
+ void setFlickEnabled(bool enabled);
+
private Q_SLOTS:
void handleFlickAnimationStopped();
@@ -241,7 +238,7 @@ private:
{
Pinch() : m_enabled(true), m_startDist(0), m_lastAngle(0.0) {}
- QDeclarativeGeoMapPinchEvent m_event;
+ QGeoMapPinchEvent m_event;
bool m_enabled;
struct Zoom
{
@@ -260,7 +257,7 @@ private:
qreal m_lastAngle;
} m_pinch;
- ActiveGestures m_activeGestures;
+ AcceptedGestures m_acceptedGestures;
struct Pan
{
@@ -289,6 +286,7 @@ private:
qreal m_distanceBetweenTouchPoints;
QPointF m_sceneCenter;
bool m_preventStealing;
+ bool m_panEnabled;
// prototype state machine...
enum TouchPointState
diff --git a/src/location/doc/qtlocation.qdocconf b/src/location/doc/qtlocation.qdocconf
index 695860a0..abe48974 100644
--- a/src/location/doc/qtlocation.qdocconf
+++ b/src/location/doc/qtlocation.qdocconf
@@ -41,7 +41,7 @@ sourcedirs += .. \
../../imports/location \
../../plugins/geoservices/nokia
-examplesinstallpath = location
+examplesinstallpath = qtlocation/location
exampledirs += ../../../examples/location \
snippets/
diff --git a/src/location/doc/src/qtlocation-changes.qdoc b/src/location/doc/src/qtlocation-changes.qdoc
index 0645c088..1c79c582 100644
--- a/src/location/doc/src/qtlocation-changes.qdoc
+++ b/src/location/doc/src/qtlocation-changes.qdoc
@@ -33,18 +33,24 @@
\b{\l{QtLocation::Map}{Map} Component}
\list
\li removed wheelAngleChanged() signal
- \li added \l[QML]{QtLocation::Map}{error} property
- \li added \l[QML]{QtLocation::Map}{errorString} property
- \li added \l[QML]{QtLocation::Map}{copyrightLinkActivated} signal
+ \li added \l[QML]{QtLocation::Map::}{error} property
+ \li added \l[QML]{QtLocation::Map::}{errorString} property
+ \li added \l[QML]{QtLocation::Map::}{copyrightLinkActivated} signal
\li removed toScreenPosition() method
- \li added \l[QML]{QtLocation::Map}{fromCoordinate}() method
- \li replaced cameraStopped() method with \l[QML]{QtLocation::Map}{prefetchData}() method
+ \li added \l[QML]{QtLocation::Map::}{fromCoordinate}() method
+ \li replaced cameraStopped() method with \l[QML]{QtLocation::Map::}{prefetchData} method
+ \li replaced fitViewportToGeoShape() method with \l[QML]{QtLocation::Map::}{visibleRegion} property
+
\endlist
\b{\l{QtLocation::MapGestureArea}{MapGestureArea} Component}
\list
- \li added missing panActiveChanged() signal to \l[QML]{QtLocation::MapGestureArea::}{isPanActive} property
+ \li added missing panActiveChanged() signal to \l[QML]{QtLocation::MapGestureArea::}{panActive} property
\li removed movementStopped() signal
+ \li replaced isPanActive, isPinchActive with panActive, pinchActive
+ \li replaced activeGestures with acceptedGestures
+ \li replaced ZoomGesture with PinchGesture
+ \li removed properties panEnabled pinchEnable, please use acceptedGestures instead
\endlist
\b Geoservice's plugin parameters
diff --git a/src/location/maps/maps.pri b/src/location/maps/maps.pri
index 43e0f747..93af4f4d 100644
--- a/src/location/maps/maps.pri
+++ b/src/location/maps/maps.pri
@@ -49,7 +49,8 @@ PRIVATE_HEADERS += \
maps/qgeoroutingmanagerengine_p.h \
maps/qgeoroutingmanager_p.h \
maps/qgeoserviceprovider_p.h \
- maps/qgeotilecache_p.h \
+ maps/qabstractgeotilecache_p.h \
+ maps/qgeofiletilecache_p.h \
maps/qgeotiledmapreply_p.h \
maps/qgeotiledmapreply_p_p.h \
maps/qgeotilespec_p.h \
@@ -81,7 +82,8 @@ SOURCES += \
maps/qgeoroutingmanagerengine.cpp \
maps/qgeoserviceprovider.cpp \
maps/qgeoserviceproviderfactory.cpp \
- maps/qgeotilecache.cpp \
+ maps/qabstractgeotilecache.cpp \
+ maps/qgeofiletilecache.cpp \
maps/qgeotiledmapreply.cpp \
maps/qgeotilespec.cpp \
maps/qgeotiledmap.cpp
diff --git a/src/location/maps/qabstractgeotilecache.cpp b/src/location/maps/qabstractgeotilecache.cpp
new file mode 100644
index 00000000..739123db
--- /dev/null
+++ b/src/location/maps/qabstractgeotilecache.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qabstractgeotilecache_p.h"
+
+#include "qgeotilespec_p.h"
+
+#include "qgeomappingmanager_p.h"
+
+#include <QDir>
+#include <QStandardPaths>
+#include <QMetaType>
+#include <QPixmap>
+#include <QDebug>
+
+Q_DECLARE_METATYPE(QList<QGeoTileSpec>)
+Q_DECLARE_METATYPE(QSet<QGeoTileSpec>)
+
+QT_BEGIN_NAMESPACE
+
+QGeoTileTexture::QGeoTileTexture()
+ : textureBound(false) {}
+
+QGeoTileTexture::~QGeoTileTexture()
+{
+}
+
+QAbstractGeoTileCache::QAbstractGeoTileCache(QObject *parent)
+ : QObject(parent)
+{
+ qRegisterMetaType<QGeoTileSpec>();
+ qRegisterMetaType<QList<QGeoTileSpec> >();
+ qRegisterMetaType<QSet<QGeoTileSpec> >();
+}
+
+QAbstractGeoTileCache::~QAbstractGeoTileCache()
+{
+}
+
+void QAbstractGeoTileCache::printStats()
+{
+}
+
+void QAbstractGeoTileCache::handleError(const QGeoTileSpec &, const QString &error)
+{
+ qWarning() << "tile request error " << error;
+}
+
+void QAbstractGeoTileCache::setMaxDiskUsage(int diskUsage)
+{
+ Q_UNUSED(diskUsage);
+}
+
+int QAbstractGeoTileCache::maxDiskUsage() const
+{
+ return 0;
+}
+
+int QAbstractGeoTileCache::diskUsage() const
+{
+ return 0;
+}
+
+void QAbstractGeoTileCache::setMaxMemoryUsage(int memoryUsage)
+{
+ Q_UNUSED(memoryUsage);
+}
+
+int QAbstractGeoTileCache::maxMemoryUsage() const
+{
+ return 0;
+}
+
+int QAbstractGeoTileCache::memoryUsage() const
+{
+ return 0;
+}
+
+QString QAbstractGeoTileCache::baseCacheDirectory()
+{
+ QString dir;
+
+ // Try the shared cache first and use a specific directory. (e.g. ~/.cache/QtLocation)
+ // If this is not supported by the platform, use the application-specific cache
+ // location. (e.g. ~/.cache/<app_name>/QtLocation)
+ dir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+
+ if (!dir.isEmpty()) {
+ // The shared cache may not be writable when application isolation is enforced.
+ static bool writable = false;
+ static bool writableChecked = false;
+ if (!writableChecked) {
+ writableChecked = true;
+ QDir::root().mkpath(dir);
+ QFile writeTestFile(QDir(dir).filePath(QStringLiteral("qt_cache_check")));
+ writable = writeTestFile.open(QIODevice::WriteOnly);
+ if (writable)
+ writeTestFile.remove();
+ }
+ if (!writable)
+ dir = QString();
+ }
+
+ if (dir.isEmpty())
+ dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
+
+ if (!dir.endsWith(QLatin1Char('/')))
+ dir += QLatin1Char('/');
+
+ dir += QLatin1String("QtLocation/");
+
+ return dir;
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/maps/qabstractgeotilecache_p.h b/src/location/maps/qabstractgeotilecache_p.h
new file mode 100644
index 00000000..e368066f
--- /dev/null
+++ b/src/location/maps/qabstractgeotilecache_p.h
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QABSTRACTGEOTILECACHE_P_H
+#define QABSTRACTGEOTILECACHE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtLocation/qlocationglobal.h>
+
+#include <QObject>
+#include <QCache>
+#include "qcache3q_p.h"
+#include <QSet>
+#include <QMutex>
+#include <QTimer>
+
+#include "qgeotilespec_p.h"
+#include "qgeotiledmappingmanagerengine_p.h"
+
+#include <QImage>
+
+QT_BEGIN_NAMESPACE
+
+class QGeoMappingManager;
+
+class QGeoTile;
+class QAbstractGeoTileCache;
+
+class QThread;
+
+/* This is also used in the mapgeometry */
+class Q_LOCATION_EXPORT QGeoTileTexture
+{
+public:
+
+ QGeoTileTexture();
+ ~QGeoTileTexture();
+
+ QGeoTileSpec spec;
+ QImage image;
+ bool textureBound;
+};
+
+class Q_LOCATION_EXPORT QAbstractGeoTileCache : public QObject
+{
+ Q_OBJECT
+public:
+ virtual ~QAbstractGeoTileCache();
+
+ virtual void setMaxDiskUsage(int diskUsage);
+ virtual int maxDiskUsage() const;
+ virtual int diskUsage() const;
+
+ virtual void setMaxMemoryUsage(int memoryUsage);
+ virtual int maxMemoryUsage() const;
+ virtual int memoryUsage() const;
+
+ virtual void setMinTextureUsage(int textureUsage) = 0;
+ virtual void setExtraTextureUsage(int textureUsage) = 0;
+ virtual int maxTextureUsage() const = 0;
+ virtual int minTextureUsage() const = 0;
+ virtual int textureUsage() const = 0;
+
+ virtual QSharedPointer<QGeoTileTexture> get(const QGeoTileSpec &spec) = 0;
+
+ virtual void insert(const QGeoTileSpec &spec,
+ const QByteArray &bytes,
+ const QString &format,
+ QGeoTiledMappingManagerEngine::CacheAreas areas = QGeoTiledMappingManagerEngine::AllCaches) = 0;
+ virtual void handleError(const QGeoTileSpec &spec, const QString &errorString);
+
+ static QString baseCacheDirectory();
+
+protected:
+ QAbstractGeoTileCache(QObject *parent = 0);
+
+ virtual void printStats() = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif // QABSTRACTGEOTILECACHE_P_H
diff --git a/src/location/maps/qgeotilecache.cpp b/src/location/maps/qgeofiletilecache.cpp
index 01cfcba4..6202f7fb 100644
--- a/src/location/maps/qgeotilecache.cpp
+++ b/src/location/maps/qgeofiletilecache.cpp
@@ -33,7 +33,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "qgeotilecache_p.h"
+#include "qgeofiletilecache_p.h"
#include "qgeotilespec_p.h"
@@ -60,14 +60,11 @@ public:
}
QGeoTileSpec spec;
- QGeoTileCache *cache;
+ QGeoFileTileCache *cache;
QByteArray bytes;
QString format;
};
-QGeoTileTexture::QGeoTileTexture()
- : textureBound(false) {}
-
void QCache3QTileEvictionPolicy::aboutToBeRemoved(const QGeoTileSpec &key, QSharedPointer<QGeoCachedTileDisk> obj)
{
Q_UNUSED(key);
@@ -88,18 +85,10 @@ QGeoCachedTileDisk::~QGeoCachedTileDisk()
cache->evictFromDiskCache(this);
}
-QGeoTileTexture::~QGeoTileTexture()
-{
-}
-
-QGeoTileCache::QGeoTileCache(const QString &directory, QObject *parent)
- : QObject(parent), directory_(directory),
+QGeoFileTileCache::QGeoFileTileCache(const QString &directory, QObject *parent)
+ : QAbstractGeoTileCache(parent), directory_(directory),
minTextureUsage_(0), extraTextureUsage_(0)
{
- qRegisterMetaType<QGeoTileSpec>();
- qRegisterMetaType<QList<QGeoTileSpec> >();
- qRegisterMetaType<QSet<QGeoTileSpec> >();
-
const QString basePath = baseCacheDirectory();
// delete old tiles from QtLocation 5.4 or prior
@@ -114,7 +103,7 @@ QGeoTileCache::QGeoTileCache(const QString &directory, QObject *parent)
if (directory_.isEmpty()) {
directory_ = basePath;
- qWarning() << "Plugin uses uninitialized QGeoTileCache directory which was deleted during startup";
+ qWarning() << "Plugin uses uninitialized QGeoFileTileCache directory which was deleted during startup";
}
QDir::root().mkpath(directory_);
@@ -127,7 +116,7 @@ QGeoTileCache::QGeoTileCache(const QString &directory, QObject *parent)
loadTiles();
}
-void QGeoTileCache::loadTiles()
+void QGeoFileTileCache::loadTiles()
{
QStringList formats;
formats << QLatin1String("*.*");
@@ -181,7 +170,7 @@ void QGeoTileCache::loadTiles()
}
}
-QGeoTileCache::~QGeoTileCache()
+QGeoFileTileCache::~QGeoFileTileCache()
{
// write disk cache queues to disk
QDir dir(directory_);
@@ -207,72 +196,72 @@ QGeoTileCache::~QGeoTileCache()
}
}
-void QGeoTileCache::printStats()
+void QGeoFileTileCache::printStats()
{
textureCache_.printStats();
memoryCache_.printStats();
diskCache_.printStats();
}
-void QGeoTileCache::setMaxDiskUsage(int diskUsage)
+void QGeoFileTileCache::setMaxDiskUsage(int diskUsage)
{
diskCache_.setMaxCost(diskUsage);
}
-int QGeoTileCache::maxDiskUsage() const
+int QGeoFileTileCache::maxDiskUsage() const
{
return diskCache_.maxCost();
}
-int QGeoTileCache::diskUsage() const
+int QGeoFileTileCache::diskUsage() const
{
return diskCache_.totalCost();
}
-void QGeoTileCache::setMaxMemoryUsage(int memoryUsage)
+void QGeoFileTileCache::setMaxMemoryUsage(int memoryUsage)
{
memoryCache_.setMaxCost(memoryUsage);
}
-int QGeoTileCache::maxMemoryUsage() const
+int QGeoFileTileCache::maxMemoryUsage() const
{
return memoryCache_.maxCost();
}
-int QGeoTileCache::memoryUsage() const
+int QGeoFileTileCache::memoryUsage() const
{
return memoryCache_.totalCost();
}
-void QGeoTileCache::setExtraTextureUsage(int textureUsage)
+void QGeoFileTileCache::setExtraTextureUsage(int textureUsage)
{
extraTextureUsage_ = textureUsage;
textureCache_.setMaxCost(minTextureUsage_ + extraTextureUsage_);
}
-void QGeoTileCache::setMinTextureUsage(int textureUsage)
+void QGeoFileTileCache::setMinTextureUsage(int textureUsage)
{
minTextureUsage_ = textureUsage;
textureCache_.setMaxCost(minTextureUsage_ + extraTextureUsage_);
}
-int QGeoTileCache::maxTextureUsage() const
+int QGeoFileTileCache::maxTextureUsage() const
{
return textureCache_.maxCost();
}
-int QGeoTileCache::minTextureUsage() const
+int QGeoFileTileCache::minTextureUsage() const
{
return minTextureUsage_;
}
-int QGeoTileCache::textureUsage() const
+int QGeoFileTileCache::textureUsage() const
{
return textureCache_.totalCost();
}
-QSharedPointer<QGeoTileTexture> QGeoTileCache::get(const QGeoTileSpec &spec)
+QSharedPointer<QGeoTileTexture> QGeoFileTileCache::get(const QGeoTileSpec &spec)
{
QSharedPointer<QGeoTileTexture> tt = textureCache_.object(spec);
if (tt)
@@ -280,12 +269,12 @@ QSharedPointer<QGeoTileTexture> QGeoTileCache::get(const QGeoTileSpec &spec)
QSharedPointer<QGeoCachedTileMemory> tm = memoryCache_.object(spec);
if (tm) {
- QPixmap pixmap;
- if (!pixmap.loadFromData(tm->bytes)) {
+ QImage image;
+ if (!image.loadFromData(tm->bytes)) {
handleError(spec, QLatin1String("Problem with tile image"));
return QSharedPointer<QGeoTileTexture>(0);
}
- QSharedPointer<QGeoTileTexture> tt = addToTextureCache(spec, pixmap);
+ QSharedPointer<QGeoTileTexture> tt = addToTextureCache(spec, image);
if (tt)
return tt;
}
@@ -298,14 +287,14 @@ QSharedPointer<QGeoTileTexture> QGeoTileCache::get(const QGeoTileSpec &spec)
QByteArray bytes = file.readAll();
file.close();
- QPixmap pixmap;
- if (!pixmap.loadFromData(bytes)) {
+ QImage image;
+ if (!image.loadFromData(bytes)) {
handleError(spec, QLatin1String("Problem with tile image"));
return QSharedPointer<QGeoTileTexture>(0);
}
addToMemoryCache(spec, bytes, format);
- QSharedPointer<QGeoTileTexture> tt = addToTextureCache(td->spec, pixmap);
+ QSharedPointer<QGeoTileTexture> tt = addToTextureCache(td->spec, image);
if (tt)
return tt;
}
@@ -313,16 +302,14 @@ QSharedPointer<QGeoTileTexture> QGeoTileCache::get(const QGeoTileSpec &spec)
return QSharedPointer<QGeoTileTexture>();
}
-QString QGeoTileCache::directory() const
-{
- return directory_;
-}
-
-void QGeoTileCache::insert(const QGeoTileSpec &spec,
+void QGeoFileTileCache::insert(const QGeoTileSpec &spec,
const QByteArray &bytes,
const QString &format,
QGeoTiledMappingManagerEngine::CacheAreas areas)
{
+ if (bytes.isEmpty())
+ return;
+
if (areas & QGeoTiledMappingManagerEngine::DiskCache) {
QString filename = tileSpecToFilename(spec, format, directory_);
QFile file(filename);
@@ -342,16 +329,16 @@ void QGeoTileCache::insert(const QGeoTileSpec &spec,
* and act as a poison */
}
-void QGeoTileCache::evictFromDiskCache(QGeoCachedTileDisk *td)
+void QGeoFileTileCache::evictFromDiskCache(QGeoCachedTileDisk *td)
{
QFile::remove(td->filename);
}
-void QGeoTileCache::evictFromMemoryCache(QGeoCachedTileMemory * /* tm */)
+void QGeoFileTileCache::evictFromMemoryCache(QGeoCachedTileMemory * /* tm */)
{
}
-QSharedPointer<QGeoCachedTileDisk> QGeoTileCache::addToDiskCache(const QGeoTileSpec &spec, const QString &filename)
+QSharedPointer<QGeoCachedTileDisk> QGeoFileTileCache::addToDiskCache(const QGeoTileSpec &spec, const QString &filename)
{
QSharedPointer<QGeoCachedTileDisk> td(new QGeoCachedTileDisk);
td->spec = spec;
@@ -364,7 +351,7 @@ QSharedPointer<QGeoCachedTileDisk> QGeoTileCache::addToDiskCache(const QGeoTileS
return td;
}
-QSharedPointer<QGeoCachedTileMemory> QGeoTileCache::addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format)
+QSharedPointer<QGeoCachedTileMemory> QGeoFileTileCache::addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format)
{
QSharedPointer<QGeoCachedTileMemory> tm(new QGeoCachedTileMemory);
tm->spec = spec;
@@ -378,24 +365,19 @@ QSharedPointer<QGeoCachedTileMemory> QGeoTileCache::addToMemoryCache(const QGeoT
return tm;
}
-QSharedPointer<QGeoTileTexture> QGeoTileCache::addToTextureCache(const QGeoTileSpec &spec, const QPixmap &pixmap)
+QSharedPointer<QGeoTileTexture> QGeoFileTileCache::addToTextureCache(const QGeoTileSpec &spec, const QImage &image)
{
QSharedPointer<QGeoTileTexture> tt(new QGeoTileTexture);
tt->spec = spec;
- tt->image = pixmap.toImage();
+ tt->image = image;
- int textureCost = tt->image.width() * tt->image.height() * tt->image.depth() / 8;
+ int textureCost = image.width() * image.height() * image.depth() / 8;
textureCache_.insert(spec, tt, textureCost);
return tt;
}
-void QGeoTileCache::handleError(const QGeoTileSpec &, const QString &error)
-{
- qWarning() << "tile request error " << error;
-}
-
-QString QGeoTileCache::tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory)
+QString QGeoFileTileCache::tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory)
{
QString filename = spec.plugin();
filename += QLatin1String("-");
@@ -421,7 +403,7 @@ QString QGeoTileCache::tileSpecToFilename(const QGeoTileSpec &spec, const QStrin
return dir.filePath(filename);
}
-QGeoTileSpec QGeoTileCache::filenameToTileSpec(const QString &filename)
+QGeoTileSpec QGeoFileTileCache::filenameToTileSpec(const QString &filename)
{
QGeoTileSpec emptySpec;
@@ -460,40 +442,9 @@ QGeoTileSpec QGeoTileCache::filenameToTileSpec(const QString &filename)
numbers.at(4));
}
-QString QGeoTileCache::baseCacheDirectory()
+QString QGeoFileTileCache::directory() const
{
- QString dir;
-
- // Try the shared cache first and use a specific directory. (e.g. ~/.cache/QtLocation)
- // If this is not supported by the platform, use the application-specific cache
- // location. (e.g. ~/.cache/<app_name>/QtLocation)
- dir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
-
- if (!dir.isEmpty()) {
- // The shared cache may not be writable when application isolation is enforced.
- static bool writable = false;
- static bool writableChecked = false;
- if (!writableChecked) {
- writableChecked = true;
- QDir::root().mkpath(dir);
- QFile writeTestFile(QDir(dir).filePath(QStringLiteral("qt_cache_check")));
- writable = writeTestFile.open(QIODevice::WriteOnly);
- if (writable)
- writeTestFile.remove();
- }
- if (!writable)
- dir = QString();
- }
-
- if (dir.isEmpty())
- dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
-
- if (!dir.endsWith(QLatin1Char('/')))
- dir += QLatin1Char('/');
-
- dir += QLatin1String("QtLocation/");
-
- return dir;
+ return directory_;
}
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeotilecache_p.h b/src/location/maps/qgeofiletilecache_p.h
index d9f7bce9..8afb4c8d 100644
--- a/src/location/maps/qgeotilecache_p.h
+++ b/src/location/maps/qgeofiletilecache_p.h
@@ -33,8 +33,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef QGEOTILECACHE_P_H
-#define QGEOTILECACHE_P_H
+#ifndef QGEOFILETILECACHE_P_H
+#define QGEOFILETILECACHE_P_H
//
// W A R N I N G
@@ -58,6 +58,7 @@
#include "qgeotilespec_p.h"
#include "qgeotiledmappingmanagerengine_p.h"
+#include "qabstractgeotilecache_p.h"
#include <QImage>
@@ -67,12 +68,12 @@ class QGeoMappingManager;
class QGeoTile;
class QGeoCachedTileMemory;
-class QGeoTileCache;
+class QGeoFileTileCache;
class QPixmap;
class QThread;
-/* This would be internal to qgeotilecache.cpp except that the eviction
+/* This would be internal to qgeofiletilecache.cpp except that the eviction
* policy can't be defined without it being concrete here */
class QGeoCachedTileDisk
{
@@ -82,20 +83,7 @@ public:
QGeoTileSpec spec;
QString filename;
QString format;
- QGeoTileCache *cache;
-};
-
-/* This is also used in the mapgeometry */
-class Q_LOCATION_EXPORT QGeoTileTexture
-{
-public:
-
- QGeoTileTexture();
- ~QGeoTileTexture();
-
- QGeoTileSpec spec;
- QImage image;
- bool textureBound;
+ QGeoFileTileCache *cache;
};
/* Custom eviction policy for the disk cache, to avoid deleting all the files
@@ -107,29 +95,28 @@ protected:
void aboutToBeEvicted(const QGeoTileSpec &key, QSharedPointer<QGeoCachedTileDisk> obj);
};
-class Q_LOCATION_EXPORT QGeoTileCache : public QObject
+class Q_LOCATION_EXPORT QGeoFileTileCache : public QAbstractGeoTileCache
{
Q_OBJECT
public:
- QGeoTileCache(const QString &directory = QString(), QObject *parent = 0);
- ~QGeoTileCache();
+ QGeoFileTileCache(const QString &directory = QString(), QObject *parent = 0);
+ ~QGeoFileTileCache();
- void setMaxDiskUsage(int diskUsage);
- int maxDiskUsage() const;
- int diskUsage() const;
+ void setMaxDiskUsage(int diskUsage) Q_DECL_OVERRIDE;
+ int maxDiskUsage() const Q_DECL_OVERRIDE;
+ int diskUsage() const Q_DECL_OVERRIDE;
- void setMaxMemoryUsage(int memoryUsage);
- int maxMemoryUsage() const;
- int memoryUsage() const;
+ void setMaxMemoryUsage(int memoryUsage) Q_DECL_OVERRIDE;
+ int maxMemoryUsage() const Q_DECL_OVERRIDE;
+ int memoryUsage() const Q_DECL_OVERRIDE;
- void setMinTextureUsage(int textureUsage);
- void setExtraTextureUsage(int textureUsage);
- int maxTextureUsage() const;
- int minTextureUsage() const;
- int textureUsage() const;
+ void setMinTextureUsage(int textureUsage) Q_DECL_OVERRIDE;
+ void setExtraTextureUsage(int textureUsage) Q_DECL_OVERRIDE;
+ int maxTextureUsage() const Q_DECL_OVERRIDE;
+ int minTextureUsage() const Q_DECL_OVERRIDE;
+ int textureUsage() const Q_DECL_OVERRIDE;
- QSharedPointer<QGeoTileTexture> get(const QGeoTileSpec &spec);
- QString directory() const;
+ QSharedPointer<QGeoTileTexture> get(const QGeoTileSpec &spec) Q_DECL_OVERRIDE;
// can be called without a specific tileCache pointer
static void evictFromDiskCache(QGeoCachedTileDisk *td);
@@ -138,33 +125,31 @@ public:
void insert(const QGeoTileSpec &spec,
const QByteArray &bytes,
const QString &format,
- QGeoTiledMappingManagerEngine::CacheAreas areas = QGeoTiledMappingManagerEngine::AllCaches);
- void handleError(const QGeoTileSpec &spec, const QString &errorString);
-
- static QString baseCacheDirectory();
-
-public Q_SLOTS:
- void printStats();
+ QGeoTiledMappingManagerEngine::CacheAreas areas = QGeoTiledMappingManagerEngine::AllCaches) Q_DECL_OVERRIDE;
private:
+ void printStats() Q_DECL_OVERRIDE;
void loadTiles();
+ QString directory() const;
+
QSharedPointer<QGeoCachedTileDisk> addToDiskCache(const QGeoTileSpec &spec, const QString &filename);
QSharedPointer<QGeoCachedTileMemory> addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format);
- QSharedPointer<QGeoTileTexture> addToTextureCache(const QGeoTileSpec &spec, const QPixmap &pixmap);
+ QSharedPointer<QGeoTileTexture> addToTextureCache(const QGeoTileSpec &spec, const QImage &image);
static QString tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory);
static QGeoTileSpec filenameToTileSpec(const QString &filename);
- QString directory_;
QCache3Q<QGeoTileSpec, QGeoCachedTileDisk, QCache3QTileEvictionPolicy > diskCache_;
QCache3Q<QGeoTileSpec, QGeoCachedTileMemory > memoryCache_;
QCache3Q<QGeoTileSpec, QGeoTileTexture > textureCache_;
+ QString directory_;
+
int minTextureUsage_;
int extraTextureUsage_;
};
QT_END_NAMESPACE
-#endif // QGEOTILECACHE_P_H
+#endif // QGEOFILETILECACHE_P_H
diff --git a/src/location/maps/qgeomapscene.cpp b/src/location/maps/qgeomapscene.cpp
index a25405ec..4a457005 100644
--- a/src/location/maps/qgeomapscene.cpp
+++ b/src/location/maps/qgeomapscene.cpp
@@ -36,7 +36,7 @@
****************************************************************************/
#include "qgeomapscene_p.h"
#include "qgeocameradata_p.h"
-#include "qgeotilecache_p.h"
+#include "qabstractgeotilecache_p.h"
#include "qgeotilespec_p.h"
#include <QtPositioning/private/qdoublevector3d_p.h>
#include <QtCore/private/qobject_p.h>
diff --git a/src/location/maps/qgeotiledmap.cpp b/src/location/maps/qgeotiledmap.cpp
index 06f5a5e8..d561c011 100644
--- a/src/location/maps/qgeotiledmap.cpp
+++ b/src/location/maps/qgeotiledmap.cpp
@@ -37,7 +37,7 @@
#include "qgeotiledmap_p_p.h"
#include "qgeotiledmappingmanagerengine_p.h"
-#include "qgeotilecache_p.h"
+#include "qabstractgeotilecache_p.h"
#include "qgeotilespec_p.h"
#include "qgeocameratiles_p.h"
@@ -85,7 +85,7 @@ void QGeoTiledMap::updateTile(const QGeoTileSpec &spec)
d->updateTile(spec);
}
-QGeoTileCache *QGeoTiledMap::tileCache()
+QAbstractGeoTileCache *QGeoTiledMap::tileCache()
{
Q_D(QGeoTiledMap);
return d->m_cache;
diff --git a/src/location/maps/qgeotiledmap_p.h b/src/location/maps/qgeotiledmap_p.h
index 2afbc5c9..111056d2 100644
--- a/src/location/maps/qgeotiledmap_p.h
+++ b/src/location/maps/qgeotiledmap_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
class QGeoTileSpec;
class QGeoTileTexture;
-class QGeoTileCache;
+class QAbstractGeoTileCache;
class QGeoTiledMapPrivate;
class QGeoTiledMappingManagerEngine;
class QGeoTileRequestManager;
@@ -79,7 +79,7 @@ public:
QGeoTiledMap(QGeoTiledMappingManagerEngine *engine, QObject *parent);
virtual ~QGeoTiledMap();
- QGeoTileCache *tileCache();
+ QAbstractGeoTileCache *tileCache();
QGeoTileRequestManager *requestManager();
void updateTile(const QGeoTileSpec &spec);
diff --git a/src/location/maps/qgeotiledmap_p_p.h b/src/location/maps/qgeotiledmap_p_p.h
index 95a61a2b..2e93a006 100644
--- a/src/location/maps/qgeotiledmap_p_p.h
+++ b/src/location/maps/qgeotiledmap_p_p.h
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
class QGeoCameraTiles;
class QGeoMapScene;
-class QGeoTileCache;
+class QAbstractGeoTileCache;
class QGeoTiledMappingManagerEngine;
class QGeoTiledMap;
class QGeoTileRequestManager;
@@ -92,7 +92,7 @@ private:
void updateScene();
private:
- QGeoTileCache *m_cache;
+ QAbstractGeoTileCache *m_cache;
QGeoCameraTiles *m_cameraTiles;
QGeoMapScene *m_mapScene;
QGeoTileRequestManager *m_tileRequests;
diff --git a/src/location/maps/qgeotiledmappingmanagerengine.cpp b/src/location/maps/qgeotiledmappingmanagerengine.cpp
index 43f56872..4e777ab2 100644
--- a/src/location/maps/qgeotiledmappingmanagerengine.cpp
+++ b/src/location/maps/qgeotiledmappingmanagerengine.cpp
@@ -41,7 +41,7 @@
#include "qgeotiledmap_p.h"
#include "qgeotilerequestmanager_p.h"
-#include "qgeotilecache_p.h"
+#include "qgeofiletilecache_p.h"
#include "qgeotilespec_p.h"
#include <QTimer>
@@ -275,22 +275,21 @@ void QGeoTiledMappingManagerEngine::setCacheHint(QGeoTiledMappingManagerEngine::
d->cacheHint_ = cacheHint;
}
-QGeoTileCache *QGeoTiledMappingManagerEngine::createTileCacheWithDir(const QString &cacheDirectory)
+void QGeoTiledMappingManagerEngine::setTileCache(QAbstractGeoTileCache *cache)
{
Q_D(QGeoTiledMappingManagerEngine);
Q_ASSERT_X(!d->tileCache_, Q_FUNC_INFO, "This should be called only once");
- d->tileCache_ = new QGeoTileCache(cacheDirectory);
- return d->tileCache_;
+ d->tileCache_ = cache;
}
-QGeoTileCache *QGeoTiledMappingManagerEngine::tileCache()
+QAbstractGeoTileCache *QGeoTiledMappingManagerEngine::tileCache()
{
Q_D(QGeoTiledMappingManagerEngine);
if (!d->tileCache_) {
QString cacheDirectory;
if (!managerName().isEmpty())
- cacheDirectory = QGeoTileCache::baseCacheDirectory() + managerName();
- d->tileCache_ = new QGeoTileCache(cacheDirectory);
+ cacheDirectory = QAbstractGeoTileCache::baseCacheDirectory() + managerName();
+ d->tileCache_ = new QGeoFileTileCache(cacheDirectory);
}
return d->tileCache_;
}
diff --git a/src/location/maps/qgeotiledmappingmanagerengine_p.h b/src/location/maps/qgeotiledmappingmanagerengine_p.h
index 12b43c40..86c5b63c 100644
--- a/src/location/maps/qgeotiledmappingmanagerengine_p.h
+++ b/src/location/maps/qgeotiledmappingmanagerengine_p.h
@@ -64,7 +64,7 @@ class QGeoTileTexture;
class QGeoTileSpec;
class QGeoTiledMap;
-class QGeoTileCache;
+class QAbstractGeoTileCache;
class Q_LOCATION_EXPORT QGeoTiledMappingManagerEngine : public QGeoMappingManagerEngine
{
@@ -93,7 +93,7 @@ public:
const QSet<QGeoTileSpec> &tilesAdded,
const QSet<QGeoTileSpec> &tilesRemoved);
- QGeoTileCache *tileCache(); // TODO: check this is still used
+ QAbstractGeoTileCache *tileCache();
QSharedPointer<QGeoTileTexture> getTileTexture(const QGeoTileSpec &spec);
@@ -112,8 +112,7 @@ protected:
void setTileSize(const QSize &tileSize);
void setTileVersion(int version);
void setCacheHint(QGeoTiledMappingManagerEngine::CacheAreas cacheHint);
-
- QGeoTileCache *createTileCacheWithDir(const QString &cacheDirectory);
+ void setTileCache(QAbstractGeoTileCache *cache);
private:
QGeoTiledMappingManagerEnginePrivate *d_ptr;
diff --git a/src/location/maps/qgeotiledmappingmanagerengine_p_p.h b/src/location/maps/qgeotiledmappingmanagerengine_p_p.h
index 7fb08e75..86ad0f08 100644
--- a/src/location/maps/qgeotiledmappingmanagerengine_p_p.h
+++ b/src/location/maps/qgeotiledmappingmanagerengine_p_p.h
@@ -57,7 +57,7 @@
QT_BEGIN_NAMESPACE
class QGeoTiledMap;
-class QGeoTileCache;
+class QAbstractGeoTileCache;
class QGeoTileSpec;
class QGeoTileFetcher;
@@ -72,7 +72,7 @@ public:
QHash<QGeoTiledMap *, QSet<QGeoTileSpec> > mapHash_;
QHash<QGeoTileSpec, QSet<QGeoTiledMap *> > tileHash_;
QGeoTiledMappingManagerEngine::CacheAreas cacheHint_;
- QGeoTileCache *tileCache_;
+ QAbstractGeoTileCache *tileCache_;
QGeoTileFetcher *fetcher_;
private:
diff --git a/src/location/maps/qgeotilefetcher_p_p.h b/src/location/maps/qgeotilefetcher_p_p.h
index ce2a5481..acd7288e 100644
--- a/src/location/maps/qgeotilefetcher_p_p.h
+++ b/src/location/maps/qgeotilefetcher_p_p.h
@@ -62,7 +62,6 @@ QT_BEGIN_NAMESPACE
class QGeoTileSpec;
class QGeoTiledMapReply;
-class QGeoTileCache;
class QGeoTiledMappingManagerEngine;
class QGeoTileFetcherPrivate
diff --git a/src/location/maps/qgeotilerequestmanager.cpp b/src/location/maps/qgeotilerequestmanager.cpp
index 8857671d..1409856a 100644
--- a/src/location/maps/qgeotilerequestmanager.cpp
+++ b/src/location/maps/qgeotilerequestmanager.cpp
@@ -37,7 +37,7 @@
#include "qgeotilespec_p.h"
#include "qgeotiledmap_p.h"
#include "qgeotiledmappingmanagerengine_p.h"
-#include "qgeotilecache_p.h"
+#include "qabstractgeotilecache_p.h"
#include <QtCore/QPointer>
QT_BEGIN_NAMESPACE
diff --git a/src/location/maps/qgeotilerequestmanager_p.h b/src/location/maps/qgeotilerequestmanager_p.h
index 8ae7360a..66d2251e 100644
--- a/src/location/maps/qgeotilerequestmanager_p.h
+++ b/src/location/maps/qgeotilerequestmanager_p.h
@@ -54,7 +54,6 @@ QT_BEGIN_NAMESPACE
class QGeoTiledMap;
class QGeoTiledMappingManagerEngine;
class QGeoTileSpec;
-class QGeoTileCache;
class QGeoTileTexture;
class QGeoTileRequestManagerPrivate;
diff --git a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
index af6cbcf0..a33d1ba8 100644
--- a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
@@ -376,18 +376,15 @@ QString QGeoRoutingManagerEngineNokia::routeRequestString(const QGeoRouteRequest
{
QString requestString;
- const QList<QGeoRectangle> excludeAreas = request.excludeAreas();
- QList<QGeoRectangle>::const_iterator beg = excludeAreas.begin();
- QList<QGeoRectangle>::const_iterator end = excludeAreas.begin();
- for (QList<QGeoRectangle>::const_iterator it = beg; it != end; ++it) {
+ foreach (const QGeoRectangle &area, request.excludeAreas()) {
requestString += QLatin1String("&avoidareas=");
- requestString += trimDouble(it->topLeft().latitude());
+ requestString += trimDouble(area.topLeft().latitude());
requestString += QLatin1String(",");
- requestString += trimDouble(it->topLeft().longitude());
+ requestString += trimDouble(area.topLeft().longitude());
requestString += QLatin1String(";");
- requestString += trimDouble(it->bottomRight().latitude());
+ requestString += trimDouble(area.bottomRight().latitude());
requestString += QLatin1String(",");
- requestString += trimDouble(it->bottomRight().longitude());
+ requestString += trimDouble(area.bottomRight().longitude());
}
// TODO: work out what was going on here
diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
index 1b1163a6..0713ba10 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
@@ -39,7 +39,7 @@
#include "qgeotiledmap_nokia.h"
#include "qgeotilefetcher_nokia.h"
#include "qgeotilespec_p.h"
-#include "qgeotilecache_p.h"
+#include "qgeofiletilecache_p.h"
#include <QDebug>
#include <QDir>
@@ -101,15 +101,15 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
// TODO: do this in a plugin-neutral way so that other tiled map plugins
// don't need this boilerplate or hardcode plugin name
- QString cacheDir;
if (parameters.contains(QStringLiteral("here.mapping.cache.directory"))) {
- cacheDir = parameters.value(QStringLiteral("here.mapping.cache.directory")).toString();
+ m_cacheDirectory = parameters.value(QStringLiteral("here.mapping.cache.directory")).toString();
} else {
// managerName() is not yet set, we have to hardcode the plugin name below
- cacheDir = QGeoTileCache::baseCacheDirectory() + QLatin1String("here");
+ m_cacheDirectory = QAbstractGeoTileCache::baseCacheDirectory() + QLatin1String("here");
}
- QGeoTileCache *tileCache = createTileCacheWithDir(cacheDir);
+ QAbstractGeoTileCache *tileCache = new QGeoFileTileCache(m_cacheDirectory);
+ setTileCache(tileCache);
if (parameters.contains(QStringLiteral("here.mapping.cache.disk.size"))) {
bool ok = false;
@@ -263,7 +263,7 @@ void QGeoTiledMappingManagerEngineNokia::updateVersion(const QJsonObject &newVer
void QGeoTiledMappingManagerEngineNokia::saveMapVersion()
{
- QDir saveDir(tileCache()->directory());
+ QDir saveDir(m_cacheDirectory);
QFile saveFile(saveDir.filePath(QStringLiteral("here_version")));
if (!saveFile.open(QIODevice::WriteOnly)) {
@@ -277,8 +277,7 @@ void QGeoTiledMappingManagerEngineNokia::saveMapVersion()
void QGeoTiledMappingManagerEngineNokia::loadMapVersion()
{
-
- QDir saveDir(tileCache()->directory());
+ QDir saveDir(m_cacheDirectory);
QFile loadFile(saveDir.filePath(QStringLiteral("here_version")));
if (!loadFile.open(QIODevice::ReadOnly)) {
diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.h b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.h
index acaf61d7..16483120 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.h
@@ -101,6 +101,8 @@ private:
QHash<QString, QList<CopyrightDesc> > m_copyrights;
QHash<int, QString> m_mapSchemes;
QGeoMapVersion m_mapVersion;
+
+ QString m_cacheDirectory;
};
QT_END_NAMESPACE
diff --git a/src/plugins/position/simulator/simulator.pro b/src/plugins/position/simulator/simulator.pro
index f9e2bdb5..dc00ae1a 100644
--- a/src/plugins/position/simulator/simulator.pro
+++ b/src/plugins/position/simulator/simulator.pro
@@ -4,16 +4,15 @@ QT = core network positioning
PLUGIN_TYPE = position
PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactorySimulator
load(qt_plugin)
+INCLUDEPATH += ../../../positioning
QT += simulator
DEFINES += QT_SIMULATOR
SOURCES += qgeopositioninfosource_simulator.cpp \
- qlocationdata_simulator.cpp \
qgeosatelliteinfosource_simulator.cpp \
qlocationconnection_simulator.cpp \
qgeopositioninfosourcefactory_simulator.cpp
HEADERS += qgeopositioninfosource_simulator_p.h \
- qlocationdata_simulator_p.h \
qgeosatelliteinfosource_simulator_p.h \
qlocationconnection_simulator_p.h \
qgeopositioninfosourcefactory_simulator.h
diff --git a/src/positioning/doc/qtpositioning.qdocconf b/src/positioning/doc/qtpositioning.qdocconf
index 608b30a1..1645c092 100644
--- a/src/positioning/doc/qtpositioning.qdocconf
+++ b/src/positioning/doc/qtpositioning.qdocconf
@@ -40,7 +40,7 @@ headerdirs += .. \
sourcedirs += .. \
../../imports/positioning
-examplesinstallpath = positioning
+examplesinstallpath = qtlocation/positioning
exampledirs += ../../../examples/positioning \
snippets/
diff --git a/src/positioning/positioning.pro b/src/positioning/positioning.pro
index 2e751bfb..0dd91272 100644
--- a/src/positioning/positioning.pro
+++ b/src/positioning/positioning.pro
@@ -46,7 +46,9 @@ PRIVATE_HEADERS += \
qdeclarativegeolocation_p.h \
qdoublevector2d_p.h \
qdoublevector3d_p.h \
- qgeoprojection_p.h
+ qgeoprojection_p.h \
+ qpositioningglobal_p.h \
+ qlocationdata_simulator_p.h
SOURCES += \
qgeoaddress.cpp \
@@ -68,7 +70,8 @@ SOURCES += \
qdeclarativegeolocation.cpp \
qdoublevector2d.cpp \
qdoublevector3d.cpp \
- qgeoprojection.cpp
+ qgeoprojection.cpp \
+ qlocationdata_simulator.cpp
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
diff --git a/src/plugins/position/simulator/qlocationdata_simulator.cpp b/src/positioning/qlocationdata_simulator.cpp
index b1ab808c..b1ab808c 100644
--- a/src/plugins/position/simulator/qlocationdata_simulator.cpp
+++ b/src/positioning/qlocationdata_simulator.cpp
diff --git a/src/plugins/position/simulator/qlocationdata_simulator_p.h b/src/positioning/qlocationdata_simulator_p.h
index a847a80f..8848123d 100644
--- a/src/plugins/position/simulator/qlocationdata_simulator_p.h
+++ b/src/positioning/qlocationdata_simulator_p.h
@@ -45,13 +45,22 @@
// We mean it.
//
+//
+// DO NOT REMOVE
+// -------------
+//
+// This header file contains structures used to serialize communication between
+// simulator's client and server implementations, it is included by simulator
+// positioning plugin.
+
+#include "qpositioningglobal_p.h"
#include <QtCore/QMetaType>
#include <QtCore/QDateTime>
#include <QtCore/QList>
QT_BEGIN_NAMESPACE
-struct QGeoPositionInfoData
+struct Q_POSITIONING_PRIVATE_EXPORT QGeoPositionInfoData
{
QGeoPositionInfoData();
@@ -76,7 +85,7 @@ struct QGeoPositionInfoData
bool enabled;
};
-struct QGeoSatelliteInfoData
+struct Q_POSITIONING_PRIVATE_EXPORT QGeoSatelliteInfoData
{
struct SatelliteInfo
{
@@ -102,7 +111,13 @@ struct QGeoSatelliteInfoData
QList<SatelliteInfo> satellites;
};
-void qt_registerLocationTypes();
+Q_POSITIONING_PRIVATE_EXPORT void qt_registerLocationTypes();
+Q_POSITIONING_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &out, const QGeoPositionInfoData &s);
+Q_POSITIONING_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &in, QGeoPositionInfoData &s);
+Q_POSITIONING_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &out, const QGeoSatelliteInfoData &s);
+Q_POSITIONING_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &in, QGeoSatelliteInfoData &s);
+Q_POSITIONING_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &out, const QGeoSatelliteInfoData::SatelliteInfo &s);
+Q_POSITIONING_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &in, QGeoSatelliteInfoData::SatelliteInfo &s);
QT_END_NAMESPACE
diff --git a/src/positioning/qpositioningglobal_p.h b/src/positioning/qpositioningglobal_p.h
new file mode 100644
index 00000000..d3a10dae
--- /dev/null
+++ b/src/positioning/qpositioningglobal_p.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QPOSITIONINGGLOBAL_P_H
+#define QPOSITIONINGGLOBAL_P_H
+
+#include "qpositioningglobal.h"
+
+QT_BEGIN_NAMESPACE
+
+#define Q_POSITIONING_PRIVATE_EXPORT Q_POSITIONING_EXPORT
+
+QT_END_NAMESPACE
+
+#endif // QPOSITIONINGGLOBAL_P_H
+
diff --git a/tests/auto/declarative_core/tst_geocoding.qml b/tests/auto/declarative_core/tst_geocoding.qml
index 984fde65..657eb512 100644
--- a/tests/auto/declarative_core/tst_geocoding.qml
+++ b/tests/auto/declarative_core/tst_geocoding.qml
@@ -343,19 +343,16 @@ Item {
slackModel.query = slackAddress1
slackAddress1.county = "5"
slackModel.update()
- wait (100)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
compare (locationsSlackSpy.count, 0)
compare (slackModel.count, 0)
slackModel.reset()
- wait (200)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
compare (locationsSlackSpy.count, 0)
compare (slackModel.count, 0)
// Check that results are cleared
slackModel.update()
- wait (300)
- compare (slackModel.count, 5) // slackAddress1.county)
+ tryCompare(slackModel, "count", 5)
slackModel.reset()
compare (slackModel.count, 0)
// Check that changing plugin resets any ongoing requests
@@ -364,20 +361,16 @@ Item {
slackAddress1.county = "7"
compare (pluginSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
slackModel.plugin = errorPlugin
- wait (200)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
compare (pluginSlackSpy.count, 1)
// switch back and check that works
slackModel.plugin = slackPlugin
compare (pluginSlackSpy.count, 2)
slackModel.update()
- wait (100)
- compare (countSlackSpy.count, 0)
- wait (200)
- compare (countSlackSpy.count, 1)
+ tryCompare(countSlackSpy, "count", 0)
+ tryCompare(countSlackSpy, "count", 1)
}
function test_error_geocode() {
// basic immediate geocode error
@@ -516,8 +509,7 @@ Item {
slackModel.query = "freetext geocode"
compare (querySlackSpy.count, 1)
slackModel.update()
- wait (100)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
compare (locationsSlackSpy.count, 0)
compare (slackModel.count, 0)
tryCompare(countSlackSpy, "count", 1); //waits up to 5s
@@ -528,20 +520,16 @@ Item {
locationsSlackSpy.clear()
countSlackSpy.clear()
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
tryCompare(countSlackSpy, "count", 1); //waits up to 5s
compare (locationsSlackSpy.count, 1)
@@ -553,16 +541,13 @@ Item {
compare (automaticLocationsSpy.count, 1)
// change query and its contents and verify that autoupdate occurs
automaticAddress1.county = 6
- wait (300)
- compare (automaticLocationsSpy.count, 2)
+ tryCompare(automaticLocationsSpy, "count", 2)
compare (automaticModel.count, 6)
automaticAddress1.street = "The Avenue"
- wait (300)
- compare (automaticLocationsSpy.count, 3)
+ tryCompare(automaticLocationsSpy, "count", 3)
compare (automaticModel.count, 6)
automaticModel.query = automaticCoordinate1
- wait (300)
- compare (automaticLocationsSpy.count, 4)
+ tryCompare(automaticLocationsSpy, "count", 4)
compare (automaticModel.count, 3)
}
@@ -576,8 +561,7 @@ Item {
slackAddress1.county = "7"
compare (querySlackSpy.count, 1)
slackModel.update()
- wait (100)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
compare (locationsSlackSpy.count, 0)
compare (slackModel.count, 0)
tryCompare(countSlackSpy, "count", 1); //waits up to 5s
@@ -588,20 +572,16 @@ Item {
locationsSlackSpy.clear()
countSlackSpy.clear()
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
tryCompare(countSlackSpy, "count", 1); //waits up to 5s
compare (locationsSlackSpy.count, 1)
@@ -634,8 +614,7 @@ Item {
slackModel.query = slackCoordinate1
compare (querySlackSpy.count, 1)
slackModel.update()
- wait (100)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
compare (locationsSlackSpy.count, 0)
compare (slackModel.count, 0)
@@ -647,20 +626,16 @@ Item {
locationsSlackSpy.clear()
countSlackSpy.clear()
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
tryCompare(countSlackSpy, "count", 1); //waits up to 5s
diff --git a/tests/auto/declarative_ui/tst_map_coordinateanimation.qml b/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
index ec8042fd..7b0e46f8 100644
--- a/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
+++ b/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
@@ -55,7 +55,10 @@ Item {
Behavior on center {
id: centerBehavior
enabled: false
- CoordinateAnimation { duration: animationDuration }
+ CoordinateAnimation {
+ id: coordinateAnimation
+ duration: animationDuration
+ }
}
onCenterChanged: {
@@ -107,7 +110,8 @@ Item {
// Set to coordinate with animation enabled
centerBehavior.enabled = true
map.center = QtPositioning.coordinate(to.latitude, to.longitude)
- wait(animationDuration * 2)
+ wait(animationDuration)
+ tryCompare(coordinateAnimation,"running",false)
//check correct start position
compare(coordinateList[0].latitude, from.latitude)
diff --git a/tests/auto/declarative_ui/tst_map_error.qml b/tests/auto/declarative_ui/tst_map_error.qml
index 68752f11..c102db6e 100644
--- a/tests/auto/declarative_ui/tst_map_error.qml
+++ b/tests/auto/declarative_ui/tst_map_error.qml
@@ -100,7 +100,7 @@ Item {
mouseClick(map, 50, 50)
mouseClick(map, 50, 50)
mouseClick(map, 50, 50)
- compare(map.mouseClickedSpy.count, 3)
+ tryCompare(map.mouseClickedSpy, "count", 3)
}
function test_map_clicked_wiht_no_plugin()
@@ -193,14 +193,6 @@ Item {
map_no_plugin.fitViewportToMapItems()
}
- function test_map_fitViewportToGeoShape()
- {
- map_no_plugin.fitViewportToGeoShape(QtPositioning.circle(coordinate,1000))
- verify(map_no_plugin.center != coordinate)
- map_error_plugin.fitViewportToGeoShape(QtPositioning.circle(coordinate,1000))
- verify(map_error_plugin.center != coordinate)
- }
-
function test_map_setVisibleRegion()
{
map_no_plugin.visibleRegion = QtPositioning.circle(coordinate,1000)
diff --git a/tests/auto/declarative_ui/tst_map_flick.qml b/tests/auto/declarative_ui/tst_map_flick.qml
index 526cbb6f..e225480d 100644
--- a/tests/auto/declarative_ui/tst_map_flick.qml
+++ b/tests/auto/declarative_ui/tst_map_flick.qml
@@ -61,17 +61,24 @@ Item {
property real flickStartedLatitude
property real flickStartedLongitude
- property bool disableFlickOnStarted: false
- property bool disableFlickOnMovementStarted: false
+ property bool disableOnPanStartedWithNoGesture: false
+ property bool disableOnFlickStartedWithNoGesture: false
+ property bool disableOnPanStartedWithDisabled: false
+ property bool disableOnFlickStartedWithDisabled: false
+
gesture.onPanStarted: {
- if (disableFlickOnMovementStarted)
- map.gesture.panEnabled = false
+ if (disableOnPanStartedWithNoGesture)
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ if (disableOnPanStartedWithDisabled)
+ map.gesture.enabled = false
}
gesture.onFlickStarted: {
flickStartedLatitude = map.center.latitude
flickStartedLatitude = map.center.longitude
- if (disableFlickOnStarted)
- map.gesture.panEnabled = false
+ if (disableOnFlickStartedWithNoGesture)
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ if (disableOnFlickStartedWithDisabled)
+ map.gesture.enabled = false
}
MouseArea {
id: mouseAreaTop
@@ -81,6 +88,7 @@ Item {
}
SignalSpy {id: centerSpy; target: map; signalName: 'centerChanged'}
+ SignalSpy {id: panStartedSpy; target: map.gesture; signalName: 'panStarted'}
SignalSpy {id: panFinishedSpy; target: map.gesture; signalName: 'panFinished'}
SignalSpy {id: gestureEnabledSpy; target: map.gesture; signalName: 'enabledChanged'}
SignalSpy {id: flickDecelerationSpy; target: map.gesture; signalName: 'flickDecelerationChanged'}
@@ -95,16 +103,19 @@ Item {
function init()
{
- map.gesture.activeGestures = MapGestureArea.PanGesture | MapGestureArea.FlickGesture;
+ map.gesture.acceptedGestures = MapGestureArea.PanGesture | MapGestureArea.FlickGesture;
map.gesture.enabled = true
map.gesture.panEnabled = true
map.gesture.flickDeceleration = 500
map.zoomLevel = 0
- map.disableFlickOnStarted = false
- map.disableFlickOnMovementStarted = false
+ map.disableOnPanStartedWithNoGesture = false
+ map.disableOnFlickStartedWithNoGesture = false
+ map.disableOnPanStartedWithDisabled = false
+ map.disableOnFlickStartedWithDisabled = false
centerSpy.clear()
gestureEnabledSpy.clear()
flickDecelerationSpy.clear()
+ panStartedSpy.clear()
panFinishedSpy.clear()
flickStartedSpy.clear()
flickFinishedSpy.clear()
@@ -112,6 +123,8 @@ Item {
mouseAreaBottomSpy.clear()
mouseAreaBottom.visible = false
mouseAreaTop.visible = false
+ compare(map.gesture.pinchActive, false)
+ compare(map.gesture.panActive, false)
}
function initTestCase()
@@ -127,16 +140,17 @@ Item {
map.gesture.enabled = true
compare(gestureEnabledSpy.count, 2)
compare(map.gesture.enabled, true)
- compare(map.gesture.isPinchActive, false)
- verify(map.gesture.activeGestures & MapGestureArea.ZoomGesture)
- map.gesture.activeGestures = MapGestureArea.NoGesture
- compare(map.gesture.activeGestures, MapGestureArea.NoGesture)
- map.gesture.activeGestures = MapGestureArea.NoGesture
- compare(map.gesture.activeGestures, MapGestureArea.NoGesture)
- map.gesture.activeGestures = MapGestureArea.ZoomGesture | MapGestureArea.PanGesture
- compare(map.gesture.activeGestures, MapGestureArea.ZoomGesture | MapGestureArea.PanGesture)
- map.gesture.activeGestures = MapGestureArea.PanGesture
- compare(map.gesture.activeGestures, MapGestureArea.PanGesture)
+ compare(map.gesture.pinchActive, false)
+ compare(map.gesture.panActive, false)
+ verify(map.gesture.acceptedGestures & MapGestureArea.PinchGesture)
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ compare(map.gesture.acceptedGestures, MapGestureArea.NoGesture)
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ compare(map.gesture.acceptedGestures, MapGestureArea.NoGesture)
+ map.gesture.acceptedGestures = MapGestureArea.PinchGesture | MapGestureArea.PanGesture
+ compare(map.gesture.acceptedGestures, MapGestureArea.PinchGesture | MapGestureArea.PanGesture)
+ map.gesture.acceptedGestures = MapGestureArea.PanGesture
+ compare(map.gesture.acceptedGestures, MapGestureArea.PanGesture)
compare(map.gesture.flickDeceleration, 2500)
map.gesture.flickDeceleration = 2600
compare(flickDecelerationSpy.count, 1)
@@ -222,7 +236,6 @@ Item {
tryCompare(mouseAreaBottomSpy, "count",0)
}
-
function test_flick_diagonal()
{
map.center.latitude = 50
@@ -244,9 +257,8 @@ Item {
verify(map.center.longitude < moveLongitude)
}
- function test_flicking_while_disabled()
+ function disabled_flicking()
{
- map.gesture.panEnabled = false
map.center.latitude = 50
map.center.longitude = 50
mousePress(page, 0, 0)
@@ -255,16 +267,28 @@ Item {
mouseMove(page, i, i, 0, Qt.LeftButton);
}
mouseRelease(page, 50, 50)
+ compare(panStartedSpy.count, 0)
+ compare(panFinishedSpy.count, 0)
compare(flickStartedSpy.count, 0)
compare(flickFinishedSpy.count, 0)
- compare(panFinishedSpy.count, 0)
}
- function test_disable_onFlickStarted()
+ function test_disabled_flicking_with_nogesture()
+ {
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ }
+
+ function test_disabled_flicking_with_disabled()
+ {
+ map.gesture.enabled = false
+ disabled_flicking()
+ }
+
+ function disable_onFlickStarted()
{
- map.disableFlickOnStarted = true
map.center.latitude = 50
map.center.longitude = 50
+ waitForRendering(map)
mousePress(page, 0, 0)
for (var i = 0; i < 50; i += 5) {
wait(20)
@@ -273,21 +297,30 @@ Item {
mouseRelease(page, 50, 50)
var latitude = map.center.latitude;
var longitude = map.center.longitude
+ tryCompare(panStartedSpy, "count", 1)
tryCompare(flickStartedSpy, "count", 1)
verify(map.center.latitude > 50)
- tryCompare(flickStartedSpy, "count", 1)
tryCompare(panFinishedSpy, "count", 1)
tryCompare(flickFinishedSpy, "count", 1)
// compare that flick was interrupted (less movement than without interrupting)
compare(latitude, map.center.latitude)
compare(longitude, map.center.longitude)
- map.disableFlickOnStarted = false
- map.gesture.panEnabled = true
}
- function test_disable_onMovementStarted()
+ function test_disable_onFlickStarted_with_disabled()
+ {
+ map.disableOnFlickStartedWithDisabled = true
+ disable_onFlickStarted()
+ }
+
+ function test_disable_onFlickStarted_with_nogesture()
+ {
+ map.disableOnFlickStartedWithNoGesture = true
+ disable_onFlickStarted()
+ }
+
+ function disable_onPanStarted()
{
- map.disableFlickOnMovementStarted = true
map.center.latitude = 50
map.center.longitude = 50
mousePress(page, 0, 0)
@@ -302,6 +335,19 @@ Item {
// compare that flick was interrupted (less movement than without interrupting)
compare(map.center.latitude,50)
compare(map.center.longitude,50)
+ compare(map.gesture.panActive, false)
+ }
+
+ function test_disable_onPanStarted_with_disabled()
+ {
+ map.disableOnPanStartedWithDisabled = true
+ disable_onPanStarted()
+ }
+
+ function test_disable_onPanStarted_with_nogesture()
+ {
+ map.disableOnPanStartedWithNoGesture = true
+ disable_onPanStarted()
}
}
}
diff --git a/tests/auto/declarative_ui/tst_map_item.qml b/tests/auto/declarative_ui/tst_map_item.qml
index 32de8efd..5be8896f 100644
--- a/tests/auto/declarative_ui/tst_map_item.qml
+++ b/tests/auto/declarative_ui/tst_map_item.qml
@@ -257,37 +257,40 @@ Item {
map.center = preMapRect.topLeft
var point = map.fromCoordinate(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
- compare(preMapRectClicked.count, 1)
+ tryCompare(preMapRectClicked, "count", 1)
mouseClick(map, 1, 1) // no item hit
- compare(preMapRectClicked.count, 1)
+ tryCompare(preMapRectClicked, "count", 1)
compare(preMapCircleClicked.count, 0)
// click circle, overlaps and is above rect
map.center = preMapCircle.center
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
- compare(preMapRectClicked.count, 1)
+ tryCompare(preMapRectClicked, "count", 1)
compare(preMapCircleClicked.count, 1)
// click within circle bounding rect but not inside the circle geometry
map.center = preMapCircle.center.atDistanceAndAzimuth(preMapCircle.radius, -45)
mouseClick(map, preMapCircle.x + 4, preMapCircle.y + 4)
- compare(preMapRectClicked.count, 2)
+ tryCompare(preMapRectClicked, "count", 2)
compare(preMapCircleClicked.count, 1)
// click quick item
compare(preMapQuickItemClicked.count, 0)
map.center = preMapQuickItem.coordinate
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
- compare(preMapQuickItemClicked.count, 1)
+ tryCompare(preMapQuickItemClicked, "count", 1)
// click polygon
compare (preMapPolygonClicked.count, 0)
map.center = preMapPolygon.path[1]
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapPolygon.path[1])
mouseClick(map, point.x - 5, point.y)
- compare(preMapPolygonClicked.count, 1)
+ tryCompare(preMapPolygonClicked, "count", 1)
// remove items and repeat clicks to verify they are gone
map.clearMapItems()
@@ -328,48 +331,54 @@ Item {
compare (map.mapItems.length, 6)
visualInspectionPoint()
map.center = preMapRect.topLeft
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
- compare(preMapRectClicked.count, 1)
+ tryCompare(preMapRectClicked, "count", 1)
map.center = preMapCircle.center
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
- compare(preMapRectClicked.count, 1)
+ tryCompare(preMapRectClicked, "count", 1)
compare(preMapCircleClicked.count, 1)
map.center = preMapCircle.center.atDistanceAndAzimuth(preMapCircle.radius, -45)
mouseClick(map, preMapCircle.x + 4, preMapCircle.y + 4)
- compare(preMapRectClicked.count, 2)
+ tryCompare(preMapRectClicked, "count", 2)
compare(preMapCircleClicked.count, 1)
compare(preMapQuickItemClicked.count, 0)
map.center = preMapQuickItem.coordinate
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
- compare(preMapQuickItemClicked.count, 1)
+ tryCompare(preMapQuickItemClicked, "count", 1)
map.center = preMapPolygon.path[1]
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapPolygon.path[1])
mouseClick(map, point.x - 5, point.y)
- compare(preMapPolygonClicked.count, 1)
+ tryCompare(preMapPolygonClicked, "count", 1)
// item clips to map. not sure if this is sensible test
map.addMapItem(extMapCircle)
map.center = extMapCircle.center
+ verify(waitForRendering(map))
visualInspectionPoint();
point = map.fromCoordinate(extMapCircle.center)
mouseClick(map, point.x, point.y)
- compare(extMapCircleClicked.count, 1)
+ tryCompare(extMapCircleClicked, "count", 1)
mouseClick(map, point.x, -5)
- compare(extMapCircleClicked.count, 1)
+ tryCompare(extMapCircleClicked, "count", 1)
map.removeMapItem(extMapCircle)
map.addMapItem(extMapQuickItem)
map.center = extMapQuickItem.coordinate
+ verify(waitForRendering(map))
visualInspectionPoint();
point = map.fromCoordinate(extMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
- compare(extMapQuickItemClicked.count, 1)
+ tryCompare(extMapQuickItemClicked, "count", 1)
mouseClick(map, map.width + 5, point.y + 5)
- compare(extMapQuickItemClicked.count, 1)
+ tryCompare(extMapQuickItemClicked, "count", 1)
map.removeMapItem(extMapQuickItem)
}
@@ -378,6 +387,8 @@ Item {
// basic drags, drag rectangle
compare (preMapRectActiveChanged.count, 0)
map.center = preMapRect.topLeft
+ verify(waitForRendering(map))
+
var i
var point = map.fromCoordinate(preMapRect.topLeft)
var targetCoordinate = map.toCoordinate(51, 51)
@@ -400,6 +411,7 @@ Item {
// drag circle
compare (preMapCircleActiveChanged.count, 0)
map.center = preMapCircle.center
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapCircle.center)
targetCoordinate = map.toCoordinate(51, 51)
mousePress(map, point.x, point.y)
@@ -418,6 +430,7 @@ Item {
// drag quick item
compare (preMapQuickItemActiveChanged.count, 0)
map.center = preMapQuickItem.coordinate
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapQuickItem.coordinate)
targetCoordinate = map.toCoordinate(51, 51)
mousePress(map, point.x + 5, point.y + 5)
diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml
index b4468301..20849079 100644
--- a/tests/auto/declarative_ui/tst_map_item_details.qml
+++ b/tests/auto/declarative_ui/tst_map_item_details.qml
@@ -41,7 +41,11 @@ Item {
x: 0; y: 0;
width: 240
height: 240
- Plugin { id: testPlugin; name : "qmlgeo.test.plugin"; allowExperimental: true }
+ Plugin { id: testPlugin
+ name : "qmlgeo.test.plugin"
+ allowExperimental: true
+ parameters: [ PluginParameter { name: "finishRequestImmediately"; value: true}]
+ }
property variant mapDefaultCenter: QtPositioning.coordinate(20, 20)
@@ -327,8 +331,9 @@ Item {
verify(extMapPolygon0.path.length == 0)
extMapPolygon.addCoordinate(polyCoordinate)
verify(extMapPolygon.path.length == 3)
+ verify(waitForRendering(map))
mouseClick(map, point.x - 5, point.y)
- compare(extMapPolygonClicked.count, 1)
+ tryCompare(extMapPolygonClicked, "count", 1)
extMapPolygon.path[0].latitude = 10
verify(extMapPolygon.path[0].latitude, 10)
@@ -427,6 +432,7 @@ Item {
verify(point.x > map.width / 2.0)
// move item edge onto dateline
extMapRectDateline.topLeft.longitude = datelineCoordinate.longitude
+ verify(waitForRendering(map))
point = map.fromCoordinate(extMapRectDateline.topLeft)
verify(point.x == map.width / 2.0)
// drag item back onto dateline
@@ -450,6 +456,7 @@ Item {
point = map.fromCoordinate(extMapCircleDateline.center)
verify(point.x == map.width / 2.0)
extMapCircleDateline.center.longitude = datelineCoordinateRight.longitude
+ verify(waitForRendering(map))
point = map.fromCoordinate(extMapCircleDateline.center)
verify(point.x > map.width / 2.0)
mousePress(map, point.x, point.y)
@@ -469,6 +476,7 @@ Item {
point = map.fromCoordinate(extMapQuickItemDateline.coordinate)
verify(point.x < map.width / 2.0)
extMapQuickItemDateline.coordinate.longitude = datelineCoordinateRight.longitude
+ verify(waitForRendering(map))
point = map.fromCoordinate(extMapQuickItemDateline.coordinate)
verify(point.x > map.width / 2.0)
mousePress(map, point.x + 5, point.y + 5)
@@ -510,6 +518,7 @@ Item {
path = extMapPolygonDateline.path;
path[3].longitude = datelineCoordinate.longitude;
extMapPolygonDateline.path = path;
+ verify(waitForRendering(map))
point = map.fromCoordinate(extMapPolygonDateline.path[3])
verify(point.x == map.width / 2.0)
mousePress(map, point.x + 5, point.y - 5)
@@ -518,6 +527,7 @@ Item {
mouseMove(map, point.x + 5 - i, point.y - 5 )
}
mouseRelease(map, point.x + 5 - i, point.y - 5)
+ verify(waitForRendering(map,10000))
point = map.fromCoordinate(extMapPolygonDateline.path[0])
verify(point.x < map.width / 2.0)
point = map.fromCoordinate(extMapPolygonDateline.path[1])
@@ -596,6 +606,7 @@ Item {
// rectangle
map.addMapItem(extMapRectEdge)
+ verify(waitForRendering(map))
verify(extMapRectEdge.topLeft.longitude == -15)
verify(extMapRectEdge.bottomRight.longitude == -5)
var point = map.fromCoordinate(extMapRectEdge.topLeft)
@@ -650,6 +661,7 @@ Item {
// quickitem
map.addMapItem(extMapQuickItemEdge)
map.center = datelineCoordinate
+ verify(waitForRendering(map))
verify(extMapQuickItemEdge.coordinate.longitude == -15)
point = map.fromCoordinate(extMapQuickItemEdge.coordinate)
verify(point.x < map.width)
@@ -671,6 +683,7 @@ Item {
// polygon
map.center = datelineCoordinate
map.addMapItem(extMapPolygonEdge)
+ verify(waitForRendering(map))
verify(extMapPolygonEdge.path[0].longitude == -15)
verify(extMapPolygonEdge.path[1].longitude == -5)
verify(extMapPolygonEdge.path[2].longitude == -5)
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 55fbd348..b3ac1d8f 100644
--- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
+++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
@@ -240,6 +240,7 @@ Item {
// normal case - fit viewport to items which are all already visible
verify_visibility_all_items()
map.fitViewportToMapItems()
+ verify(waitForRendering(map))
visualInspectionPoint()
verify_visibility_all_items()
}
@@ -322,7 +323,7 @@ Item {
verify(!is_coord_on_screen(fitRect.topLeft))
verify(!is_coord_on_screen(fitRect.bottomRight))
- map.fitViewportToGeoShape(fitRect)
+ map.visibleRegion = fitRect
visualInspectionPoint()
calculate_fit_circle_bounds()
//Rectangle should be visible, not circle
@@ -331,7 +332,7 @@ Item {
verify(is_coord_on_screen(fitRect.topLeft))
verify(is_coord_on_screen(fitRect.bottomRight))
- map.fitViewportToGeoShape(fitCircle)
+ map.visibleRegion = fitCircle
visualInspectionPoint()
calculate_fit_circle_bounds()
//Circle should be visible, not rectangle
@@ -340,7 +341,7 @@ Item {
verify(!is_coord_on_screen(fitRect.topLeft))
verify(!is_coord_on_screen(fitRect.bottomRight))
- map.fitViewportToGeoShape(fitInvalidShape)
+ map.visibleRegion = fitInvalidShape
visualInspectionPoint()
calculate_fit_circle_bounds()
//Invalid shape, map should be in the same position as before
@@ -349,7 +350,7 @@ Item {
verify(!is_coord_on_screen(fitRect.topLeft))
verify(!is_coord_on_screen(fitRect.bottomRight))
- map.fitViewportToGeoShape(fitEmptyRect)
+ map.visibleRegion = fitEmptyRect
visualInspectionPoint()
calculate_fit_circle_bounds()
//Empty shape, map should change centerlocation, empty rect visible
@@ -577,6 +578,7 @@ Item {
map.addMapItem(preMapPolygon)
map.addMapItem(preMapPolyline)
map.addMapItem(preMapRoute)
+ verify(waitForRendering(map))
compare (map.mapItems.length, 6)
calculate_bounds()
}
diff --git a/tests/auto/declarative_ui/tst_map_mouse.qml b/tests/auto/declarative_ui/tst_map_mouse.qml
index fe02f81d..57cde142 100644
--- a/tests/auto/declarative_ui/tst_map_mouse.qml
+++ b/tests/auto/declarative_ui/tst_map_mouse.qml
@@ -267,25 +267,25 @@ Item {
compare(mouseUpperClickedSpy.count, 0)
mouseUpper.enabled = true
mouseClick(map, 5, 25)
- compare(mouseUpperClickedSpy.count, 1)
+ tryCompare(mouseUpperClickedSpy, "count", 1)
compare(mouseUpperEnabledChangedSpy.count, 2)
// when overlapping are is disabled, the event should flow through
compare(mouseOverlapperClickedSpy.count, 0)
mouseClick(map, 55, 25)
- compare(mouseUpperClickedSpy.count, 1)
+ tryCompare(mouseUpperClickedSpy, "count", 1)
compare(mouseOverlapperClickedSpy.count, 1)
mouseOverlapper.enabled = false
compare(mouseOverlapperEnabledChangedSpy.count, 1)
compare(mouseOverlapper.enabled, false)
mouseClick(map, 55, 25)
- compare(mouseOverlapperClickedSpy.count, 1)
+ tryCompare(mouseOverlapperClickedSpy, "count", 1)
compare(mouseUpperClickedSpy.count, 2)
// re-enable and verify that still works
mouseOverlapper.enabled = true
compare(mouseOverlapperEnabledChangedSpy.count, 2)
compare(mouseOverlapper.enabled, true)
mouseClick(map, 55, 25)
- compare(mouseOverlapperClickedSpy.count, 2) // should consume again
+ tryCompare(mouseOverlapperClickedSpy, "count", 2) // should consume again
compare(mouseUpperClickedSpy.count, 2)
}
@@ -338,7 +338,7 @@ Item {
mouseUpper.acceptedButtons = Qt.LeftButton
compare(mouseUpperAcceptedButtonsChangedSpy.count, 2)
mouseClick(map, 5, 25)
- compare(mouseUpperClickedSpy.count, 1)
+ tryCompare(mouseUpperClickedSpy, "count", 1)
}
function test_basic_position_changed() {
@@ -574,40 +574,40 @@ Item {
// mouse click with unaccepted buttons should not cause click
mouseUpper.acceptedButtons = Qt.LeftButton
mouseClick(map, 5, 25, Qt.RightButton, Qt.AltModifier)
- compare(mouseUpperClickedSpy.count, 1)
+ tryCompare(mouseUpperClickedSpy, "count", 1)
compare(mouseLowerClickedSpy.count, 0)
compare(mouseOverlapperClickedSpy.count, 0)
mouseClick(map, 5, 25)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 0)
compare(mouseOverlapperClickedSpy.count, 0)
compare(mouseUpper.lastModifiers, Qt.NoModifier)
compare(mouseUpper.lastButton, Qt.LeftButton)
mouseClick(map, 5, 55)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 1)
compare(mouseOverlapperClickedSpy.count, 0)
mouseClick(map, 5, 55)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy,"count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 0)
// declaration order counts on overlap case; overlapping area
// declared later will get the events
mouseClick(map, 55, 25)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 1)
mouseClick(map, 55, 75)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 2)
real_click(map, 55, 25)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 3)
real_click(map, 55, 75)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 4)
}
@@ -621,7 +621,7 @@ Item {
compare(mouseLowerDoubleClickedSpy.count, 0)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
real_double_click(map, 5, 25)
- compare(mouseUpper.lastAccepted, true)
+ tryCompare(mouseUpper, "lastAccepted", true)
compare(mouseUpper.lastButton, Qt.LeftButton)
compare(mouseUpper.lastModifiers, Qt.NoModifier)
compare(mouseUpper.lastWasHeld, false)
@@ -632,26 +632,26 @@ Item {
compare(mouseLowerDoubleClickedSpy.count, 0)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
real_double_click(map, 5, 25)
- compare(mouseUpperDoubleClickedSpy.count, 2)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 0)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
real_double_click(map, 5, 55)
- compare(mouseUpperDoubleClickedSpy.count, 2)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 1)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
real_double_click(map, 5, 55)
- compare(mouseUpperDoubleClickedSpy.count, 2)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 2)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
// declaration order counts on overlap case; overlapping area declared later will get the events
real_double_click(map, 55, 25)
- compare(mouseUpperDoubleClickedSpy.count, 2)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 2)
compare(mouseOverlapperDoubleClickedSpy.count, 1)
compare(mouseOverlapperPressedSpy.count, 2)
compare(mouseOverlapperReleasedSpy.count, 2)
real_double_click(map, 55, 75)
- compare(mouseUpperDoubleClickedSpy.count, 2)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 2)
compare(mouseOverlapperDoubleClickedSpy.count, 2)
compare(mouseOverlapperPressedSpy.count, 4)
@@ -659,20 +659,20 @@ Item {
// disable overlapping area and check event is delivered to the ones beneath
mouseOverlapper.enabled = false
real_double_click(map, 55, 25)
- compare(mouseUpperDoubleClickedSpy.count, 3)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 3)
compare(mouseLowerDoubleClickedSpy.count, 2)
compare(mouseOverlapperDoubleClickedSpy.count, 2)
real_double_click(map, 55, 75)
- compare(mouseUpperDoubleClickedSpy.count, 3)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 3)
compare(mouseLowerDoubleClickedSpy.count, 3)
compare(mouseOverlapperDoubleClickedSpy.count, 2)
mouseOverlapper.enabled = true
real_double_click(map, 55, 25)
- compare(mouseUpperDoubleClickedSpy.count, 3)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 3)
compare(mouseLowerDoubleClickedSpy.count, 3)
compare(mouseOverlapperDoubleClickedSpy.count, 3)
real_double_click(map, 55, 75)
- compare(mouseUpperDoubleClickedSpy.count, 3)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 3)
compare(mouseLowerDoubleClickedSpy.count, 3)
compare(mouseOverlapperDoubleClickedSpy.count, 4)
}
@@ -698,11 +698,11 @@ Item {
compare(mouseUpper.lastY, 5) // remember 20 offset of the mouse area
mouseRelease(map,5,25)
real_press_and_hold(map, 5, 55)
- compare(mouseUpperPressAndHoldSpy.count, 1)
+ tryCompare(mouseUpperPressAndHoldSpy, "count", 1)
compare(mouseLowerPressAndHoldSpy.count, 1)
compare(mouseOverlapperPressAndHoldSpy.count, 0)
real_press_and_hold(map, 55, 75)
- compare(mouseUpperPressAndHoldSpy.count, 1)
+ tryCompare(mouseUpperPressAndHoldSpy, "count", 1)
compare(mouseLowerPressAndHoldSpy.count, 1)
compare(mouseOverlapperPressAndHoldSpy.count, 1)
compare(mouseOverlapper.lastAccepted, true)
@@ -713,14 +713,14 @@ Item {
compare(mouseOverlapper.lastY, 75)
// make sure that the wasHeld is cleared
mouseClick(map, 55, 75)
- compare(mouseOverlapper.lastAccepted, true)
+ tryCompare(mouseOverlapper, "lastAccepted", true)
compare(mouseOverlapper.lastButton, Qt.LeftButton)
compare(mouseOverlapper.lastModifiers, Qt.NoModifier)
compare(mouseOverlapper.lastWasHeld, false)
compare(mouseOverlapper.lastX, 5)
compare(mouseOverlapper.lastY, 75)
real_press_and_hold(map, 55, 25)
- compare(mouseUpperPressAndHoldSpy.count, 1)
+ tryCompare(mouseUpperPressAndHoldSpy, "count", 1)
compare(mouseLowerPressAndHoldSpy.count, 1)
compare(mouseOverlapperPressAndHoldSpy.count, 2)
}
diff --git a/tests/auto/geotestplugin/qgeotilefetcher_test.h b/tests/auto/geotestplugin/qgeotilefetcher_test.h
index 4d0ff750..18fe8650 100644
--- a/tests/auto/geotestplugin/qgeotilefetcher_test.h
+++ b/tests/auto/geotestplugin/qgeotilefetcher_test.h
@@ -68,23 +68,21 @@ Q_SIGNALS:
class QGeoTileFetcherTest: public QGeoTileFetcher
{
-Q_OBJECT
+ Q_OBJECT
public:
QGeoTileFetcherTest(QObject *parent = 0)
- : QGeoTileFetcher(parent), finishRequestImmediately_(false), mappingReply_(0),
- errorCode_(QGeoTiledMapReply::NoError)
+ : QGeoTileFetcher(parent), finishRequestImmediately_(false), errorCode_(QGeoTiledMapReply::NoError)
{
}
bool init()
{
-
return true;
}
QGeoTiledMapReply* getTileImage(const QGeoTileSpec &spec)
{
- mappingReply_ = new TiledMapReplyTest(spec, this);
+ TiledMapReplyTest* mappingReply = new TiledMapReplyTest(spec, this);
QImage im(256, 256, QImage::Format_RGB888);
im.fill(QColor("lightgray"));
@@ -113,12 +111,19 @@ public:
buffer.open(QIODevice::WriteOnly);
pm.save(&buffer, "PNG");
- mappingReply_->callSetMapImageData(bytes);
- mappingReply_->callSetMapImageFormat("png");
+ mappingReply->callSetMapImageData(bytes);
+ mappingReply->callSetMapImageFormat("png");
- timer_.start(500, this);
+ if (finishRequestImmediately_) {
+ updateRequest(mappingReply);
+ return mappingReply;
+ } else {
+ if (m_queue.isEmpty())
+ timer_.start(500, this);
+ m_queue.append(mappingReply);
+ }
- return mappingReply_;
+ return mappingReply;
}
void setParams(const QVariantMap &parameters)
@@ -141,31 +146,35 @@ public Q_SLOTS:
}
protected:
- void timerEvent(QTimerEvent *event)
- {
- if (event->timerId() != timer_.timerId()) {
- QGeoTileFetcher::timerEvent(event);
- return;
- }
-
- Q_ASSERT(mappingReply_);
- timer_.stop();
- if (errorCode_) {
- mappingReply_->callSetError(errorCode_, errorString_);
- emit tileError(mappingReply_->tileSpec(), errorString_);
- } else {
- mappingReply_->callSetError(QGeoTiledMapReply::NoError, "no error");
- mappingReply_->callSetFinished(true);
- }
- }
+ void updateRequest(TiledMapReplyTest* mappingReply)
+ {
+ if (errorCode_) {
+ mappingReply->callSetError(errorCode_, errorString_);
+ emit tileError(mappingReply->tileSpec(), errorString_);
+ } else {
+ mappingReply->callSetError(QGeoTiledMapReply::NoError, "no error");
+ mappingReply->callSetFinished(true);
+ }
+ }
+
+ void timerEvent(QTimerEvent *event)
+ {
+ if (event->timerId() != timer_.timerId()) {
+ QGeoTileFetcher::timerEvent(event);
+ return;
+ }
+ updateRequest(m_queue.takeFirst());
+ if (m_queue.isEmpty())
+ timer_.stop();
+ }
private:
bool finishRequestImmediately_;
- TiledMapReplyTest* mappingReply_;
QBasicTimer timer_;
QGeoTiledMapReply::Error errorCode_;
QString errorString_;
QSize tileSize_;
+ QList<TiledMapReplyTest*> m_queue;
};
#endif
diff --git a/tests/auto/qgeomapscene/tst_qgeomapscene.cpp b/tests/auto/qgeomapscene/tst_qgeomapscene.cpp
index ac12d986..5977e82f 100644
--- a/tests/auto/qgeomapscene/tst_qgeomapscene.cpp
+++ b/tests/auto/qgeomapscene/tst_qgeomapscene.cpp
@@ -37,7 +37,7 @@
#include "qgeomapscene_p.h"
#include "qgeocameratiles_p.h"
#include "qgeocameradata_p.h"
-#include "qgeotilecache_p.h"
+#include "qabstractgeotilecache_p.h"
#include <QtPositioning/private/qgeoprojection_p.h>
#include <QtPositioning/private/qdoublevector2d_p.h>