summaryrefslogtreecommitdiff
path: root/src/declarative
diff options
context:
space:
mode:
authorAlberto Mardegan <info@mardy.it>2012-07-05 17:56:51 +0400
committerQt by Nokia <qt-info@nokia.com>2012-07-25 09:03:22 +0200
commitef4af1217af456dbddc3b5df4004378019a85404 (patch)
tree24db68526e6e58bfc07762aa2448dcfd1381d5ae /src/declarative
parentc13df9f2147e85e104ac105f975ef87914c908e9 (diff)
downloadqt4-tools-ef4af1217af456dbddc3b5df4004378019a85404.tar.gz
MouseArea: use current value of drag.axis
If the drag.axis is changed while a drag operation is in progress, put it into action immediately. This allows, for example, start a dragging operation out of an item in a scrollable ListView to anywhere on the screen. See the linked bug number for an example. Task-number: QTBUG-26440 Change-Id: I4ffa71c08b97a767aec7f69d19271000a2631327 Reviewed-by: Rick Stockton <rickstockton@reno-computerhelp.com> Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp17
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p_p.h2
2 files changed, 8 insertions, 11 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index c653893642..60d86bb092 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -483,10 +483,6 @@ void QDeclarativeMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event)
else {
d->longPress = false;
d->saveEvent(event);
- if (d->drag) {
- d->dragX = drag()->axis() & QDeclarativeDrag::XAxis;
- d->dragY = drag()->axis() & QDeclarativeDrag::YAxis;
- }
if (d->drag)
d->drag->setActive(false);
setHovered(true);
@@ -540,7 +536,10 @@ void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (keepMouseGrab() && d->stealMouse)
d->drag->setActive(true);
- if (d->dragX && d->drag->active()) {
+ bool dragX = drag()->axis() & QDeclarativeDrag::XAxis;
+ bool dragY = drag()->axis() & QDeclarativeDrag::YAxis;
+
+ if (dragX && d->drag->active()) {
qreal x = (curLocalPos.x() - startLocalPos.x()) + d->startX;
if (x < drag()->xmin())
x = drag()->xmin();
@@ -548,7 +547,7 @@ void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
x = drag()->xmax();
drag()->target()->setX(x);
}
- if (d->dragY && d->drag->active()) {
+ if (dragY && d->drag->active()) {
qreal y = (curLocalPos.y() - startLocalPos.y()) + d->startY;
if (y < drag()->ymin())
y = drag()->ymin();
@@ -558,9 +557,9 @@ void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
if (!keepMouseGrab()) {
- if ((!d->dragY && dy < dragThreshold && d->dragX && dx > dragThreshold)
- || (!d->dragX && dx < dragThreshold && d->dragY && dy > dragThreshold)
- || (d->dragX && d->dragY && (dx > dragThreshold || dy > dragThreshold))) {
+ if ((!dragY && dy < dragThreshold && dragX && dx > dragThreshold)
+ || (!dragX && dx < dragThreshold && dragY && dy > dragThreshold)
+ || (dragX && dragY && (dx > dragThreshold || dy > dragThreshold))) {
setKeepMouseGrab(true);
d->stealMouse = true;
}
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
index 00c6eed813..de3456597e 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
@@ -106,8 +106,6 @@ public:
bool pressed : 1;
bool longPress : 1;
bool moved : 1;
- bool dragX : 1;
- bool dragY : 1;
bool stealMouse : 1;
bool doubleClick : 1;
bool preventStealing : 1;