summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-07-28 11:05:27 +0200
committerLiang Qi <liang.qi@digia.com>2014-07-28 22:13:28 +0200
commit61fecb23c2adaf50eb7b55fa85ec94a5bbc9f69a (patch)
treec2f611504e1fa97787d09e0ad3144046ec71e8f0 /src/gui
parent178a1548f3ae87c8fdde1bf5d0e71ed4e4252253 (diff)
Add debug output for input method related events.
Task-number: QTBUG-40402 Change-Id: Ide96588488eb6d95f4c39f3da749d301d9ec858e Reviewed-by: Liang Qi <liang.qi@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qevent.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 6dfccec834..492f2a11c9 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3382,6 +3382,61 @@ static inline void formatTouchEvent(QDebug d, const char *name, const QTouchEven
d << ')';
}
+static void formatUnicodeString(QDebug d, const QString &s)
+{
+ d << '"' << hex;
+ for (int i = 0; i < s.size(); ++i) {
+ if (i)
+ d << ',';
+ d << "U+" << s.at(i).unicode();
+ }
+ d << dec << '"';
+}
+
+static inline void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e)
+{
+ d << "QInputMethodEvent(";
+ if (!e->preeditString().isEmpty()) {
+ d << "preedit=";
+ formatUnicodeString(d, e->preeditString());
+ }
+ if (!e->commitString().isEmpty()) {
+ d << ", commit=";
+ formatUnicodeString(d, e->commitString());
+ }
+ if (e->replacementLength()) {
+ d << ", replacementStart=" << e->replacementStart() << ", replacementLength="
+ << e->replacementLength();
+ }
+ if (const int attributeCount = e->attributes().size()) {
+ d << ", attributes= {";
+ for (int a = 0; a < attributeCount; ++a) {
+ const QInputMethodEvent::Attribute &at = e->attributes().at(a);
+ if (a)
+ d << ',';
+ d << "[type= " << at.type << ", start=" << at.start << ", length=" << at.length
+ << ", value=" << at.value << ']';
+ }
+ d << '}';
+ }
+ d << ')';
+}
+
+static inline void formatInputMethodQueryEvent(QDebug d, const QInputMethodQueryEvent *e)
+{
+ const Qt::InputMethodQueries queries = e->queries();
+ d << "QInputMethodQueryEvent(queries=" << showbase << hex << int(queries)
+ << noshowbase << dec << ", {";
+ for (unsigned mask = 1; mask <= Qt::ImTextAfterCursor; mask<<=1) {
+ if (queries & mask) {
+ const QVariant value = e->value(static_cast<Qt::InputMethodQuery>(mask));
+ if (value.isValid())
+ d << '[' << showbase << hex << mask << noshowbase << dec << '=' << value << "],";
+ }
+ }
+ d << "})";
+}
+
QDebug operator<<(QDebug dbg, const QEvent *e) {
// More useful event output could be added here
if (!e)
@@ -3631,6 +3686,18 @@ QDebug operator<<(QDebug dbg, const QEvent *e) {
case QEvent::GraphicsSceneMove:
n = "GraphicsSceneMove";
break;
+ case QEvent::InputMethod: {
+ QDebugStateSaver saver(dbg);
+ dbg.nospace();
+ formatInputMethodEvent(dbg, static_cast<const QInputMethodEvent *>(e));
+ }
+ return dbg;
+ case QEvent::InputMethodQuery: {
+ QDebugStateSaver saver(dbg);
+ dbg.nospace();
+ formatInputMethodQueryEvent(dbg, static_cast<const QInputMethodQueryEvent *>(e));
+ }
+ return dbg;
case QEvent::CursorChange:
n = "CursorChange";
break;