diff options
author | Aaron McCarthy <aaron.mccarthy@jollamobile.com> | 2013-12-18 15:15:58 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-11 01:02:51 +0100 |
commit | 334b9f3b0c4acb77db7254380c4a96cea6d589a8 (patch) | |
tree | eac101b47ec011783c050189ed8f3dbdef65d0e1 /src | |
parent | 1e58cb04817a3ea6fbed45d5bbb9e6aea99b282d (diff) | |
download | qtlocation-334b9f3b0c4acb77db7254380c4a96cea6d589a8.tar.gz |
Fix declarative_ui tests.
Coordinates for map items located outside the view port cannot be
converted to and from screen coordinates. During tests pan the map so
that the items under tests are inside the view port.
Tests for panning the map and dragging map items were failing because
mapping between coordinates and screen position only works for visible
screen positions. The MouseAreas under test did not have
preventStealing set, which was causing the map to pan slightly prior to
item drag being detected.
Stop gesture detection for a touch point when the mouse is grabbed by a
child item.
Task-number: QTBUG-31797
Change-Id: I42a801d50c194c6fe9629f3b0de606b406ad8b8c
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src')
4 files changed, 21 insertions, 16 deletions
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp index 14003c0f..a59b30e7 100644 --- a/src/imports/location/qdeclarativegeomap.cpp +++ b/src/imports/location/qdeclarativegeomap.cpp @@ -752,7 +752,7 @@ qreal QDeclarativeGeoMap::zoomLevel() const */ void QDeclarativeGeoMap::setCenter(const QGeoCoordinate ¢er) { - if (center == center_) + if (!mappingManagerInitialized_ && center == center_) return; center_ = center; @@ -925,6 +925,8 @@ bool QDeclarativeGeoMap::childMouseEventFilter(QQuickItem *item, QEvent *event) return gestureArea_->filterMapChildMouseEvent(static_cast<QMouseEvent *>(event)); else return false; + case QEvent::UngrabMouse: + return gestureArea_->filterMapChildMouseEvent(static_cast<QMouseEvent *>(event)); case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: diff --git a/src/imports/location/qdeclarativegeomapgesturearea.cpp b/src/imports/location/qdeclarativegeomapgesturearea.cpp index dcc86bac..88925524 100644 --- a/src/imports/location/qdeclarativegeomapgesturearea.cpp +++ b/src/imports/location/qdeclarativegeomapgesturearea.cpp @@ -679,6 +679,10 @@ bool QDeclarativeGeoMapGestureArea::filterMapChildMouseEvent(QMouseEvent *event) case QEvent::MouseMove: used = mouseMoveEvent(event); break; + case QEvent::UngrabMouse: + touchPoints_.clear(); + update(); + break; default: used = false; break; diff --git a/src/imports/location/qdeclarativegeomapitembase.cpp b/src/imports/location/qdeclarativegeomapitembase.cpp index 087d9c6a..d53da881 100644 --- a/src/imports/location/qdeclarativegeomapitembase.cpp +++ b/src/imports/location/qdeclarativegeomapitembase.cpp @@ -207,6 +207,7 @@ bool QDeclarativeGeoMapItemBase::childMouseEventFilter(QQuickItem *item, QEvent if (contains(static_cast<QMouseEvent*>(event)->pos())) { return false; } else { + event->setAccepted(false); return true; } default: diff --git a/src/imports/location/qdeclarativepolygonmapitem.cpp b/src/imports/location/qdeclarativepolygonmapitem.cpp index 9ba9c4e7..55261ed1 100644 --- a/src/imports/location/qdeclarativepolygonmapitem.cpp +++ b/src/imports/location/qdeclarativepolygonmapitem.cpp @@ -351,7 +351,7 @@ QDeclarativePolygonMapItem::~QDeclarativePolygonMapItem() \qmlproperty color MapPolygon::border.color This property is part of the border property group. The border property - group holds the width and color used to draw the border of the circle. + group holds the width and color used to draw the border of the polygon. The width is in pixels and is independent of the zoom level of the map. @@ -546,23 +546,21 @@ void QDeclarativePolygonMapItem::updateMapItem() geometry_.updateSourcePoints(*map(), path_); geometry_.updateScreenPoints(*map()); - if (border_.color() != Qt::transparent && border_.width() > 0) { - QList<QGeoCoordinate> closedPath = path_; - closedPath << closedPath.first(); - borderGeometry_.updateSourcePoints(*map(), closedPath); + QList<QGeoCoordinate> closedPath = path_; + closedPath << closedPath.first(); + borderGeometry_.clear(); + borderGeometry_.updateSourcePoints(*map(), closedPath); + + if (border_.color() != Qt::transparent && border_.width() > 0) borderGeometry_.updateScreenPoints(*map(), border_.width()); - QList<QGeoMapItemGeometry *> geoms; - geoms << &geometry_ << &borderGeometry_; - QRectF combined = QGeoMapItemGeometry::translateToCommonOrigin(geoms); + QList<QGeoMapItemGeometry *> geoms; + geoms << &geometry_ << &borderGeometry_; + QRectF combined = QGeoMapItemGeometry::translateToCommonOrigin(geoms); + + setWidth(combined.width()); + setHeight(combined.height()); - setWidth(combined.width()); - setHeight(combined.height()); - } else { - borderGeometry_.clear(); - setWidth(geometry_.sourceBoundingBox().width()); - setHeight(geometry_.sourceBoundingBox().height()); - } setPositionOnMap(path_.at(0), -1 * geometry_.sourceBoundingBox().topLeft()); update(); } |