diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-05-25 15:20:09 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-06-20 22:01:48 +0000 |
commit | 5e1063b6671c3116653cebabc693fae4c0ed5aae (patch) | |
tree | 4aa506d8588e4f83f800d786ce944d15e9ae897e /src/quick/items/qquickevents_p_p.h | |
parent | 29bdc9bf8bfdf3386d6b2e76eaecde9d58af3ab0 (diff) |
Add QQuickSinglePointEvent as intermed. base for QQMouseEvent and others
For now we already have QQuickPointerNativeGestureEvent; and in the
future, there may be other single-point events such as wheel events.
It's handy to reuse the implementations of several virtual
functions and the m_point storage.
Also format braces more consistently in function implementations.
Change-Id: I4b514610b9ed2bd23b7e9a6f1acf826ebd9ebc45
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickevents_p_p.h')
-rw-r--r-- | src/quick/items/qquickevents_p_p.h | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index b5596801b7..1f6abdec84 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -450,21 +450,14 @@ protected: Q_DISABLE_COPY(QQuickPointerEvent) }; -class Q_QUICK_PRIVATE_EXPORT QQuickPointerMouseEvent : public QQuickPointerEvent +class Q_QUICK_PRIVATE_EXPORT QQuickSinglePointEvent : public QQuickPointerEvent { Q_OBJECT public: - QQuickPointerMouseEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr) - : QQuickPointerEvent(parent, device), m_mousePoint(new QQuickEventPoint(this)) { } + QQuickSinglePointEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr) + : QQuickPointerEvent(parent, device), m_point(new QQuickEventPoint(this)) { } - QQuickPointerEvent *reset(QEvent *) override; void localize(QQuickItem *target) override; - bool isPressEvent() const override; - bool isDoubleClickEvent() const override; - bool isUpdateEvent() const override; - bool isReleaseEvent() const override; - QQuickPointerMouseEvent *asPointerMouseEvent() override { return this; } - const QQuickPointerMouseEvent *asPointerMouseEvent() const override { return this; } int pointCount() const override { return 1; } QQuickEventPoint *point(int i) const override; QQuickEventPoint *pointById(int pointId) const override; @@ -475,10 +468,28 @@ public: void clearGrabbers() const override; bool hasExclusiveGrabber(const QQuickPointerHandler *handler) const override; - QMouseEvent *asMouseEvent(const QPointF& localPos) const; +protected: + QQuickEventPoint *m_point; -private: - QQuickEventPoint *m_mousePoint; + Q_DISABLE_COPY(QQuickSinglePointEvent) +}; + +class Q_QUICK_PRIVATE_EXPORT QQuickPointerMouseEvent : public QQuickSinglePointEvent +{ + Q_OBJECT +public: + QQuickPointerMouseEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr) + : QQuickSinglePointEvent(parent, device) { } + + QQuickPointerEvent *reset(QEvent *) override; + bool isPressEvent() const override; + bool isDoubleClickEvent() const override; + bool isUpdateEvent() const override; + bool isReleaseEvent() const override; + QQuickPointerMouseEvent *asPointerMouseEvent() override { return this; } + const QQuickPointerMouseEvent *asPointerMouseEvent() const override { return this; } + + QMouseEvent *asMouseEvent(const QPointF& localPos) const; Q_DISABLE_COPY(QQuickPointerMouseEvent) }; @@ -526,7 +537,7 @@ private: }; #if QT_CONFIG(gestures) -class Q_QUICK_PRIVATE_EXPORT QQuickPointerNativeGestureEvent : public QQuickPointerEvent +class Q_QUICK_PRIVATE_EXPORT QQuickPointerNativeGestureEvent : public QQuickSinglePointEvent { Q_OBJECT Q_PROPERTY(Qt::NativeGestureType type READ type CONSTANT) @@ -534,30 +545,17 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerNativeGestureEvent : public QQuickPoin public: QQuickPointerNativeGestureEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr) - : QQuickPointerEvent(parent, device), m_gesturePoint(new QQuickEventPoint(this)) { } + : QQuickSinglePointEvent(parent, device) { } QQuickPointerEvent *reset(QEvent *) override; - void localize(QQuickItem *target) override; bool isPressEvent() const override; bool isUpdateEvent() const override; bool isReleaseEvent() const override; QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() override { return this; } const QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() const override { return this; } - int pointCount() const override { return 1; } - QQuickEventPoint *point(int i) const override; - QQuickEventPoint *pointById(int pointId) const override; - bool allPointsAccepted() const override; - bool allUpdatedPointsAccepted() const override; - bool allPointsGrabbed() const override; - QVector<QObject *> exclusiveGrabbers() const override; - void clearGrabbers() const override; - bool hasExclusiveGrabber(const QQuickPointerHandler *handler) const override; Qt::NativeGestureType type() const; qreal value() const; -private: - QQuickEventPoint *m_gesturePoint; - Q_DISABLE_COPY(QQuickPointerNativeGestureEvent) }; #endif // QT_CONFIG(gestures) |