aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickevents.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2016-07-21 11:35:42 +0200
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2016-07-21 14:14:56 +0000
commita5e7897dd7705a9df3a97e5de75b5b95d6a88e25 (patch)
tree39cbb88f5c25194b87f8124ae88e0c57e526d5b8 /src/quick/items/qquickevents.cpp
parentc856d877e77048701182cc0e5ae275c398e55166 (diff)
Improve encapsuation of touch/mouse event specific things
This makes it easy to avoid casts when using the classes. Change-Id: I27bd1244bffb3a7d2cdb4572c229333e4c499d9b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickevents.cpp')
-rw-r--r--src/quick/items/qquickevents.cpp30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index cb48255c4e..e4a080d2b7 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -506,26 +506,6 @@ QQuickPointerEvent *QQuickPointerTouchEvent::reset(QEvent *event) {
return this;
}
-/*!
- \internal
- Returns the original touch event, or nullptr if it was not a touch event.
-*/
-QTouchEvent *QQuickPointerEvent::asTouchEvent() const {
- if (!isTouchEvent())
- return nullptr;
- return static_cast<QTouchEvent *>(m_event);
-}
-
-/*!
- \internal
- Returns the original mouse event, or nullptr if it was not a mouse event.
-*/
-QMouseEvent *QQuickPointerEvent::asMouseEvent() const {
- if (isMouseEvent())
- return static_cast<QMouseEvent *>(m_event);
- return nullptr;
-}
-
QQuickEventPoint *QQuickPointerMouseEvent::point(int i) const {
if (i == 0)
return m_mousePoint;
@@ -554,6 +534,11 @@ bool QQuickPointerMouseEvent::allPointsAccepted() const {
return m_mousePoint->isAccepted();
}
+QMouseEvent *QQuickPointerMouseEvent::asMouseEvent() const
+{
+ return static_cast<QMouseEvent *>(m_event);
+}
+
bool QQuickPointerTouchEvent::allPointsAccepted() const {
for (int i = 0; i < m_pointCount; ++i) {
if (!m_touchPoints.at(i)->isAccepted())
@@ -704,6 +689,11 @@ QTouchEvent *QQuickPointerTouchEvent::touchEventForItem(const QList<const QQuick
return touchEvent;
}
+QTouchEvent *QQuickPointerTouchEvent::asTouchEvent() const
+{
+ return static_cast<QTouchEvent *>(m_event);
+}
+
#ifndef QT_NO_DEBUG_STREAM
Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickPointerDevice *dev) {