diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-05-08 16:46:44 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-05-11 14:52:04 (GMT) |
commit | 81a64345258f2f2ad5cf77355f7ecbd3ebad9734 (patch) | |
tree | 6fa024d2cadedae9ecd4e1718f704281112a78b5 /src/gui/kernel/qevent.cpp | |
parent | 0edf9fc7ede35995ec37197b5fb5ef92a4ccf60f (diff) | |
download | Qt-81a64345258f2f2ad5cf77355f7ecbd3ebad9734.zip Qt-81a64345258f2f2ad5cf77355f7ecbd3ebad9734.tar.gz Qt-81a64345258f2f2ad5cf77355f7ecbd3ebad9734.tar.bz2 |
Improved gesture propagation.
Each gesture can now be accepted separately and not accepted gestures
will be propagated to parent widget that are subscribed to them.
Added an internal flag to specify that gesture is a "singleshot" - aka
if the gesture is not continious and will not have a GestureStarted
state, but only GestureFinished.
Asynchronous gestures still need to fixed, as well as QGraphicsView.
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r-- | src/gui/kernel/qevent.cpp | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f24f186..fa85bf2 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3532,10 +3532,11 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar) are being executed and a list of gesture that were cancelled (\a cancelledGestures). */ -QGestureEvent::QGestureEvent(const QList<QGesture*> &gestures, +QGestureEvent::QGestureEvent(const QSet<QGesture*> &gestures, const QSet<QString> &cancelledGestures) : QEvent(QEvent::Gesture), m_cancelledGestures(cancelledGestures) { + setAccepted(false); foreach(QGesture *r, gestures) m_gestures.insert(r->type(), r); } @@ -3606,6 +3607,54 @@ QSet<QString> QGestureEvent::cancelledGestures() const return m_cancelledGestures; } +/*! + Sets the accept flag of the all gestures inside the event object, + the equivalent of calling \l{QEvent::accept()}{accept()} or + \l{QEvent::setAccepted()}{setAccepted(true)}. + + Setting the accept parameter indicates that the event receiver + wants the gesture. Unwanted gestures might be propagated to the parent + widget. +*/ +void QGestureEvent::acceptAll() +{ + QHash<QString, QGesture*>::iterator it = m_gestures.begin(), + e = m_gestures.end(); + for(; it != e; ++it) + it.value()->accept(); + setAccepted(true); +} + +/*! + Sets the accept flag of the specified gesture inside the event + object, the equivalent of calling + \l{QGestureEvent::gesture()}{gesture(type)}->\l{QGesture::accept()}{accept()} + + Setting the accept parameter indicates that the event receiver + wants the gesture. Unwanted gestures might be propagated to the parent + widget. +*/ +void QGestureEvent::accept(Qt::GestureType type) +{ + if (QGesture *g = m_gestures.value(qt_getStandardGestureTypeName(type), 0)) + g->accept(); +} + +/*! + Sets the accept flag of the specified gesture inside the event + object, the equivalent of calling + \l{QGestureEvent::gesture()}{gesture(type)}->\l{QGesture::accept()}{accept()} + + Setting the accept parameter indicates that the event receiver + wants the gesture. Unwanted gestures might be propagated to the parent + widget. +*/ +void QGestureEvent::accept(const QString &type) +{ + if (QGesture *g = m_gestures.value(type, 0)) + g->accept(); +} + /*! \class QTouchEvent \brief The QTouchEvent class contains parameters that describe a touch event . |