summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent.cpp
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2012-02-29 09:18:59 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2012-02-29 09:23:14 +1000
commit98dd1781d9256f68025d2a2db408f4f5947f3214 (patch)
treedbe1424abd90014edb5546c920ca585ed62b46e3 /src/gui/kernel/qevent.cpp
parent6c1bdc1854a7700c2b3a345b95f6a2fdca84037d (diff)
parentfa1b9070af66edb81b2a3735c1951f78b22bd666 (diff)
Merge master -> api_changes
Includes fixes for tst_qfiledialog2, tst_qtextedit autotests on mac. Change-Id: I49cac26894d31291a8339ccc1eb80b6a940f0827
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r--src/gui/kernel/qevent.cpp78
1 files changed, 65 insertions, 13 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index c3a6be692b..281d4f61bc 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -453,7 +453,13 @@ QHoverEvent::~QHoverEvent()
Wheel events are sent to the widget under the mouse cursor, but
if that widget does not handle the event they are sent to the
- focus widget. The rotation distance is provided by delta().
+ focus widget. Wheel events are generated for both mouse wheels
+ and trackpad scroll gestures. There are two ways to read the
+ wheel event delta: angleDelta() returns the delta in wheel
+ degrees. This value is always provided. pixelDelta() returns
+ the delta in screen pixels and is available on platforms that
+ have high-resolution trackpads, such as Mac OS X.
+
The functions pos() and globalPos() return the mouse cursor's
location at the time of the event.
@@ -483,8 +489,11 @@ QHoverEvent::~QHoverEvent()
*/
/*!
+ \obsolete
Constructs a wheel event object.
+ Use the QPoint-based constructor instead.
+
The position, \a pos, is the location of the mouse cursor within
the widget. The globalPos() is initialized to QCursor::pos()
which is usually, but not always, correct.
@@ -496,13 +505,13 @@ QHoverEvent::~QHoverEvent()
\a modifiers holds the keyboard modifier flags at the time of the
event, and \a orient holds the wheel's orientation.
- \sa pos() delta() state()
+ \sa pos() pixelDelta() angleDelta() state()
*/
#ifndef QT_NO_WHEELEVENT
QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
Qt::Orientation orient)
- : QInputEvent(Wheel, modifiers), p(pos), d(delta), mouseState(buttons), o(orient)
+ : QInputEvent(Wheel, modifiers), p(pos), qt4D(delta), qt4O(orient), mouseState(buttons)
{
g = QCursor::pos();
}
@@ -515,26 +524,69 @@ QWheelEvent::~QWheelEvent()
}
/*!
+ \obsolete
Constructs a wheel event object.
+ Use the QPoint-based constructor instead.
+
The \a pos provides the location of the mouse cursor
within the widget. The position in global coordinates is specified
by \a globalPos. \a delta contains the rotation distance, \a modifiers
holds the keyboard modifier flags at the time of the event, and
\a orient holds the wheel's orientation.
- \sa pos() globalPos() delta() state()
+
+ \sa pos() pixelDelta() angleDelta() state()
*/
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
Qt::Orientation orient)
- : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), d(delta), mouseState(buttons), o(orient)
+ : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), qt4D(delta), qt4O(orient), mouseState(buttons)
+{}
+
+/*!
+ 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. \pixelDelta contains the scrolling distance
+ in pixels on screen, \a angleDelta contains the wheel rotation distance.
+ \pixelDelta is optional and can be null.
+
+ \a modifiers holds the keyboard modifier flags at the time of the event.
+
+ \a pixelDelta contains the scrolling delta in pixels,
+ \a angleDelta contains the rotation distance, and
+ \a orient holds the wheel's orientation.
+
+ \sa pos() globalPos() delta() state()
+*/
+
+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)
{}
+
#endif // QT_NO_WHEELEVENT
/*!
- \fn int QWheelEvent::delta() const
+ \fn QPoint QWheelEvent::pixelDelta() const
+
+ Returns the scrolling distance in pixels on screen. This value is
+ provided on platforms that support high-resolution pixel-based
+ delta values, such as Mac OS X. The value should be used directly
+ to scroll content on screen.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qevent.cpp 0
+*/
+
+/*!
+ \fn QPoint QWheelEvent::angleDelta() const
Returns the distance that the wheel is rotated, in eighths of a
degree. A positive value indicates that the wheel was rotated
@@ -556,6 +608,12 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta
*/
/*!
+ \fn int QWheelEvent::delta() const
+
+ This function has been deprecated, use pixelDelta() or angleDelta() instead.
+*/
+
+/*!
\fn const QPoint &QWheelEvent::pos() const
Returns the position of the mouse cursor relative to the widget
@@ -833,7 +891,7 @@ Qt::KeyboardModifiers QKeyEvent::modifiers() const
bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
{
uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference
- uint platform = QGuiApplicationPrivate::currentKeyPlatform();
+ const uint platform = QKeySequencePrivate::currentKeyPlatforms();
uint N = QKeySequencePrivate::numberOfKeyBindings;
@@ -2887,7 +2945,6 @@ QShortcutEvent::~QShortcutEvent()
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QEvent *e) {
-#ifndef Q_BROKEN_DEBUG_STREAM
// More useful event output could be added here
if (!e)
return dbg << "QEvent(this = 0x0)";
@@ -3168,11 +3225,6 @@ QDebug operator<<(QDebug dbg, const QEvent *e) {
dbg.nospace() << 'Q' << n << "Event(" << (const void *)e << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QEvent to QDebug");
- return dbg;
- Q_UNUSED(e);
-#endif
}
#endif