diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-06-24 14:06:18 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-06-25 16:31:10 +0200 |
commit | bae7435f61e68711b6b8ce056957a146dc1a335e (patch) | |
tree | f1d4ee85e0c04643692877b4a43833e5e3636b4d /src/widgets/graphicsview/qgraphicssceneevent.cpp | |
parent | 4696e9dbaa4fc8bf3c7eeed9aceaba5da480acaf (diff) |
Propagate source/flags of QMouseEvent to QGraphicsSceneMouseEvent.
It is useful to be able to detect synthesized mouse events
in GraphicsView as well.
[ChangeLog][QtWidgets][QGraphicsSceneMouseEvent] Accessors
for Qt::MouseEventSource and Qt::MouseEventFlags were added to
QGraphicsSceneMouseEvent to enable detection of
synthesized mouse events.
Task-number: QTBUG-39814
Change-Id: Ib5835fef1f484005f9b0fc86518ed32ea79cd80f
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicssceneevent.cpp')
-rw-r--r-- | src/widgets/graphicsview/qgraphicssceneevent.cpp | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp index 631aa7bf19..be91c63fad 100644 --- a/src/widgets/graphicsview/qgraphicssceneevent.cpp +++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp @@ -348,7 +348,7 @@ class QGraphicsSceneMouseEventPrivate : public QGraphicsSceneEventPrivate public: inline QGraphicsSceneMouseEventPrivate() : button(Qt::NoButton), - buttons(0), modifiers(0) + buttons(0), modifiers(0), source(Qt::MouseEventNotSynthesized), flags(0) { } QPointF pos; @@ -363,6 +363,8 @@ public: Qt::MouseButton button; Qt::MouseButtons buttons; Qt::KeyboardModifiers modifiers; + Qt::MouseEventSource source; + Qt::MouseEventFlags flags; }; /*! @@ -626,6 +628,60 @@ Qt::KeyboardModifiers QGraphicsSceneMouseEvent::modifiers() const } /*! + \since 5.4 + + Returns information about the mouse event source. + + The mouse event source can be used to distinguish between genuine + and artificial mouse events. The latter are events that are + synthesized from touch events by the operating system or Qt itself. + + \sa Qt::MouseEventSource + \sa QMouseEvent::source() + */ +Qt::MouseEventSource QGraphicsSceneMouseEvent::source() const +{ + Q_D(const QGraphicsSceneMouseEvent); + return d->source; +} + +/*! + \since 5.4 + \internal + */ +void QGraphicsSceneMouseEvent::setSource(Qt::MouseEventSource source) +{ + Q_D(QGraphicsSceneMouseEvent); + d->source = source; +} + +/*! + \since 5.4 + + Returns the mouse event flags. + + The mouse event flags provide additional information about a mouse event. + + \sa Qt::MouseEventFlag + \sa QMouseEvent::flags() + */ +Qt::MouseEventFlags QGraphicsSceneMouseEvent::flags() const +{ + Q_D(const QGraphicsSceneMouseEvent); + return d->flags; +} + +/*! + \since 5.4 + \internal + */ +void QGraphicsSceneMouseEvent::setFlags(Qt::MouseEventFlags flags) +{ + Q_D(QGraphicsSceneMouseEvent); + d->flags = flags; +} + +/*! \internal */ void QGraphicsSceneMouseEvent::setModifiers(Qt::KeyboardModifiers modifiers) |