From 30e30b98669bc51c77416f8c1ba68e348848be23 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 14 Jul 2016 15:31:53 +0200 Subject: Add QQuickEventPoint *QQuickPointerEvent::pointById(int) Change-Id: Id6a41545036b7fe37d5b486789f77642a4241d9a Reviewed-by: Frederik Gladhorn --- src/quick/items/qquickevents.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/quick/items/qquickevents.cpp') 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 @@ -619,6 +619,28 @@ QMouseEvent *QQuickPointerEvent::syntheticMouseEvent(int pointID, QQuickItem *re return &m_synthMouseEvent; } +/*! + \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 -- cgit v1.2.3