diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2013-08-10 15:19:27 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-15 10:02:36 +0200 |
commit | 751989df5cc441dcffbbbe2da0c3c0558701d5c6 (patch) | |
tree | faaed4ab993c54924da0be15ec7c090c0041ab18 /src | |
parent | 8e13a9792afcaf1be901ac00418b30372e818fde (diff) |
Replace QWheelEvent::Phase with revised Qt::ScrollPhase
Change-Id: I4d8e7d48497d0d96a297191976c0d99feb67b538
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/global/qnamespace.h | 7 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.qdoc | 15 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 27 | ||||
-rw-r--r-- | src/gui/kernel/qevent.h | 6 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.h | 5 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_p.h | 4 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 8 | ||||
-rw-r--r-- | src/widgets/widgets/qscrollbar.cpp | 4 |
9 files changed, 44 insertions, 40 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index e714839f26..9b63166474 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -95,6 +95,7 @@ Qt { #endif Q_ENUMS(CursorMoveStyle) Q_ENUMS(TimerType) + Q_ENUMS(ScrollPhase) #endif // defined(Q_MOC_RUN) #if defined(Q_MOC_RUN) @@ -1569,6 +1570,12 @@ public: CoarseTimer, VeryCoarseTimer }; + + enum ScrollPhase { + ScrollBegin = 1, + ScrollUpdate, + ScrollEnd + }; } #ifdef Q_MOC_RUN ; diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 4a5285fa5d..22e48e9796 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2878,3 +2878,18 @@ nearest full second (e.g. an interval of 23500ms will be rounded to 24000ms, and 20300ms to 20000ms). */ + +/*! + \enum Qt::ScrollPhase + \since 5.2 + + This enum describes the phase of scrolling. + + \value ScrollBegin Scrolling is about to begin, but the scrolling + distance did not yet change. + + \value ScrollUpdate The scrolling distance has changed (default). + + \value ScrollEnd Scrolling has ended, but the scrolling distance + did not change anymore. +*/ diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 49cc411c4f..96fbc42f72 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -654,7 +654,7 @@ 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 QWheelEvent::Changed. Use the other constructor + The phase() is initialized to Qt::ScrollUpdate. Use the other constructor to specify the phase explicitly. \sa posF(), globalPosF(), angleDelta(), pixelDelta() @@ -664,7 +664,7 @@ 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), ph(Changed) + angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(Qt::ScrollUpdate) {} /*! @@ -685,14 +685,14 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the direction. - The phase of the event is specified by \a phase. + 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, Phase phase) + 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) {} @@ -827,25 +827,10 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, */ /*! - \enum QWheelEvent::Phase + \fn Qt::ScrollPhase QWheelEvent::phase() const \since 5.2 - This enum describes the phase of a wheel event. - - \value Started Scrolling has started, but the scrolling - distance did not yet change. - - \value Changed The scrolling distance has changed (default). - - \value Ended Scrolling has ended, but the scrolling distance - did not change anymore. -*/ - -/*! - \fn QWheelEvent::Phase QWheelEvent::phase() const - \since 5.2 - - Returns the phase of this wheel event. + Returns the scrolling phase of this wheel event. */ diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 2de88cf010..0c1cf70420 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -167,8 +167,6 @@ protected: class Q_GUI_EXPORT QWheelEvent : public QInputEvent { public: - enum Phase { Started, Changed, Ended }; - QWheelEvent(const QPointF &pos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient = Qt::Vertical); @@ -180,7 +178,7 @@ public: Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, - Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Phase phase); + Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase); ~QWheelEvent(); @@ -204,7 +202,7 @@ public: inline Qt::MouseButtons buttons() const { return mouseState; } - inline Phase phase() const { return Phase(ph); } + inline Qt::ScrollPhase phase() const { return Qt::ScrollPhase(ph); } protected: QPointF p; diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index b094ccb33b..7b57313645 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -298,13 +298,13 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, con handleWheelEvent(tlw, timestamp, local, global, QPoint(), point, mods); } -void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, QWheelEvent::Phase phase) +void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase) { unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); handleWheelEvent(w, time, local, global, pixelDelta, angleDelta, mods, phase); } -void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, QWheelEvent::Phase phase) +void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase) { // Qt 4 sends two separate wheel events for horizontal and vertical // deltas. For Qt 5 we want to send the deltas in one event, but at the @@ -315,9 +315,9 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, con // Angle deltas must always be sent in addition to pixel deltas. QWindowSystemInterfacePrivate::WheelEvent *e; - // Pass QWheelEvent::Started and QWheelEvent::Ended through + // Pass Qt::ScrollBegin and Qt::ScrollEnd through // even if the wheel delta is null. - if (angleDelta.isNull() && phase == QWheelEvent::Changed) + if (angleDelta.isNull() && phase == Qt::ScrollUpdate) return; // Simple case: vertical deltas only: diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index f9efdbf8ce..cac943cda1 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -61,7 +61,6 @@ #include <QtGui/QTouchEvent> #include <QtCore/QEventLoop> #include <QtGui/QVector2D> -#include <QtGui/QWheelEvent> QT_BEGIN_NAMESPACE @@ -104,8 +103,8 @@ public: quint32 nativeModifiers, const QString& text = QString(), bool autorep = false, ushort count = 1); - static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier, QWheelEvent::Phase phase = QWheelEvent::Changed); - static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier, QWheelEvent::Phase phase = QWheelEvent::Changed); + static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier, Qt::ScrollPhase phase = Qt::ScrollUpdate); + static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier, Qt::ScrollPhase phase = Qt::ScrollUpdate); // Wheel event compatibility functions. Will be removed: do not use. static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier); diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 7dbc3ad8ed..46479701cc 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -218,7 +218,7 @@ public: class WheelEvent : public InputEvent { public: WheelEvent(QWindow *w, ulong time, const QPointF & local, const QPointF & global, QPoint pixelD, QPoint angleD, int qt4D, Qt::Orientation qt4O, - Qt::KeyboardModifiers mods, QWheelEvent::Phase phase = QWheelEvent::Changed) + Qt::KeyboardModifiers mods, Qt::ScrollPhase phase = Qt::ScrollUpdate) : InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D), qt4Orientation(qt4O), localPos(local), globalPos(global), phase(phase) { } QPoint pixelDelta; QPoint angleDelta; @@ -226,7 +226,7 @@ public: Qt::Orientation qt4Orientation; QPointF localPos; QPointF globalPos; - QWheelEvent::Phase phase; + Qt::ScrollPhase phase; }; class KeyEvent : public InputEvent { diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index aaff86c450..2d3c2f0fad 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -880,20 +880,20 @@ static QTouchDevice *touchDevice = 0; currentWheelModifiers = [QNSView convertKeyModifiers:[theEvent modifierFlags]]; } - QWheelEvent::Phase ph = QWheelEvent::Changed; + Qt::ScrollPhase ph = Qt::ScrollUpdate; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8 if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) { // On 10.8 and above, MayBegin is likely to happen. We treat it the same as an actual begin. if (phase == NSEventPhaseMayBegin) - ph = QWheelEvent::Started; + ph = Qt::ScrollBegin; } else #endif if (phase == NSEventPhaseBegan) { // On 10.7, MayBegin will not happen, so Began is the actual beginning. - ph = QWheelEvent::Started; + ph = Qt::ScrollBegin; } if (phase == NSEventPhaseEnded || phase == NSEventPhaseCancelled) { - ph = QWheelEvent::Ended; + ph = Qt::ScrollEnd; } QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph); diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp index 4ed91204cd..05b8935bb5 100644 --- a/src/widgets/widgets/qscrollbar.cpp +++ b/src/widgets/widgets/qscrollbar.cpp @@ -511,9 +511,9 @@ void QScrollBar::wheelEvent(QWheelEvent *event) if (d->scrollByDelta(event->orientation(), event->modifiers(), delta)) event->accept(); - if (event->phase() == QWheelEvent::Started) + if (event->phase() == Qt::ScrollBegin) d->setTransient(false); - else if (event->phase() == QWheelEvent::Ended) + else if (event->phase() == Qt::ScrollEnd) d->setTransient(true); } #endif |