Replace QWheelEvent::Phase with revised Qt::ScrollPhase

Change-Id: I4d8e7d48497d0d96a297191976c0d99feb67b538
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
bb10
J-P Nurmi 2013-08-10 15:19:27 +02:00 committed by The Qt Project
parent 8e13a9792a
commit 751989df5c
9 changed files with 44 additions and 40 deletions

View File

@ -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
;

View File

@ -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.
*/

View File

@ -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.
*/

View File

@ -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;

View File

@ -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:

View File

@ -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);

View File

@ -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 {

View File

@ -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);

View File

@ -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