diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-08-31 15:01:45 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-09-02 21:38:40 +0000 |
commit | 0dbb301e167292f728a845625556f2bef4699022 (patch) | |
tree | 7a527f05410363a84f99d1e41a22b35621144c49 /src/quick/items/qquickevents.cpp | |
parent | 856332456d9f289a05bc039cfa4e875f21441207 (diff) |
QQuickPointerEvent and EventPoint: add localize(QQuickItem *)
During delivery we need to call
QQuickItem::mapFromScene(point->scenePos())
so let's do it as early as possible and store the result right in the
EventPoint. That way the pos() property can be made available,
for the benefit of QML/JS signal handlers and also for C++ handlers.
Change-Id: I2706ffd6bc51a449eeba64f69c9ffdfb913c5ca6
Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'src/quick/items/qquickevents.cpp')
-rw-r--r-- | src/quick/items/qquickevents.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 45e2fd3e73..c3156d0328 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -529,6 +529,14 @@ void QQuickEventPoint::reset(Qt::TouchPointState state, const QPointF &scenePos, m_velocity = velocity; } +void QQuickEventPoint::localize(QQuickItem *target) +{ + if (target) + m_pos = target->mapFromScene(scenePos()); + else + m_pos = QPointF(); +} + QObject *QQuickEventPoint::grabber() const { return m_grabber.data(); @@ -638,6 +646,11 @@ QQuickPointerEvent *QQuickPointerMouseEvent::reset(QEvent *event) return this; } +void QQuickPointerMouseEvent::localize(QQuickItem *target) +{ + m_mousePoint->localize(target); +} + QQuickPointerEvent *QQuickPointerTouchEvent::reset(QEvent *event) { auto ev = static_cast<QTouchEvent*>(event); @@ -682,6 +695,12 @@ QQuickPointerEvent *QQuickPointerTouchEvent::reset(QEvent *event) return this; } +void QQuickPointerTouchEvent::localize(QQuickItem *target) +{ + for (auto point : qAsConst(m_touchPoints)) + point->localize(target); +} + QQuickEventPoint *QQuickPointerMouseEvent::point(int i) const { if (i == 0) return m_mousePoint; |