diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-07-14 15:31:53 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-07-15 13:26:19 +0000 |
commit | 30e30b98669bc51c77416f8c1ba68e348848be23 (patch) | |
tree | bfb7a541e2b827a0fa7174d92beda48256920f21 /src/quick/items/qquickevents.cpp | |
parent | ff844b63b9656e5527af126d41a300ecfcc303ff (diff) |
Add QQuickEventPoint *QQuickPointerEvent::pointById(int)
Change-Id: Id6a41545036b7fe37d5b486789f77642a4241d9a
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'src/quick/items/qquickevents.cpp')
-rw-r--r-- | src/quick/items/qquickevents.cpp | 22 |
1 files changed, 22 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. |