summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-10-08 02:55:21 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-10-08 02:55:21 (GMT)
commit10f0cc708b8e7fc2206d1a141dfd4122e7a6f4b0 (patch)
tree73af4a373836368cebbb6c672f056929a403ce4d /src
parent2c92730ad20aac6f4c869eb152b2bb7f19655206 (diff)
downloadQt-10f0cc708b8e7fc2206d1a141dfd4122e7a6f4b0.zip
Qt-10f0cc708b8e7fc2206d1a141dfd4122e7a6f4b0.tar.gz
Qt-10f0cc708b8e7fc2206d1a141dfd4122e7a6f4b0.tar.bz2
Ensure that onRelease is called for doubleClick events.
Also ensures that the pressed property is updated appropriately and the double click and hold is possible. Task-number: QTBUG-14279 Reviewed-by: Michael Brasser
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp12
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p_p.h3
2 files changed, 8 insertions, 7 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index a0208ef..1533d55 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -557,6 +557,7 @@ void QDeclarativeMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
ungrabMouse();
setKeepMouseGrab(false);
}
+ d->doubleClick = false;
}
void QDeclarativeMouseArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
@@ -565,14 +566,12 @@ void QDeclarativeMouseArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even
if (!d->absorb) {
QDeclarativeItem::mouseDoubleClickEvent(event);
} else {
+ d->doubleClick = true;
d->saveEvent(event);
QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false);
me.setAccepted(d->isDoubleClickConnected());
emit this->doubleClicked(&me);
- if (!me.isAccepted()) {
- // Only deliver the press event if we haven't accepted the double click.
- QDeclarativeItem::mouseDoubleClickEvent(event);
- }
+ QDeclarativeItem::mouseDoubleClickEvent(event);
}
}
@@ -841,7 +840,8 @@ bool QDeclarativeMouseArea::setPressed(bool p)
d->pressed = p;
QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, isclick, d->longPress);
if (d->pressed) {
- emit pressed(&me);
+ if (!d->doubleClick)
+ emit pressed(&me);
me.setX(d->lastPos.x());
me.setY(d->lastPos.y());
emit mousePositionChanged(&me);
@@ -849,7 +849,7 @@ bool QDeclarativeMouseArea::setPressed(bool p)
emit released(&me);
me.setX(d->lastPos.x());
me.setY(d->lastPos.y());
- if (isclick && !d->longPress)
+ if (isclick && !d->longPress && !d->doubleClick)
emit clicked(&me);
}
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
index 48a56d9..06a01d3 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
@@ -68,7 +68,7 @@ class QDeclarativeMouseAreaPrivate : public QDeclarativeItemPrivate
public:
QDeclarativeMouseAreaPrivate()
: absorb(true), hovered(false), pressed(false), longPress(false),
- moved(false), stealMouse(false), drag(0)
+ moved(false), stealMouse(false), doubleClick(false), drag(0)
{
}
@@ -109,6 +109,7 @@ public:
bool dragX : 1;
bool dragY : 1;
bool stealMouse : 1;
+ bool doubleClick : 1;
QDeclarativeDrag *drag;
QPointF startScene;
qreal startX;