diff options
23 files changed, 63 insertions, 707 deletions
diff --git a/examples/location/mapviewer/content/map/ImageItem.qml b/examples/location/mapviewer/content/map/ImageItem.qml index a7146fbf..81e9f1c1 100644 --- a/examples/location/mapviewer/content/map/ImageItem.qml +++ b/examples/location/mapviewer/content/map/ImageItem.qml @@ -43,7 +43,7 @@ import QtLocation 5.0 MapQuickItem { //to be used inside MapComponent only id: imageItem - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent } diff --git a/examples/location/mapviewer/content/map/MapComponent.qml b/examples/location/mapviewer/content/map/MapComponent.qml index e51373a7..6d7d7baa 100644 --- a/examples/location/mapviewer/content/map/MapComponent.qml +++ b/examples/location/mapviewer/content/map/MapComponent.qml @@ -298,7 +298,7 @@ Map { smooth: true opacity: 0.8 //! [routedelegate0] - MapMouseArea { + MouseArea { id: routeMouseArea anchors.fill: parent hoverEnabled: false @@ -346,7 +346,7 @@ Map { opacity: 0.6 center: locationData.coordinate //! [pointdel0] - MapMouseArea { + MouseArea { anchors.fill:parent id: circleMouseArea hoverEnabled: false @@ -365,7 +365,8 @@ Map { Math.abs(map.pressX - parent.x- mouse.x ) > map.jitterThreshold || Math.abs(map.pressY - parent.y -mouse.y ) > map.jitterThreshold) { map.state = "" - if (pressed) parent.radius = parent.center.distanceTo(mouseToCoordinate(mouse)) + if (pressed) parent.radius = parent.center.distanceTo( + map.toCoordinate(Qt.point(mouse.x, mouse.y))) } if ((mouse.button == Qt.LeftButton) & (map.state == "")) { map.lastX = mouse.x + parent.x @@ -844,7 +845,7 @@ Map { } } - MapMouseArea { + MouseArea { id: mouseArea property variant lastCoordinate anchors.fill: parent @@ -856,7 +857,7 @@ Map { map.lastY = mouse.y map.pressX = mouse.x map.pressY = mouse.y - lastCoordinate = mouseArea.mouseToCoordinate(mouse) + lastCoordinate = map.toCoordinate(Qt.point(mouse.x, mouse.y)) // if (mouse.button == Qt.MiddleButton) // addMarker() } @@ -879,7 +880,7 @@ Map { } onDoubleClicked: { - map.center = mouseArea.mouseToCoordinate(mouse) + map.center = map.toCoordinate(Qt.point(mouse.x, mouse.y)) if (mouse.button == Qt.LeftButton){ map.zoomLevel += 1 } else if (mouse.button == Qt.RightButton) map.zoomLevel -= 1 diff --git a/examples/location/mapviewer/content/map/Marker.qml b/examples/location/mapviewer/content/map/Marker.qml index d7a1e838..ece34819 100644 --- a/examples/location/mapviewer/content/map/Marker.qml +++ b/examples/location/mapviewer/content/map/Marker.qml @@ -57,7 +57,7 @@ MapQuickItem { id: image //! [mqi-anchor] source: markerMouseArea.containsMouse ? (markerMouseArea.pressed ? "../../resources/marker_selected.png" :"../../resources/marker_hovered.png") : "../../resources/marker.png" - MapMouseArea { + MouseArea { id: markerMouseArea property int pressX : -1 property int pressY : -1 @@ -108,7 +108,8 @@ MapQuickItem { } //! [mqi-closeimage] - Component.onCompleted: coordinate = mouseArea.lastCoordinate + Component.onCompleted: coordinate = map.toCoordinate(Qt.point(markerMouseArea.mouseX, + markerMouseArea.mouseY)); //! [mqi-close] } //! [mqi-close] diff --git a/examples/location/mapviewer/content/map/MiniMap.qml b/examples/location/mapviewer/content/map/MiniMap.qml index e5d03e49..5bee404c 100644 --- a/examples/location/mapviewer/content/map/MiniMap.qml +++ b/examples/location/mapviewer/content/map/MiniMap.qml @@ -62,9 +62,6 @@ Rectangle{ center: map.center plugin: map.plugin gesture.enabled: false - MapMouseArea{ - anchors.fill: parent - } MapRectangle { color: "#44ff0000" diff --git a/examples/location/mapviewer/content/map/PolygonItem.qml b/examples/location/mapviewer/content/map/PolygonItem.qml index b6e41ea6..9b52bbca 100644 --- a/examples/location/mapviewer/content/map/PolygonItem.qml +++ b/examples/location/mapviewer/content/map/PolygonItem.qml @@ -55,7 +55,7 @@ MapPolygon { addCoordinate(markers[i].coordinate) } } - MapMouseArea { + MouseArea { anchors.fill:parent id: mousearea drag.target: parent diff --git a/examples/location/mapviewer/content/map/RectangleItem.qml b/examples/location/mapviewer/content/map/RectangleItem.qml index 97896883..1b58f468 100644 --- a/examples/location/mapviewer/content/map/RectangleItem.qml +++ b/examples/location/mapviewer/content/map/RectangleItem.qml @@ -65,7 +65,7 @@ MapRectangle { (bottomRight.longitude == 153.3021)) } - MapMouseArea { + MouseArea { anchors.fill:parent id: mousearea hoverEnabled: false diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp index 894d555e..260e60b6 100644 --- a/src/imports/location/location.cpp +++ b/src/imports/location/location.cpp @@ -42,7 +42,6 @@ #include "qdeclarativegeoserviceprovider_p.h" #include "qdeclarativegeomap_p.h" -#include "qdeclarativegeomapmousearea_p.h" #include "qdeclarativegeomapmouseevent_p.h" #include "qdeclarativegeoroute_p.h" @@ -110,8 +109,6 @@ public: qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase>(uri, 5, 0, "GeoMapItemBase", QCoreApplication::translate(CONTEXT_NAME, NOT_INSTANTIABLE_BY_DEVELOPER).arg("GeoMapItemBase")); qmlRegisterType<QDeclarativeGeoMapQuickItem>(uri, 5, 0, "MapQuickItem"); qmlRegisterType<QDeclarativeGeoMapItemView>(uri, 5, 0, "MapItemView"); - qmlRegisterType<QDeclarativeGeoMapMouseArea>(uri, 5, 0, "MapMouseArea"); - qmlRegisterType<QDeclarativeGeoMapMouseEvent>(uri, 5, 0, "MapMouseEvent"); qmlRegisterType<QDeclarativeGeocodeModel>(uri, 5, 0, "GeocodeModel"); // geocoding and reverse geocoding qmlRegisterType<QDeclarativeGeoRouteModel>(uri, 5, 0, "RouteModel"); diff --git a/src/imports/location/location.pro b/src/imports/location/location.pro index 8dccfa2d..1538fe55 100644 --- a/src/imports/location/location.pro +++ b/src/imports/location/location.pro @@ -17,8 +17,6 @@ win32 { HEADERS += \ qdeclarativegeomapitemview_p.h \ - qdeclarativegeomapmouseevent_p.h \ - qdeclarativegeomapmousearea_p.h \ qdeclarativegeoserviceprovider_p.h \ qdeclarativegeocodemodel_p.h \ qdeclarativegeoroutemodel_p.h \ @@ -44,8 +42,6 @@ HEADERS += \ SOURCES += \ location.cpp \ qdeclarativegeomapitemview.cpp \ - qdeclarativegeomapmouseevent.cpp \ - qdeclarativegeomapmousearea.cpp \ qdeclarativegeoserviceprovider.cpp \ qdeclarativegeocodemodel.cpp \ qdeclarativegeoroutemodel.cpp \ diff --git a/src/imports/location/qdeclarativecirclemapitem.cpp b/src/imports/location/qdeclarativecirclemapitem.cpp index c5962044..90f34740 100644 --- a/src/imports/location/qdeclarativecirclemapitem.cpp +++ b/src/imports/location/qdeclarativecirclemapitem.cpp @@ -84,7 +84,7 @@ QT_BEGIN_NAMESPACE accuracy of the circle's shape, depending on position and map projection. - \note Dragging a MapCircle (through the use of \l MapMouseArea) + \note Dragging a MapCircle (through the use of \l MouseArea) causes new points to be generated at the same distance (in meters) from the center. This is in contrast to other map items which store their dimensions in terms of latitude and longitude differences between diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp index bc97bed1..14003c0f 100644 --- a/src/imports/location/qdeclarativegeomap.cpp +++ b/src/imports/location/qdeclarativegeomap.cpp @@ -40,7 +40,6 @@ ****************************************************************************/ #include "qdeclarativegeomap_p.h" -#include "qdeclarativegeomapmousearea_p.h" #include "error_messages.h" #include "qdeclarativecirclemapitem_p.h" @@ -134,13 +133,6 @@ QT_BEGIN_NAMESPACE specially at startup and cannot be replaced or destroyed. Its properties can be altered, however, to control its behavior. - Mouse and touch interaction with Maps and map objects is slightly different - to ordinary QML types. In a Map or Map object, you will need to make use - of the \l MapMouseArea type instead of the normal Qt Quick MouseArea. - MapMouseArea is, in almost all respects, a drop-in replacement for - MouseArea, but the documentation for that type should be referred to for - further details. - \section2 Performance Maps are rendered using OpenGL (ES) and the Qt Scene Graph stack, and as diff --git a/src/imports/location/qdeclarativegeomapitembase.cpp b/src/imports/location/qdeclarativegeomapitembase.cpp index 8a6a4eab..e4b56833 100644 --- a/src/imports/location/qdeclarativegeomapitembase.cpp +++ b/src/imports/location/qdeclarativegeomapitembase.cpp @@ -40,10 +40,10 @@ ****************************************************************************/ #include "qdeclarativegeomapitembase_p.h" -#include "qdeclarativegeomapmousearea_p.h" #include "qgeocameradata_p.h" #include <QtQml/QQmlInfo> #include <QtQuick/QSGOpacityNode> +#include <QtQuick/private/qquickmousearea_p.h> QT_BEGIN_NAMESPACE @@ -84,6 +84,7 @@ QDeclarativeGeoMapItemBase::QDeclarativeGeoMapItemBase(QQuickItem *parent) map_(0), quickMap_(0) { + setFiltersChildMouseEvents(true); connect(this, SIGNAL(childrenChanged()), this, SLOT(afterChildrenChanged())); } @@ -105,7 +106,7 @@ void QDeclarativeGeoMapItemBase::afterChildrenChanged() bool printedWarning = false; foreach (QQuickItem *i, kids) { if (i->flags() & QQuickItem::ItemHasContents - && !qobject_cast<QDeclarativeGeoMapMouseArea *>(i)) { + && !qobject_cast<QQuickMouseArea *>(i)) { if (!printedWarning) { qmlInfo(this) << "Geographic map items do not support child items"; printedWarning = true; @@ -212,6 +213,23 @@ float QDeclarativeGeoMapItemBase::zoomLevelOpacity() const return 0.0; } +bool QDeclarativeGeoMapItemBase::childMouseEventFilter(QQuickItem *item, QEvent *event) +{ + Q_UNUSED(item) + switch (event->type()) { + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + if (contains(static_cast<QMouseEvent*>(event)->pos())) { + return false; + } else { + return true; + } + default: + return false; + } +} + /*! \internal */ diff --git a/src/imports/location/qdeclarativegeomapitembase_p.h b/src/imports/location/qdeclarativegeomapitembase_p.h index 78424124..1e726459 100644 --- a/src/imports/location/qdeclarativegeomapitembase_p.h +++ b/src/imports/location/qdeclarativegeomapitembase_p.h @@ -91,6 +91,7 @@ protected Q_SLOTS: protected: float zoomLevelOpacity() const; + bool childMouseEventFilter(QQuickItem *item, QEvent *event); private Q_SLOTS: void baseCameraDataChanged(const QGeoCameraData &camera); diff --git a/src/imports/location/qdeclarativegeomapitemview.cpp b/src/imports/location/qdeclarativegeomapitemview.cpp index 1ae8cb68..b737f9da 100644 --- a/src/imports/location/qdeclarativegeomapitemview.cpp +++ b/src/imports/location/qdeclarativegeomapitemview.cpp @@ -40,7 +40,6 @@ ****************************************************************************/ #include "qdeclarativegeomapitemview_p.h" -#include "qdeclarativegeomapmousearea_p.h" #include "qdeclarativegeomap_p.h" #include "qdeclarativegeomapitembase_p.h" diff --git a/src/imports/location/qdeclarativegeomapmousearea.cpp b/src/imports/location/qdeclarativegeomapmousearea.cpp deleted file mode 100644 index 8146ecc3..00000000 --- a/src/imports/location/qdeclarativegeomapmousearea.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 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 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativegeomapmousearea_p.h" -#include "qdeclarativegeomapitembase_p.h" -#include <QtQml/qqmlinfo.h> -#include <QtQuick/QQuickWindow> - -#include <QtQuick/private/qquickevents_p_p.h> -#include <QtQuick/private/qquickdrag_p.h> - -#include <QDebug> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype MapMouseArea - \instantiates QDeclarativeGeoMapMouseArea - - \brief The MapMouseArea item enables simple mouse handling. - - \inqmlmodule QtLocation - \ingroup qml-QtLocation5-maps - - Like a standard Qt Quick \l{MouseArea}, the MapMouseArea provides mouse - handling for an item. Creating a normal Qt Quick MouseArea inside a - map object type (for example MapPolygon) will result in undefined behavior - due to the way in which Map objects are rendered, so MapMouseArea exists to - provide this functionality instead. - - The only exception to this is the MapQuickItem, which can have normal - MouseArea objects defined within the sourceItem. See the documentation - for \l{MapQuickItem} for more details. - - MapMouseArea objects should only ever be used within a map object, such as - a MapPolygon or MapQuickItem, and never within another Qt Quick component. - - The \l enabled property of the MapMouseArea is used to enable and disable - mouse handling for the proxied item. When disabled, the mouse area becomes - transparent to mouse events. - - The \l pressed read-only property indicates whether or not the user is - holding down a mouse button over the mouse area. This property is often - used in bindings between properties in a user interface. - - Information about the mouse position and button clicks are provided via - signals for which event handler properties are defined. The most commonly - used handlers involve handling mouse presses and clicks: onClicked, - onDoubleClicked, onPressed and onReleased. - - \section2 Example Usage - - The following example shows a map containing a MapCircle object. When - the user clicks the MapCircle, a message is printed to the console. - - \code - Map { - MapCircle { - center { - latitude: -27.5 - longitude: 153 - } - radius: 100 - - MapMouseArea { - anchors.fill: parent - - onClicked: { - console.log("You clicked the circle!"); - } - } - } - } - \endcode - - \section2 Limitations - - Some important limitations apply to the use of a MapMouseArea: - \list - \li The mouse event is guaranteed only to be valid for the - duration of the signal handler (for example onPositionChanged, onClicked). Consequently - the mouse event itself should not be stored. The main reason for this is to - optimize memory usage; we do not want to allocate heap memory every time the mouse - moves. - \li Nested mouse areas are not supported (MapMouseArea { MapMouseArea {} }. - \li If two or more MapMouseAreas overlap, the declaration order is significant (not for example 'z' value). - \li Only one MapMouseArea per MapItem is supported, and it always fills the whole MapItem. - \endlist - - \sa MapMouseEvent -*/ - -QDeclarativeGeoMapMouseArea::QDeclarativeGeoMapMouseArea(QQuickItem *parent) - : QQuickMouseArea(parent), - componentCompleted_(false), - dragActive_(false) -{ -} - -QDeclarativeGeoMapMouseArea::~QDeclarativeGeoMapMouseArea() -{ -} - -/*! - \qmlmethod coordinate QtLocation::MapMouseArea::mouseToCoordinate(MouseEvent event) - - Converts the \a event's coordinates to geo coordinates. - */ -QGeoCoordinate QDeclarativeGeoMapMouseArea::mouseToCoordinate(QQuickMouseEvent *event) -{ - // figure out the map association for this mouse area and use it to resolve geocoordinate - QDeclarativeGeoMap *quickmap = map(); - if (quickmap) - return quickmap->toCoordinate(quickmap->mapFromItem(this, QPointF(event->x(), event->y()))); - return QGeoCoordinate(); // return invalid coordinate -} - -/*! - \internal -*/ -// TODO: cache the map association and hook up to parent change -signals -QDeclarativeGeoMap *QDeclarativeGeoMapMouseArea::map() -{ - QQuickItem *pmi = parentMapItem(); - QDeclarativeGeoMap *map = 0; - if (pmi) { - map = qobject_cast<QDeclarativeGeoMap *>(pmi); - if (!map) { - QDeclarativeGeoMapItemBase *item = qobject_cast<QDeclarativeGeoMapItemBase *>(pmi); - if (item) - map = item->quickMap(); - } - } - return map; -} - -/*! - \internal -*/ -void QDeclarativeGeoMapMouseArea::dragActiveChanged() -{ - if (drag() && drag()->property("active").toBool()) { - dragActive_ = true; - QQuickItem *pmi = parentMapItem(); - if (pmi && qobject_cast<QDeclarativeGeoMapItemBase *>(pmi)) - qobject_cast<QDeclarativeGeoMapItemBase *>(pmi)->dragStarted(); - } -} - -/*! - \internal -*/ -void QDeclarativeGeoMapMouseArea::componentComplete() -{ - componentCompleted_ = true; - connect(drag(), SIGNAL(activeChanged()), this, SLOT(dragActiveChanged())); - QQuickMouseArea::componentComplete(); -} - -/*! - \internal -*/ -void QDeclarativeGeoMapMouseArea::mousePressEvent(QMouseEvent *event) -{ - // ignore event if it misses non-rectangular geometry (e.g. circle, route) - QQuickItem *pmi = parentMapItem(); - bool contains = true; - if (pmi && qobject_cast<QDeclarativeGeoMapItemBase *>(pmi)) - contains = pmi->contains(event->pos()); - - if (contains) - QQuickMouseArea::mousePressEvent(event); - else - event->ignore(); -} - -/*! - \internal -*/ -void QDeclarativeGeoMapMouseArea::mouseReleaseEvent(QMouseEvent *event) -{ - QQuickItem *pmi = parentMapItem(); - - if (dragActive_ && pmi && qobject_cast<QDeclarativeGeoMapItemBase *>(pmi)) { - // position of the item may have changed by the time the activeChanged - // is received, hence update already on mouse release - qobject_cast<QDeclarativeGeoMapItemBase *>(pmi)->dragEnded(); - dragActive_ = false; - } - - QQuickMouseArea::mouseReleaseEvent(event); -} - -/*! - \internal -*/ -void QDeclarativeGeoMapMouseArea::mouseDoubleClickEvent(QMouseEvent *event) -{ - QQuickMouseArea::mouseDoubleClickEvent(event); -} - -/*! - \internal -*/ -void QDeclarativeGeoMapMouseArea::mouseMoveEvent(QMouseEvent *event) -{ - QQuickMouseArea::mouseMoveEvent(event); -} - -/*! - \internal -*/ -void QDeclarativeGeoMapMouseArea::hoverEnterEvent(QHoverEvent *event) -{ - QQuickItem *pmi = parentMapItem(); - bool contains = true; - if (pmi && qobject_cast<QDeclarativeGeoMapItemBase *>(pmi)) - contains = pmi->contains(event->pos()); - - /* for many objects it's doubtful this will ever be true */ - if (!hovered() && contains) - QQuickMouseArea::hoverEnterEvent(event); - else - event->ignore(); -} - -/*! - \internal -*/ -void QDeclarativeGeoMapMouseArea::hoverMoveEvent(QHoverEvent *event) -{ - QQuickItem *pmi = parentMapItem(); - bool contains = true; - if (pmi && qobject_cast<QDeclarativeGeoMapItemBase *>(pmi)) - contains = pmi->contains(event->pos()); - - /* we may have already entered the object from scenegraph's perspective - * (ie, the hoverEnterEvent fired and we ignored it), so make sure our - * state is set correctly here */ - if (hovered() && !contains) - QQuickMouseArea::hoverLeaveEvent(event); - else if (!hovered() && contains) - QQuickMouseArea::hoverEnterEvent(event); - else if (hovered() && contains) - QQuickMouseArea::hoverMoveEvent(event); - else - event->ignore(); -} - -/*! - \internal -*/ -void QDeclarativeGeoMapMouseArea::hoverLeaveEvent(QHoverEvent *event) -{ - QQuickItem *pmi = parentMapItem(); - bool contains = true; - if (pmi && qobject_cast<QDeclarativeGeoMapItemBase *>(pmi)) - contains = pmi->contains(event->pos()); - - if (!hovered() && contains) - QQuickMouseArea::hoverEnterEvent(event); - - if (hovered()) - QQuickMouseArea::hoverLeaveEvent(event); - else - event->ignore(); -} - -/*! - \internal -*/ -QQuickItem *QDeclarativeGeoMapMouseArea::parentMapItem() -{ - QQuickItem *item = this; - while (item->parentItem()) { - item = item->parentItem(); - if (qobject_cast<QDeclarativeGeoMap *>(item) || - qobject_cast<QDeclarativeGeoMapItemBase *>(item)) - return item; - } - return 0; -} - -/*! - \qmlproperty real QtLocation::MapMouseArea::mouseX - \qmlproperty real QtLocation::MapMouseArea::mouseY - - These properties hold the screen coordinates of the mouse cursor. - - These properties will only be valid while a button is pressed, and will remain - valid as long as the button is held down even if the mouse is moved outside the area. - - The screen coordinates are relative to the MapMouseArea. -*/ - -/*! - \qmlproperty bool QtLocation::MapMouseArea::containsMouse - This property holds whether the mouse is currently inside the mouse area. - - \warning This property is not updated if the area moves under the mouse: \e containsMouse will not change. - In addition, containsMouse will only be valid when the mouse is pressed. -*/ - -/*! - \qmlproperty bool QtLocation::MapMouseArea::pressed - This property holds whether the mouse area is currently pressed. -*/ - -/*! - \qmlproperty bool QtLocation::MapMouseArea::enabled - This property holds whether the item accepts mouse events. - - By default, this property is true. -*/ - -/*! - \qmlproperty MouseButton QtLocation::MapMouseArea::pressedButtons - This property holds the mouse buttons currently pressed. - - It contains a bitwise combination of: - \list - \li Qt.LeftButton - \li Qt.RightButton - \li Qt.MiddleButton - \endlist - - \sa acceptedButtons -*/ - -/*! - \qmlproperty Qt::MouseButtons QtLocation::MapMouseArea::acceptedButtons - This property holds the mouse buttons that the mouse area reacts to. - - The available buttons are: - \list - \li Qt.LeftButton - \li Qt.RightButton - \li Qt.MiddleButton - \endlist - - To accept more than one button the flags can be combined with the - "|" (or) operator: - - \code - MapMouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton } - \endcode - - The default value is \c Qt.LeftButton. -*/ - -/*! - \qmlsignal QtLocation::MapMouseArea::onPressed(MapMouseEvent mouse) - - This handler is called when there is a press. - - The \l {MapMouseEvent}{mouse} parameter provides information about the - press, including the x and y position and which button was pressed. - - The \l {MapMouseEvent}{accepted} property of the MapMouseEvent parameter determines whether - this MapMouseArea will handle the press and all future mouse events until - release. The default is to accept the event and not allow other - MapMouseArea beneath this one to handle the event. If \l {MapMouseEvent}{accepted} - is set to false, no further events will be sent to this MapMouseArea until - the button is next pressed. -*/ - -/*! - \qmlsignal QtLocation::MapMouseArea::onReleased(MapMouseEvent mouse) - - This handler is called when there is a release. - The \l {MapMouseEvent}{mouse} parameter provides information about the - click, including the x and y position of the release of the click. - - The \l {MapMouseEvent}{accepted} property of the MapMouseEvent parameter is ignored - in this handler. -*/ - -/*! - \qmlsignal QtLocation::MapMouseArea::onClicked(MapMouseEvent mouse) - - This handler is called when there is a click. A click is defined as a - press followed by a release, both inside the MapMouseArea (pressing, - moving outside the MapMouseArea, and then moving back inside and - releasing is also considered a click). - - The \l {MapMouseEvent}{mouse} parameter provides information about the - click, including the x and y position of the release of the click. - - The \l {MapMouseEvent}{accepted} property of the MapMouseEvent parameter is ignored in - this handler. -*/ - -/*! - \qmlsignal QtLocation::MapMouseArea::onDoubleClicked(MapMouseEvent mouse) - - This handler is called when there is a double-click (a press followed - by a release followed by a press). - - The \l {MapMouseEvent}{mouse} parameter provides information about the - click, including the x and y position of the release of the click. - - If the \l {MapMouseEvent}{accepted} property of the \l {MapMouseEvent}{mouse} parameter is - set to false in the handler, the onPressed/onReleased/onClicked handlers - will be called for the second click; otherwise they are suppressed. - The accepted property defaults to true. -*/ - -/*! - \qmlsignal QtLocation::MapMouseArea::onEntered() - - This handler is called when the mouse enters the mouse area. - - The onEntered handler is only called while a button is - pressed. - - \sa onExited -*/ - -/*! - \qmlsignal QtLocation::MapMouseArea::onPositionChanged(MapMouseEvent mouse) - - This handler is called when the mouse position changes. - - The \l {MapMouseEvent}{mouse} parameter provides information about the mouse, including the x and y - position, and any buttons currently pressed. - - The \e accepted property of the MapMouseEvent parameter is ignored in this handler. - - The onPositionChanged handler is only called while a button is pressed. -*/ - -/*! - \qmlsignal QtLocation::MapMouseArea::onPressAndHold(MapMouseEvent mouse) - - This handler is called when there is a long press (currently 800ms). - The \l {MapMouseEvent}{mouse} parameter provides information about the press, including the x and y - position of the press, and which button is pressed. - - The \e accepted property of the MapMouseEvent parameter is ignored in this handler. -*/ - -/*! - \qmlsignal QtLocation::MapMouseArea::onExited() - - This handler is called when the mouse exits the mouse area. - - The onExited handler is only called while a button is pressed. - - \sa onEntered -*/ - -#include "moc_qdeclarativegeomapmousearea_p.cpp" - -QT_END_NAMESPACE diff --git a/src/imports/location/qdeclarativegeomapmousearea_p.h b/src/imports/location/qdeclarativegeomapmousearea_p.h deleted file mode 100644 index 3c89ef0b..00000000 --- a/src/imports/location/qdeclarativegeomapmousearea_p.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 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 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEGEOMAPMOUSEAREA_H -#define QDECLARATIVEGEOMAPMOUSEAREA_H - -#include "qdeclarativegeomap_p.h" -#include "qdeclarativegeomapmouseevent_p.h" - -#include <QtQuick/QQuickItem> -#include <QtQuick/private/qquickmousearea_p.h> - -QT_BEGIN_NAMESPACE - -class QDeclarativeGeoMapMouseArea : public QQuickMouseArea -{ - Q_OBJECT - -public: - explicit QDeclarativeGeoMapMouseArea(QQuickItem *parent = 0); - ~QDeclarativeGeoMapMouseArea(); - - Q_INVOKABLE QGeoCoordinate mouseToCoordinate(QQuickMouseEvent *event); - - // From QQmlParserStatus - virtual void componentComplete(); - -protected: - // from QQuickItem - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void hoverEnterEvent(QHoverEvent *event); - void hoverMoveEvent(QHoverEvent *event); - void hoverLeaveEvent(QHoverEvent *event); - -private Q_SLOTS: - void dragActiveChanged(); - -private: - QQuickItem *parentMapItem(); - QDeclarativeGeoMap *map(); - -private: - bool componentCompleted_; - bool dragActive_; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeGeoMapMouseArea) - -#endif diff --git a/src/imports/location/qdeclarativegeomapquickitem.cpp b/src/imports/location/qdeclarativegeomapquickitem.cpp index 4dd8a188..dc4250d2 100644 --- a/src/imports/location/qdeclarativegeomapquickitem.cpp +++ b/src/imports/location/qdeclarativegeomapquickitem.cpp @@ -40,10 +40,10 @@ ****************************************************************************/ #include "qdeclarativegeomapquickitem_p.h" -#include "qdeclarativegeomapmousearea_p.h" #include <QtQml/qqmlinfo.h> #include <QtQuick/QSGOpacityNode> #include "qdoublevector2d_p.h" +#include <QtQuick/private/qquickmousearea_p.h> #include <QDebug> #include <cmath> @@ -89,50 +89,6 @@ QT_BEGIN_NAMESPACE "on the screen" rather than "on the map", so that its size remains the same regardless of the zoom level of the Map. - \section2 Interaction - - MapQuickItem is different to the other map objects in that it can - accept "normal" QtQuick mouse and touch interaction types as well as - the MapMouseArea and friends. For example, for a MapQuickItem, the following - two situations are equivalent: - - \code - MapQuickItem { - sourceItem: Rectangle { - width: 20; height: 20 - } - - MapMouseArea { - onClicked: { - console.log("clicked!"); - } - } - } - \endcode - - \code - MapQuickItem { - sourceItem: Rectangle { - width: 20; height: 20 - - MouseArea { - onClicked: { - console.log("clicked!"); - } - } - } - } - \endcode - - Note, however, that using a MapMouseArea inside the sourceItem (in this - case, inside the Rectangle object), is unsupported, and may not work as - desired. - - MouseAreas used inside a complex \l{sourceItem} can be used to create, for - example, a "close" button within a speech bubble that can be clicked - separately to the rest of the bubble, which would be impossible using - MapMouseArea alone. - \section2 Performance Performance of a MapQuickItem is normally in the same ballpark as the @@ -263,7 +219,7 @@ void QDeclarativeGeoMapQuickItem::afterChildrenChanged() bool printedWarning = false; foreach (QQuickItem *i, kids) { if (i->flags() & QQuickItem::ItemHasContents - && !qobject_cast<QDeclarativeGeoMapMouseArea *>(i) + && !qobject_cast<QQuickMouseArea *>(i) && sourceItem_.data() != i && opacityContainer_ != i) { if (!printedWarning) { diff --git a/src/imports/location/qdeclarativepolygonmapitem.cpp b/src/imports/location/qdeclarativepolygonmapitem.cpp index 7b87bc29..442ad307 100644 --- a/src/imports/location/qdeclarativepolygonmapitem.cpp +++ b/src/imports/location/qdeclarativepolygonmapitem.cpp @@ -98,7 +98,7 @@ QT_BEGIN_NAMESPACE \l border.width properties. \note Since MapPolygons are geographic items, dragging a MapPolygon - (through the use of \l MapMouseArea) causes its vertices to be + (through the use of \l MouseArea) causes its vertices to be recalculated in the geographic coordinate space. The edges retain the same geographic lengths (latitude and longitude differences between the vertices), but they remain straight. Apparent stretching of the item occurs diff --git a/src/location/doc/src/maps.qdoc b/src/location/doc/src/maps.qdoc index a9816f52..180eb04c 100644 --- a/src/location/doc/src/maps.qdoc +++ b/src/location/doc/src/maps.qdoc @@ -113,26 +113,11 @@ only be created within a \l{QtLocation::Map}{Map}. \section2 Interaction with Map Overlay Objects -Interaction with the pre-defined map overlay object types is done using the -\l{QtLocation::MapMouseArea}{MapMouseArea} type, which behaves much like a -normal QtQuick MouseArea. MapQuickItems can also contain MapMouseArea objects, -but can additionally use normal QtQuick MouseAreas to provide interaction. - Properties of map overlay objects that influence their appearance on the display can be changed at any time, and many can also be used in animations. Animating coordinate-based map overlay objects, such as MapPolygon and MapPolyline, is not yet available. -\b{Key Types} -\table - \row - \li \l{QtLocation::MapMouseArea}{MapMouseArea} - \li Accepts mouse events for a pre-defined map overlay object (for example MapCircle). - \row - \li \l{QtLocation::MapMouseEvent}{MapMouseEvent} - \li Provides additional information unique to mouse events on a Map. -\endtable - \section1 Geocoding -- Address to Coordinate and Vice Versa Geocoding is the translation of geographic coordinates into addresses, or vice diff --git a/src/location/doc/src/qml-maps.qdoc b/src/location/doc/src/qml-maps.qdoc index 84ccfbf4..460ec170 100644 --- a/src/location/doc/src/qml-maps.qdoc +++ b/src/location/doc/src/qml-maps.qdoc @@ -48,9 +48,7 @@ Map item you can center the map, zoom, pinch and make the item flickable. The places to be added to the map are \l {Maps and Navigation (QML)#Putting Objects on a Map (Map Overlay Objects)}{MapItems}. The item's position is defined by a \l {coordinate}{coordinate} which includes latitude, -longitude and altitude. The item is then displayed automatically after it is added to the Map. -Interaction with the added items, and the \l Map itself, is handled by \l MapMouseArea when items -are added as children of the +longitude and altitude. The item is then displayed automatically after it is added to the Map. \l {Maps and Navigation (QML)#Putting Objects on a Map (Map Overlay Objects)}{MapItems} or \l Map. \section2 Position on map diff --git a/tests/auto/declarative_ui/tst_map_item.qml b/tests/auto/declarative_ui/tst_map_item.qml index 6533e964..cfb1c51b 100644 --- a/tests/auto/declarative_ui/tst_map_item.qml +++ b/tests/auto/declarative_ui/tst_map_item.qml @@ -97,7 +97,7 @@ Item { } color: 'firebrick' radius: 600000 - MapMouseArea { + MouseArea { anchors.fill: parent onClicked: console.log('ext circle clicked') SignalSpy { id: extMapCircleClicked; target: parent; signalName: "clicked" } @@ -106,7 +106,7 @@ Item { MapQuickItem { id: extMapQuickItem - MapMouseArea { + MouseArea { anchors.fill: parent SignalSpy { id: extMapQuickItemClicked; target: parent; signalName: "clicked" } } @@ -160,7 +160,7 @@ Item { longitude: 30 } radius: 400000 - MapMouseArea { + MouseArea { id: preMapCircleMa anchors.fill: parent drag.target: parent @@ -175,7 +175,7 @@ Item { } MapQuickItem { id: preMapQuickItem - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent SignalSpy { id: preMapQuickItemClicked; target: parent; signalName: "clicked" } @@ -204,7 +204,7 @@ Item { { latitude: 20, longitude: 10 }, { latitude: 15, longitude: 6 } ] - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent SignalSpy { id: preMapPolygonClicked; target: parent; signalName: "clicked" } diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml index ccaba322..a15fc353 100644 --- a/tests/auto/declarative_ui/tst_map_item_details.qml +++ b/tests/auto/declarative_ui/tst_map_item_details.qml @@ -65,7 +65,7 @@ Item { { latitude: 25, longitude: 5 }, { latitude: 20, longitude: 10 } ] - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent SignalSpy { id: extMapPolygonClicked; target: parent; signalName: "clicked" } @@ -109,7 +109,7 @@ Item { latitude: 10 longitude: -175 } - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent } @@ -123,7 +123,7 @@ Item { longitude: 180 } radius: 400000 - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent } @@ -131,7 +131,7 @@ Item { MapQuickItem { id: extMapQuickItemDateline - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent } @@ -155,7 +155,7 @@ Item { { latitude: 10, longitude: -175 }, { latitude: 10, longitude: 175 } ] - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent } @@ -168,7 +168,7 @@ Item { { latitude: 20, longitude: 175 }, { latitude: 25, longitude: -175 } ] - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent } @@ -196,7 +196,7 @@ Item { latitude: 10 longitude: -5 } - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent } @@ -210,7 +210,7 @@ Item { longitude: -15 } radius: 400000 - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent } @@ -218,7 +218,7 @@ Item { MapQuickItem { id: extMapQuickItemEdge - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent } @@ -242,7 +242,7 @@ Item { { latitude: 10, longitude: -5 }, { latitude: 10, longitude: -15 } ] - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent } @@ -255,7 +255,7 @@ Item { { latitude: 20, longitude: -15 }, { latitude: 25, longitude: -5 } ] - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent } 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 ff3d224c..26cef4f8 100644 --- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml +++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml @@ -152,8 +152,7 @@ Item { border.width: 0 center: preMapCircleDefaultCenter radius: 400000 - MapMouseArea { - id: preMapCircleMa + MouseArea { anchors.fill: parent drag.target: parent SignalSpy { id: preMapCircleClicked; target: parent; signalName: "clicked" } @@ -167,7 +166,7 @@ Item { } MapQuickItem { id: preMapQuickItem - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent SignalSpy { id: preMapQuickItemClicked; target: parent; signalName: "clicked" } @@ -193,7 +192,7 @@ Item { { latitude: 20, longitude: 10 }, { latitude: 15, longitude: 6 } ] - MapMouseArea { + MouseArea { anchors.fill: parent drag.target: parent SignalSpy { id: preMapPolygonClicked; target: parent; signalName: "clicked" } diff --git a/tests/auto/declarative_ui/tst_map_mouse.qml b/tests/auto/declarative_ui/tst_map_mouse.qml index 7787d462..d059bcfb 100644 --- a/tests/auto/declarative_ui/tst_map_mouse.qml +++ b/tests/auto/declarative_ui/tst_map_mouse.qml @@ -46,7 +46,7 @@ import QtPositioning 5.2 import QtLocation.test 5.0 /* - MapMouseArea setup for this test case. + MouseArea setup for this test case. Map dimensions are 100 * 100 Item containing map is 120,120 @@ -117,7 +117,7 @@ Item { lastWheelAngleDeltaY = angleDelta.y; } - MapMouseArea { + MouseArea { id: mouseUpper objectName: "mouseUpper" x: 0; y: 20; width: 100; height: 29 @@ -137,7 +137,7 @@ Item { onPositionChanged: { page.setMouseData(mouseUpper, mouse); } onPressAndHold: { page.setMouseData(mouseUpper, mouse); } } - MapMouseArea { + MouseArea { id: mouseLower objectName: "mouseLower" x: 0; y: 50; width: 100; height: 50 @@ -156,7 +156,7 @@ Item { onPositionChanged: { page.setMouseData(mouseLower, mouse); } onPressAndHold: { page.setMouseData(mouseLower, mouse); } } - MapMouseArea { + MouseArea { id: mouseOverlapper objectName: "mouseOverlapper" x: 50; y: 0; width: 50; height: 100 @@ -178,7 +178,7 @@ Item { } TestCase { - name: "MapMouseArea" + name: "MouseArea" when: windowShown SignalSpy {id: mouseUpperClickedSpy; target: mouseUpper; signalName: "clicked"} SignalSpy {id: mouseLowerClickedSpy; target: mouseLower; signalName: "clicked"} |