diff options
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r-- | src/gui/kernel/qevent.cpp | 87 |
1 files changed, 42 insertions, 45 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index fa289bbf8b..e11c4671e6 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -45,7 +45,6 @@ #include "qpa/qplatformintegration.h" #include "qpa/qplatformdrag.h" #include "private/qevent_p.h" -#include "private/qkeysequence_p.h" #include "qdebug.h" #include "qmimedata.h" #include "private/qdnd_p.h" @@ -654,6 +653,9 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the direction. + The phase() is initialized to Qt::ScrollUpdate. Use the other constructor + to specify the phase explicitly. + \sa posF(), globalPosF(), angleDelta(), pixelDelta() */ @@ -661,9 +663,38 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), - angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons) + angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(Qt::ScrollUpdate) {} +/*! + Constructs a wheel event object. + + The \a pos provides the location of the mouse cursor + within the window. The position in global coordinates is specified + by \a globalPos. + + \a pixelDelta contains the scrolling distance in pixels on screen, while + \a angleDelta contains the wheel rotation distance. \a pixelDelta is + optional and can be null. + + The mouse and keyboard states at the time of the event are specified by + \a buttons and \a modifiers. + + For backwards compatibility, the event can also hold monodirectional wheel + event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the + direction. + + The scrolling phase of the event is specified by \a phase. + + \sa posF(), globalPosF(), angleDelta(), pixelDelta(), phase() +*/ + +QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, + QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, + Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase) + : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), + angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(phase) +{} #endif // QT_NO_WHEELEVENT @@ -794,6 +825,13 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, \sa posF() */ +/*! + \fn Qt::ScrollPhase QWheelEvent::phase() const + \since 5.2 + + Returns the scrolling phase of this wheel event. +*/ + /*! \class QKeyEvent @@ -997,50 +1035,9 @@ bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const { //The keypad and group switch modifier should not make a difference uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier | Qt::GroupSwitchModifier); - const uint platform = QKeySequencePrivate::currentKeyPlatforms(); - - uint N = QKeySequencePrivate::numberOfKeyBindings; - int first = 0; - int last = N - 1; - while (first <= last) { - int mid = (first + last) / 2; - QKeyBinding midVal = QKeySequencePrivate::keyBindings[mid]; - - if (searchkey > midVal.shortcut){ - first = mid + 1; // Search in top half - } - else if (searchkey < midVal.shortcut){ - last = mid - 1; // Search in bottom half - } - else { - //found correct shortcut value, now we must check for platform match - if ((midVal.platform & platform) && (midVal.standardKey == matchKey)) { - return true; - } else { //We may have several equal values for different platforms, so we must search in both directions - - //search forward - for ( unsigned int i = mid + 1 ; i < N - 1 ; ++i) { - QKeyBinding current = QKeySequencePrivate::keyBindings[i]; - if (current.shortcut != searchkey) - break; - else if (current.platform & platform && current.standardKey == matchKey) - return true; - } - - //search back - for ( int i = mid - 1 ; i >= 0 ; --i) { - QKeyBinding current = QKeySequencePrivate::keyBindings[i]; - if (current.shortcut != searchkey) - break; - else if (current.platform & platform && current.standardKey == matchKey) - return true; - } - return false; //we could not find it among the matching keySequences - } - } - } - return false; //we could not find matching keySequences at all + const QList<QKeySequence> bindings = QKeySequence::keyBindings(matchKey); + return bindings.contains(QKeySequence(searchkey)); } #endif // QT_NO_SHORTCUT |