summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-08-06 13:30:09 +0200
committerShawn Rutledge <shawn.rutledge@digia.com>2014-08-06 16:16:35 +0200
commitc1d2a04923b8c48becb200e84c253beb52ac809f (patch)
tree6c6ae2f73a217b9e3b316448b9020bc61476794f /src/gui
parent589894c072b941f07062cd9b3ebd34f0c4291fb7 (diff)
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 <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qevent.cpp52
-rw-r--r--src/gui/kernel/qevent.h4
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,34 +3355,32 @@ QShortcutEvent::~QShortcutEvent()
#ifndef QT_NO_DEBUG_STREAM
-static inline void formatTouchEvent(QDebug d, const char *name, const QTouchEvent &t)
+static inline void formatTouchPoint(QDebug d, const QTouchEvent::TouchPoint &tp)
{
- d << "QTouchEvent(" << name << " states: " << t.touchPointStates();
- const QList<QTouchEvent::TouchPoint> 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 << "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();
+ d << ", " << t.touchPoints().size() << " points: " << t.touchPoints() << ')';
+}
+
static void formatUnicodeString(QDebug d, const QString &s)
{
d << '"' << hex;
@@ -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: