diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-05-07 12:52:00 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-05-18 12:44:06 (GMT) |
commit | dd59023394a8f4cdaf4be9f632d58434f52c76e4 (patch) | |
tree | 9b9ff6cbcb96014c962725ee4eff722b8c6e114a | |
parent | 4ec480ef000d60c2a177db29686b4aeb2511532f (diff) | |
download | Qt-dd59023394a8f4cdaf4be9f632d58434f52c76e4.zip Qt-dd59023394a8f4cdaf4be9f632d58434f52c76e4.tar.gz Qt-dd59023394a8f4cdaf4be9f632d58434f52c76e4.tar.bz2 |
Removed the "maybe" timer from gesturemanager.
According to users of the api "maybe" timer (that is supposed to cancel
gestures that have stayed in the "MaybeGesture" state for too long) is not
useful and might even harm some gestures, so removing it completely and leaving
it up to the author of a gesture recognizer to make sure the state machine is
implemented properly.
Task-number: QTBUG-9926
Reviewed-by: Thomas Zander
-rw-r--r-- | src/gui/kernel/qgesturemanager.cpp | 42 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager_p.h | 3 |
2 files changed, 7 insertions, 38 deletions
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 6fad18c..43facef 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -288,24 +288,14 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap<QObject *, // i.e. were canceled QSet<QGesture *> canceledGestures = m_activeGestures & notGestures; - // start timers for new gestures in maybe state - foreach (QGesture *state, newMaybeGestures) { - QBasicTimer &timer = m_maybeGestures[state]; - if (!timer.isActive()) - timer.start(3000, this); - } - // kill timers for gestures that were in maybe state + // new gestures in maybe state + m_maybeGestures += newMaybeGestures; + + // gestures that were in maybe state QSet<QGesture *> notMaybeGestures = (startedGestures | triggeredGestures | finishedGestures | canceledGestures | notGestures); - foreach(QGesture *gesture, notMaybeGestures) { - QHash<QGesture *, QBasicTimer>::iterator it = - m_maybeGestures.find(gesture); - if (it != m_maybeGestures.end()) { - it.value().stop(); - m_maybeGestures.erase(it); - } - } + m_maybeGestures -= notMaybeGestures; Q_ASSERT((startedGestures & finishedGestures).isEmpty()); Q_ASSERT((startedGestures & newMaybeGestures).isEmpty()); @@ -349,7 +339,7 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap<QObject *, !finishedGestures.isEmpty() || !canceledGestures.isEmpty()) { DEBUG() << "QGestureManager::filterEventThroughContexts:" << "\n\tactiveGestures:" << m_activeGestures - << "\n\tmaybeGestures:" << m_maybeGestures.keys() + << "\n\tmaybeGestures:" << m_maybeGestures << "\n\tstarted:" << startedGestures << "\n\ttriggered:" << triggeredGestures << "\n\tfinished:" << finishedGestures @@ -688,26 +678,6 @@ void QGestureManager::deliverEvents(const QSet<QGesture *> &gestures, } } -void QGestureManager::timerEvent(QTimerEvent *event) -{ - QHash<QGesture *, QBasicTimer>::iterator it = m_maybeGestures.begin(), - e = m_maybeGestures.end(); - for (; it != e; ) { - QBasicTimer &timer = it.value(); - Q_ASSERT(timer.isActive()); - if (timer.timerId() == event->timerId()) { - timer.stop(); - QGesture *gesture = it.key(); - it = m_maybeGestures.erase(it); - DEBUG() << "QGestureManager::timerEvent: gesture stopped due to timeout:" - << gesture; - recycle(gesture); - } else { - ++it; - } - } -} - void QGestureManager::recycle(QGesture *gesture) { QGestureRecognizer *recognizer = m_gestureToRecognizer.value(gesture, 0); diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index c105c9b..c452f49 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -85,7 +85,6 @@ public: void recycle(QGesture *gesture); protected: - void timerEvent(QTimerEvent *event); bool filterEventThroughContexts(const QMultiMap<QObject *, Qt::GestureType> &contexts, QEvent *event); @@ -93,7 +92,7 @@ private: QMultiMap<Qt::GestureType, QGestureRecognizer *> m_recognizers; QSet<QGesture *> m_activeGestures; - QHash<QGesture *, QBasicTimer> m_maybeGestures; + QSet<QGesture *> m_maybeGestures; enum State { Gesture, |