From c1d2a04923b8c48becb200e84c253beb52ac809f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 6 Aug 2014 13:30:09 +0200 Subject: [PATCH] Add debug operator for QTouchEvent::TouchPoint dfde72e4361d82a782cb4da08ddcd0d8e8c40b07 added debug support for QWindowSystemInterface::TouchPoint, which is useful only near the QPA interface; but in qtdeclarative it's useful to be able to log individual touch points too. Change-Id: I237d354d7018e6326e586ae3355c8aa6f781eff8 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qevent.cpp | 52 ++++++++++++++++++++++----------------- src/gui/kernel/qevent.h | 4 +++ 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 457428f569..a002aad387 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3355,32 +3355,30 @@ QShortcutEvent::~QShortcutEvent() #ifndef QT_NO_DEBUG_STREAM +static inline void formatTouchPoint(QDebug d, const QTouchEvent::TouchPoint &tp) +{ + d << "TouchPoint(" << tp.id() << ' ' << tp.rect(); + switch (tp.state()) { + case Qt::TouchPointPressed: + d << " pressed"; + break; + case Qt::TouchPointReleased: + d << " released"; + break; + case Qt::TouchPointMoved: + d << " moved"; + break; + case Qt::TouchPointStationary: + d << " stationary"; + break; + } + d << ')'; +} + static inline void formatTouchEvent(QDebug d, const char *name, const QTouchEvent &t) { d << "QTouchEvent(" << name << " states: " << t.touchPointStates(); - const QList points = t.touchPoints(); - const int size = points.size(); - d << ", " << size << " points: "; - for (int i = 0; i < size; ++i) { - if (i) - d << ", "; - d << points.at(i).pos() << ' ' << points.at(i).rect(); - switch (points.at(i).state()) { - case Qt::TouchPointPressed: - d << " pressed"; - break; - case Qt::TouchPointReleased: - d << " released"; - break; - case Qt::TouchPointMoved: - d << " moved"; - break; - case Qt::TouchPointStationary: - d << " stationary"; - break; - } - } - d << ')'; + d << ", " << t.touchPoints().size() << " points: " << t.touchPoints() << ')'; } static void formatUnicodeString(QDebug d, const QString &s) @@ -3647,6 +3645,14 @@ static void formatTabletEvent(QDebug d, const QTabletEvent *e) # endif // !QT_NO_TABLETEVENT +QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &tp) +{ + QDebugStateSaver saver(dbg); + dbg.nospace(); + formatTouchPoint(dbg, tp); + return dbg; +} + QDebug operator<<(QDebug dbg, const QEvent *e) { QDebugStateSaver saver(dbg); diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index e123845f66..d128c34134 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -889,6 +889,10 @@ protected: Q_DECLARE_TYPEINFO(QTouchEvent::TouchPoint, Q_MOVABLE_TYPE); Q_DECLARE_OPERATORS_FOR_FLAGS(QTouchEvent::TouchPoint::InfoFlags) +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QTouchEvent::TouchPoint &); +#endif + class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent { public: