diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-10-21 14:33:11 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-10-22 14:59:20 (GMT) |
commit | 6c7d3f73e361c460ad5523f1d9c9d9d6ebc81299 (patch) | |
tree | c471d9823bc5b2dde0c5ab468ded3b3231917a74 /tests | |
parent | 9cf2b77328fce9b7663876966112af6ed374df5b (diff) | |
download | Qt-6c7d3f73e361c460ad5523f1d9c9d9d6ebc81299.zip Qt-6c7d3f73e361c460ad5523f1d9c9d9d6ebc81299.tar.gz Qt-6c7d3f73e361c460ad5523f1d9c9d9d6ebc81299.tar.bz2 |
Fixed the gestures/graphicsview manualtest
Diffstat (limited to 'tests')
-rw-r--r-- | tests/manual/gestures/graphicsview/main.cpp | 2 | ||||
-rw-r--r-- | tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp | 25 |
2 files changed, 23 insertions, 4 deletions
diff --git a/tests/manual/gestures/graphicsview/main.cpp b/tests/manual/gestures/graphicsview/main.cpp index 263a963..b4d74e4 100644 --- a/tests/manual/gestures/graphicsview/main.cpp +++ b/tests/manual/gestures/graphicsview/main.cpp @@ -126,6 +126,8 @@ public: scene = new QGraphicsScene(this); scene->setSceneRect(-2000, -2000, 4000, 4000); view = new QGraphicsView(scene, 0); + view->viewport()->grabGesture(Qt::PanGesture); + view->viewport()->grabGesture(ThreeFingerSlideGesture::Type); QVBoxLayout *l = new QVBoxLayout(this); l->addWidget(view); } diff --git a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp index 0e7f538..acd525f 100644 --- a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp +++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp @@ -42,6 +42,8 @@ #include "mousepangesturerecognizer.h" #include <QEvent> +#include <QVariant> +#include <QGraphicsSceneMouseEvent> #include <QMouseEvent> #include <QGesture> @@ -57,16 +59,31 @@ QGesture* MousePanGestureRecognizer::createGesture(QObject *) QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) { QPanGesture *g = static_cast<QPanGesture *>(state); - QMouseEvent *me = static_cast<QMouseEvent *>(event); + QPoint globalPos; + switch (event->type()) { + case QEvent::GraphicsSceneMousePress: + case QEvent::GraphicsSceneMouseDoubleClick: + case QEvent::GraphicsSceneMouseMove: + case QEvent::GraphicsSceneMouseRelease: + globalPos = static_cast<QGraphicsSceneMouseEvent *>(event)->screenPos(); + break; + case QEvent::MouseButtonPress: + case QEvent::MouseMove: + case QEvent::MouseButtonRelease: + globalPos = static_cast<QMouseEvent *>(event)->globalPos(); + break; + default: + break; + } if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick || event->type() == QEvent::GraphicsSceneMousePress || event->type() == QEvent::GraphicsSceneMouseDoubleClick) { - g->setHotSpot(me->globalPos()); - g->setProperty("lastPos", me->globalPos()); + g->setHotSpot(globalPos); + g->setProperty("lastPos", globalPos); g->setProperty("pressed", QVariant::fromValue<bool>(true)); return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; } else if (event->type() == QEvent::MouseMove || event->type() == QEvent::GraphicsSceneMouseMove) { if (g->property("pressed").toBool()) { - QPoint pos = me->globalPos(); + QPoint pos = globalPos; QPoint lastPos = g->property("lastPos").toPoint(); g->setLastOffset(g->offset()); lastPos = pos - lastPos; |