diff options
author | Zeno Albisser <zeno.albisser@nokia.com> | 2010-09-08 04:32:27 -0400 |
---|---|---|
committer | Zeno Albisser <zeno.albisser@nokia.com> | 2010-09-08 10:14:17 -0400 |
commit | ea62344a43431aa8d243642b180d27b5e3db3b9a (patch) | |
tree | 2465dbdd96e18a31d2dfc181574872010766fc7b | |
parent | 36194e4951ce0b9e076e3da1c863fc10f6555a31 (diff) |
avoid using private headers in QTapGestureRecognizer and QTapAndHoldGestureRecognizer
Reviewed-by: Denis Dzyubenko
-rw-r--r-- | plugin.cpp | 4 | ||||
-rw-r--r-- | qdeclarativegesturerecognizers.cpp | 65 |
2 files changed, 33 insertions, 36 deletions
@@ -75,8 +75,8 @@ void GestureAreaQmlPlugin::registerTypes(const char *uri) QGestureRecognizer::unregisterRecognizer(Qt::PinchGesture); QGestureRecognizer::unregisterRecognizer(Qt::SwipeGesture); -// QGestureRecognizer::registerRecognizer(new QTapGestureRecognizer()); -// QGestureRecognizer::registerRecognizer(new QTapAndHoldGestureRecognizer()); + QGestureRecognizer::registerRecognizer(new QTapGestureRecognizer()); + QGestureRecognizer::registerRecognizer(new QTapAndHoldGestureRecognizer()); QGestureRecognizer::registerRecognizer(new QPanGestureRecognizer()); QGestureRecognizer::registerRecognizer(new QPinchGestureRecognizer()); // QGestureRecognizer::registerRecognizer(new QSwipeGestureRecognizer()); diff --git a/qdeclarativegesturerecognizers.cpp b/qdeclarativegesturerecognizers.cpp index 7297de8..a89bc0b 100644 --- a/qdeclarativegesturerecognizers.cpp +++ b/qdeclarativegesturerecognizers.cpp @@ -681,7 +681,7 @@ void QSwipeGestureRecognizer::reset(QGesture *state) QGestureRecognizer::reset(state); } - +*/ // // QTapGestureRecognizer // @@ -706,15 +706,15 @@ QGestureRecognizer::Result QTapGestureRecognizer::recognize(QGesture *state, QEvent *event) { QTapGesture *q = static_cast<QTapGesture *>(state); - QTapGesturePrivate *d = q->d_func(); QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture; switch (event->type()) { case QEvent::TouchBegin: { - d->gotTouched = true; + + q->setProperty("gotTouched", true); const QTouchEvent *ev = static_cast<const QTouchEvent *>(event); - d->position = ev->touchPoints().at(0).pos(); + q->setPosition(ev->touchPoints().at(0).pos()); q->setHotSpot(ev->touchPoints().at(0).screenPos()); result = QGestureRecognizer::TriggerGesture; break; @@ -737,7 +737,7 @@ QGestureRecognizer::Result QTapGestureRecognizer::recognize(QGesture *state, } case QEvent::MouseButtonPress: - if (!d->gotTouched) { + if (!q->property("gotTouched").toBool()) { QMouseEvent *ev = static_cast<QMouseEvent *>(event); if (!(ev->modifiers() & Qt::ControlModifier)) { state->setProperty("position", ev->globalPos()); @@ -753,7 +753,7 @@ QGestureRecognizer::Result QTapGestureRecognizer::recognize(QGesture *state, return QGestureRecognizer::Ignore; case QEvent::MouseButtonRelease: - if (!d->gotTouched) { + if (!q->property("gotTouched").toBool()) { if (state->state() == Qt::GestureStarted) { return QGestureRecognizer::FinishGesture; } @@ -782,9 +782,7 @@ void QTapGestureRecognizer::reset(QGesture *state) if (!state) return; QTapGesture *q = static_cast<QTapGesture *>(state); - QTapGesturePrivate *d = q->d_func(); - - d->position = QPointF(); + q->setPosition(QPointF()); QGestureRecognizer::reset(state); } @@ -813,11 +811,10 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, QEvent *event) { QTapAndHoldGesture *q = static_cast<QTapAndHoldGesture *>(state); - QTapAndHoldGesturePrivate *d = q->d_func(); if (object == state && event->type() == QEvent::Timer) { - q->killTimer(d->timerId); - d->timerId = 0; + q->killTimer(q->property("timerId").toInt()); + q->setProperty("timerId",0); return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint; } @@ -832,26 +829,26 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, switch (event->type()) { #ifndef QT_NO_GRAPHICSVIEW case QEvent::MouseButtonPress: - d->position = gsme->globalPos(); - q->setHotSpot(d->position); - if (d->timerId) - q->killTimer(d->timerId); - d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); + q->setPosition(gsme->globalPos()); + q->setHotSpot(q->position()); + if (q->property("timerId").toInt()) + q->killTimer(q->property("timerId").toInt()); + q->setProperty("timerId",q->startTimer(q->timeout())); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout #endif // case QEvent::MouseButtonPress: // d->position = me->globalPos(); // q->setHotSpot(d->position); -// if (d->timerId) -// q->killTimer(d->timerId); -// d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); +// if (q->property("timerId").toInt()) +// q->killTimer(q->property("timerId").toInt()); +// q->setProperty("timerId",q->startTimer(QTapAndHoldGesturePrivate::Timeout)); // return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout case QEvent::TouchBegin: - d->position = ev->touchPoints().at(0).startScreenPos(); - q->setHotSpot(d->position); - if (d->timerId) - q->killTimer(d->timerId); - d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); + q->setPosition(ev->touchPoints().at(0).startScreenPos()); + q->setHotSpot(q->position()); + if (q->property("timerId").toInt()) + q->killTimer(q->property("timerId").toInt()); + q->setProperty("timerId",q->startTimer(q->timeout())); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout #ifndef QT_NO_GRAPHICSVIEW case QEvent::MouseButtonRelease: @@ -860,7 +857,7 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, case QEvent::TouchEnd: return QGestureRecognizer::CancelGesture; // get out of the MayBeGesture state case QEvent::TouchUpdate: - if (d->timerId && ev->touchPoints().size() == 1) { + if (q->property("timerId").toInt() && ev->touchPoints().size() == 1) { QTouchEvent::TouchPoint p = ev->touchPoints().at(0); QPoint delta = p.pos().toPoint() - p.startPos().toPoint(); if (delta.manhattanLength() <= TapRadius) @@ -869,14 +866,14 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, return QGestureRecognizer::CancelGesture; // case QEvent::MouseMove: { // QPoint delta = me->globalPos() - d->position.toPoint(); -// if (d->timerId && delta.manhattanLength() <= TapRadius) +// if (q->property("timerId").toInt() && delta.manhattanLength() <= TapRadius) // return QGestureRecognizer::MayBeGesture; // return QGestureRecognizer::CancelGesture; // } #ifndef QT_NO_GRAPHICSVIEW case QEvent::MouseMove: { - QPoint delta = gsme->globalPos() - d->position.toPoint(); - if (d->timerId && delta.manhattanLength() <= TapRadius) + QPoint delta = gsme->globalPos() - q->position().toPoint(); + if (q->property("timerId").toInt() && delta.manhattanLength() <= TapRadius) return QGestureRecognizer::MayBeGesture; return QGestureRecognizer::CancelGesture; } @@ -893,13 +890,13 @@ void QTapAndHoldGestureRecognizer::reset(QGesture *state) QTapAndHoldGesture *q = static_cast<QTapAndHoldGesture *>(state); QTapAndHoldGesturePrivate *d = q->d_func(); - d->position = QPointF(); - if (d->timerId) - q->killTimer(d->timerId); - d->timerId = 0; + q->setPosition(QPointF()); + if (q->property("timerId").toInt()) + q->killTimer(q->property("timerId").toInt()); + q->setProperty("timerId",0); QGestureRecognizer::reset(state); -}*/ +} QT_END_NAMESPACE |