summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-08-29 16:59:21 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-09-17 04:20:58 +0200
commit8932e80d0c8879a1e720fef825ed0d9c4e384a01 (patch)
treed4654c5d4a221d6a000d7e73a40be3d4170252f7 /src/gui/kernel/qevent.cpp
parentd1fc991c6e3c45a5f93c925d49e3fe77ce6ce455 (diff)
Add more QPointerEvent functions needed in Qt Quick
Change-Id: I87a874477b89eb3f5951930f03e305d896a24c2e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r--src/gui/kernel/qevent.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 811d2d1f20..6f4208fe84 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -606,6 +606,44 @@ QPointerEvent::~QPointerEvent()
}
/*!
+ Returns the point whose \l {QEventPoint::id()}{id} matches the given \a id,
+ or \c nullptr if no such point is found.
+*/
+QEventPoint *QPointerEvent::pointById(int id)
+{
+ for (auto &p : m_points) {
+ if (p.id() == id)
+ return &p;
+ }
+ return nullptr;
+}
+
+/*!
+ Returns \c true if every point in points() has an exclusiveGrabber().
+*/
+bool QPointerEvent::allPointsGrabbed() const
+{
+ for (const auto &p : points()) {
+ if (exclusiveGrabber(p) && passiveGrabbers(p).isEmpty())
+ return false;
+ }
+ return true;
+}
+
+/*!
+ Returns \c true if isPointAccepted() is \c true for every point in
+ points(); otherwise \c false.
+*/
+bool QPointerEvent::allPointsAccepted() const
+{
+ for (const auto &p : points()) {
+ if (!p.isAccepted())
+ return false;
+ }
+ return true;
+}
+
+/*!
Returns the source device from which this event originates.
This is the same as QInputEvent::device() but typecast for convenience.
@@ -844,6 +882,27 @@ QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *d
m_points.append(mut);
}
+/*! \internal
+ Constructs a single-point event with the given \a point, which must be an instance
+ (or copy of one) that already exists in QPointingDevicePrivate::activePoints.
+ Unlike the other constructor, it does not modify the given \a point in any way.
+ This is useful when synthesizing a QMouseEvent from one point taken from a QTouchEvent, for example.
+
+ \sa QMutableSinglePointEvent()
+*/
+QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *dev, const QEventPoint &point,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
+ : QPointerEvent(type, dev, modifiers),
+ m_button(button),
+ m_mouseState(buttons),
+ m_source(source),
+ m_doubleClick(false),
+ m_reserved(0)
+{
+ m_points << point;
+}
+
/*!
Returns \c true if this event represents a \l {button()}{button} being pressed.
*/