aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-07-14 15:31:53 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2016-07-15 13:26:19 +0000
commit30e30b98669bc51c77416f8c1ba68e348848be23 (patch)
treebfb7a541e2b827a0fa7174d92beda48256920f21
parentff844b63b9656e5527af126d41a300ecfcc303ff (diff)
Add QQuickEventPoint *QQuickPointerEvent::pointById(int)
Change-Id: Id6a41545036b7fe37d5b486789f77642a4241d9a Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
-rw-r--r--src/quick/items/qquickevents.cpp22
-rw-r--r--src/quick/items/qquickevents_p_p.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index d09294b515..68284843b6 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -621,6 +621,28 @@ QMouseEvent *QQuickPointerEvent::syntheticMouseEvent(int pointID, QQuickItem *re
/*!
\internal
+ Returns a pointer to the QQuickEventPoint which has the \a pointId as
+ \l {QQuickEventPoint::pointId}{pointId}.
+ Returns nullptr if there is no point with that ID.
+*/
+QQuickEventPoint *QQuickPointerEvent::pointById(quint64 pointId) {
+ if (isMouseEvent()) {
+ if (m_mousePoint && pointId == m_mousePoint->pointId())
+ return m_mousePoint;
+ }
+ if (isTouchEvent()) {
+ auto it = std::find_if(m_touchPoints.constBegin(), m_touchPoints.constEnd(),
+ [pointId](const QQuickEventTouchPoint *tp) { return tp->pointId() == pointId; } );
+ if (it != m_touchPoints.constEnd()) {
+ return *it;
+ }
+ }
+ // TODO it could alternatively be a tablet point
+ return nullptr;
+}
+
+/*!
+ \internal
Returns a pointer to the original TouchPoint which has the same
\l {QTouchEvent::TouchPoint::id}{id} as \a pointId, if the original event is a
QTouchEvent, and if that point is found. Otherwise, returns nullptr.
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index 65a9ae190a..303b14b5cf 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -418,6 +418,7 @@ public: // helpers for C++ only (during event delivery)
int pointCount() const { return m_pointCount; }
const QQuickEventPoint *point(int i) const;
+ QQuickEventPoint *pointById(quint64 pointId);
const QTouchEvent::TouchPoint *touchPointById(int pointId) const;