diff options
author | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2009-11-04 13:02:41 (GMT) |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2009-11-04 13:02:41 (GMT) |
commit | 94b595f37b3a49d44d1a795e5f2b003ac921d4b7 (patch) | |
tree | 74009d7bd395e7bd39076875914c5f1353a30902 /tests/manual/gestures/graphicsview | |
parent | 3c3db55c205012de15bab758b3bb4857d132cb98 (diff) | |
parent | 51c9b68425c1d3fe64a08e6ef0357fbd6bdd8f8a (diff) | |
download | Qt-94b595f37b3a49d44d1a795e5f2b003ac921d4b7.zip Qt-94b595f37b3a49d44d1a795e5f2b003ac921d4b7.tar.gz Qt-94b595f37b3a49d44d1a795e5f2b003ac921d4b7.tar.bz2 |
Merge commit '51c9b68' into 4.6
Conflicts:
dist/changes-4.6.0
src/gui/kernel/qevent.h
Diffstat (limited to 'tests/manual/gestures/graphicsview')
5 files changed, 33 insertions, 38 deletions
diff --git a/tests/manual/gestures/graphicsview/gestures.cpp b/tests/manual/gestures/graphicsview/gestures.cpp index 5416457..4c21712 100644 --- a/tests/manual/gestures/graphicsview/gestures.cpp +++ b/tests/manual/gestures/graphicsview/gestures.cpp @@ -45,41 +45,41 @@ Qt::GestureType ThreeFingerSlideGesture::Type = Qt::CustomGesture; -QGesture *ThreeFingerSlideGestureRecognizer::createGesture(QObject *) +QGesture *ThreeFingerSlideGestureRecognizer::create(QObject *) { return new ThreeFingerSlideGesture; } -QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) +QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event) { ThreeFingerSlideGesture *d = static_cast<ThreeFingerSlideGesture *>(state); QGestureRecognizer::Result result; switch (event->type()) { case QEvent::TouchBegin: - result = QGestureRecognizer::MaybeGesture; + result = QGestureRecognizer::MayBeGesture; case QEvent::TouchEnd: if (d->gestureFired) - result = QGestureRecognizer::GestureFinished; + result = QGestureRecognizer::FinishGesture; else - result = QGestureRecognizer::NotGesture; + result = QGestureRecognizer::CancelGesture; case QEvent::TouchUpdate: if (d->state() != Qt::NoGesture) { QTouchEvent *ev = static_cast<QTouchEvent*>(event); if (ev->touchPoints().size() == 3) { d->gestureFired = true; - result = QGestureRecognizer::GestureTriggered; + result = QGestureRecognizer::TriggerGesture; } else { - result = QGestureRecognizer::MaybeGesture; + result = QGestureRecognizer::MayBeGesture; for (int i = 0; i < ev->touchPoints().size(); ++i) { const QTouchEvent::TouchPoint &pt = ev->touchPoints().at(i); const int distance = (pt.pos().toPoint() - pt.startPos().toPoint()).manhattanLength(); if (distance > 20) { - result = QGestureRecognizer::NotGesture; + result = QGestureRecognizer::CancelGesture; } } } } else { - result = QGestureRecognizer::NotGesture; + result = QGestureRecognizer::CancelGesture; } break; @@ -89,7 +89,7 @@ QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::filterEvent(QGestu if (d->state() != Qt::NoGesture) result = QGestureRecognizer::Ignore; else - result = QGestureRecognizer::NotGesture; + result = QGestureRecognizer::CancelGesture; break; default: result = QGestureRecognizer::Ignore; @@ -105,12 +105,12 @@ void ThreeFingerSlideGestureRecognizer::reset(QGesture *state) } -QGesture *RotateGestureRecognizer::createGesture(QObject *) +QGesture *RotateGestureRecognizer::create(QObject *) { return new QGesture; } -QGestureRecognizer::Result RotateGestureRecognizer::filterEvent(QGesture *, QObject *, QEvent *event) +QGestureRecognizer::Result RotateGestureRecognizer::recognize(QGesture *, QObject *, QEvent *event) { switch (event->type()) { case QEvent::TouchBegin: diff --git a/tests/manual/gestures/graphicsview/gestures.h b/tests/manual/gestures/graphicsview/gestures.h index 6140b12..8a31b71 100644 --- a/tests/manual/gestures/graphicsview/gestures.h +++ b/tests/manual/gestures/graphicsview/gestures.h @@ -59,8 +59,8 @@ public: class ThreeFingerSlideGestureRecognizer : public QGestureRecognizer { private: - QGesture* createGesture(QObject *target); - QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); + QGesture *create(QObject *target); + QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); }; @@ -70,8 +70,8 @@ public: RotateGestureRecognizer(); private: - QGesture* createGesture(QObject *target); - QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); + QGesture *create(QObject *target); + QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); }; diff --git a/tests/manual/gestures/graphicsview/main.cpp b/tests/manual/gestures/graphicsview/main.cpp index de92afe..f8433b5 100644 --- a/tests/manual/gestures/graphicsview/main.cpp +++ b/tests/manual/gestures/graphicsview/main.cpp @@ -66,11 +66,11 @@ protected: default: qDebug("view: Pan: <unknown state>"); break; } - const QPointF offset = pan->offset(); + const QPointF delta = pan->delta(); QScrollBar *vbar = verticalScrollBar(); QScrollBar *hbar = horizontalScrollBar(); - vbar->setValue(vbar->value() - offset.y()); - hbar->setValue(hbar->value() - offset.x()); + vbar->setValue(vbar->value() - delta.y()); + hbar->setValue(hbar->value() - delta.x()); ge->accept(pan); return true; } @@ -152,8 +152,8 @@ private: MainWindow::MainWindow() { - (void)QApplication::registerGestureRecognizer(new MousePanGestureRecognizer); - ThreeFingerSlideGesture::Type = QApplication::registerGestureRecognizer(new ThreeFingerSlideGestureRecognizer); + (void)QGestureRecognizer::registerRecognizer(new MousePanGestureRecognizer); + ThreeFingerSlideGesture::Type = QGestureRecognizer::registerRecognizer(new ThreeFingerSlideGestureRecognizer); tabWidget = new QTabWidget; diff --git a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp index 6cdbe12..82adfbd 100644 --- a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp +++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp @@ -51,12 +51,12 @@ MousePanGestureRecognizer::MousePanGestureRecognizer() { } -QGesture* MousePanGestureRecognizer::createGesture(QObject *) +QGesture* MousePanGestureRecognizer::create(QObject *) { return new QPanGesture; } -QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) +QGestureRecognizer::Result MousePanGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event) { QPanGesture *g = static_cast<QPanGesture *>(state); QPoint globalPos; @@ -78,23 +78,19 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick || event->type() == QEvent::GraphicsSceneMousePress || event->type() == QEvent::GraphicsSceneMouseDoubleClick) { g->setHotSpot(globalPos); - g->setProperty("lastPos", globalPos); + g->setProperty("startPos", globalPos); g->setProperty("pressed", QVariant::fromValue<bool>(true)); - return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; + return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; } else if (event->type() == QEvent::MouseMove || event->type() == QEvent::GraphicsSceneMouseMove) { if (g->property("pressed").toBool()) { - QPoint pos = globalPos; - QPoint lastPos = g->property("lastPos").toPoint(); + QPoint offset = globalPos - g->property("startPos").toPoint(); g->setLastOffset(g->offset()); - lastPos = pos - lastPos; - g->setOffset(QPointF(lastPos.x(), lastPos.y())); - g->setTotalOffset(g->totalOffset() + QPointF(lastPos.x(), lastPos.y())); - g->setProperty("lastPos", pos); - return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; + g->setOffset(QPointF(offset.x(), offset.y())); + return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; } - return QGestureRecognizer::NotGesture; + return QGestureRecognizer::CancelGesture; } else if (event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::GraphicsSceneMouseRelease) { - return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint; + return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint; } return QGestureRecognizer::Ignore; } @@ -102,11 +98,10 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat void MousePanGestureRecognizer::reset(QGesture *state) { QPanGesture *g = static_cast<QPanGesture *>(state); - g->setTotalOffset(QPointF()); g->setLastOffset(QPointF()); g->setOffset(QPointF()); g->setAcceleration(0); - g->setProperty("lastPos", QVariant()); + g->setProperty("startPos", QVariant()); g->setProperty("pressed", QVariant::fromValue<bool>(false)); QGestureRecognizer::reset(state); } diff --git a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h index b062fd0..6e04621 100644 --- a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h +++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h @@ -49,8 +49,8 @@ class MousePanGestureRecognizer : public QGestureRecognizer public: MousePanGestureRecognizer(); - QGesture* createGesture(QObject *target); - QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); + QGesture* create(QObject *target); + QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); }; |