diff options
author | Zeno Albisser <zeno.albisser@nokia.com> | 2010-09-13 06:40:42 -0400 |
---|---|---|
committer | Zeno Albisser <zeno.albisser@nokia.com> | 2010-09-13 06:40:42 -0400 |
commit | 59c57c0e2994d0851006280a3df92b0408e224b9 (patch) | |
tree | 9a8b29fcc37be925cd7695ffb1917a40b637826a | |
parent | 43248255eaafe4f974409628cbaaff5966b3c109 (diff) |
use properties insteas of private data for various things
-rw-r--r-- | qdeclarativegesturerecognizers.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/qdeclarativegesturerecognizers.cpp b/qdeclarativegesturerecognizers.cpp index d82fbf5..d8486a0 100644 --- a/qdeclarativegesturerecognizers.cpp +++ b/qdeclarativegesturerecognizers.cpp @@ -157,7 +157,6 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, q->setProperty("startPosition", globalPos); q->setProperty("lastPos", globalPos); state->setHotSpot(globalPos); - state->setHandled(false); QElapsedTimer pressTime; pressTime.start(); @@ -182,8 +181,8 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, QPoint lastPos = q->property("lastPos").toPoint(); QElapsedTimer lastPosTime = q->property("lastPosTime").value<QElapsedTimer>(); - qreal xVelocity = q->horizontalVelocity(); - qreal yVelocity = q->verticalVelocity(); + qreal xVelocity = q->property("horizontalVelocity").toReal(); + qreal yVelocity = q->property("verticalVelocity").toReal(); qreal elapsed = qreal(lastPosTime.restart()) / 1000.; q->setProperty("lastPosTime", QVariant::fromValue(lastPosTime)); @@ -192,11 +191,11 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, int dx = ev->globalPos().x() - lastPos.x(); xVelocity += dx / elapsed; xVelocity /= 2; - q->setHorizontalVelocity(xVelocity); + q->setProperty("horizontalVelocity", xVelocity); int dy = ev->globalPos().y() - lastPos.y(); yVelocity += dy / elapsed; yVelocity /= 2; - q->setVerticalVelocity(yVelocity); + q->setProperty("verticalVelocity", yVelocity); q->setProperty("lastPos",ev->globalPos()); return QGestureRecognizer::TriggerGesture; @@ -212,8 +211,8 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, QMouseEvent *ev = static_cast<QMouseEvent *>(event); if (q->property("lastPosTime").value<QElapsedTimer>().elapsed() > 100) { // if we drag then pause before release we should not cause a flick. - q->setHorizontalVelocity(0); - q->setVerticalVelocity(0); + q->setProperty("horizontalVelocity", 0); + q->setProperty("verticalVelocity", 0); } else { // FlickThreshold determines how far the "mouse" must have moved // before we perform a flick. @@ -222,15 +221,15 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, // Really slow flicks can be annoying. static const int minimumFlickVelocity = 200; - qreal xVelocity = q->horizontalVelocity(); + qreal xVelocity = q->property("horizontalVelocity").toReal(); if (qAbs(xVelocity) > 10 && qAbs(ev->globalPos().x() - q->property("startPosition").toPoint().x()) > FlickThreshold) { if (qAbs(xVelocity) < minimumFlickVelocity) - q->setHorizontalVelocity(xVelocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity); + q->setProperty("horizontalVelocity", xVelocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity); } - qreal yVelocity = q->verticalVelocity(); + qreal yVelocity = q->property("verticalVelocity").toReal(); if (qAbs(yVelocity) > 10 && qAbs(ev->globalPos().y() - q->property("startPosition").toPoint().y()) > FlickThreshold) { if (qAbs(yVelocity) < minimumFlickVelocity) - q->setVerticalVelocity(yVelocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity); + q->setProperty("verticalVelocity", yVelocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity); } } if (!q->property("startPosition").toPoint().isNull() && !q->lastOffset().isNull()) { @@ -264,8 +263,8 @@ void QPanGestureRecognizer::reset(QGesture *state) lastPosTime.invalidate(); pan->setProperty("lastPosTime", QVariant::fromValue(lastPosTime)); pan->setProperty("lastPos",QPoint()); - pan->setHorizontalVelocity(0); - pan->setVerticalVelocity(0); + pan->setProperty("horizontalVelocity", 0); + pan->setProperty("verticalVelocity", 0); QGestureRecognizer::reset(state); } @@ -766,7 +765,6 @@ QGestureRecognizer::Result QTapGestureRecognizer::recognize(QGesture *state, if (!(ev->modifiers() & Qt::ControlModifier)) { state->setProperty("position", ev->globalPos()); state->setHotSpot(ev->globalPos()); - state->setHandled(false); event->accept(); return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; } |