diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-10-23 17:49:11 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-11-05 08:42:38 +0000 |
commit | 00f0e00fb22065e0e4d5702bb851887c7d935e92 (patch) | |
tree | 32b566760c711d2f8a7a9eda655c1777d593ad6b | |
parent | 6b7bcd04605b72f00ef92a8983a6f913ab753c4e (diff) |
Add some more information to input events, if available
Just "Mouse" or "Key" is not very helpful.
Change-Id: Ia5db293fb957242aa0a7a84440cd1632d2babe8a
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r-- | plugins/qmlprofiler/inputeventsmodel.cpp | 70 | ||||
-rw-r--r-- | plugins/qmlprofiler/inputeventsmodel.h | 9 |
2 files changed, 76 insertions, 3 deletions
diff --git a/plugins/qmlprofiler/inputeventsmodel.cpp b/plugins/qmlprofiler/inputeventsmodel.cpp index 5dd0a80ec6..808e8aff80 100644 --- a/plugins/qmlprofiler/inputeventsmodel.cpp +++ b/plugins/qmlprofiler/inputeventsmodel.cpp @@ -20,6 +20,10 @@ #include "qmldebug/qmlprofilereventtypes.h" #include "qmlprofiler/qmlprofilermodelmanager.h" +#include <QKeyEvent> +#include <QMouseEvent> +#include <QMetaEnum> + namespace QmlProfilerExtension { namespace Internal { @@ -62,9 +66,60 @@ QVariantList InputEventsModel::labels() const QVariantMap InputEventsModel::details(int index) const { QVariantMap result; - result.insert(QLatin1String("displayName"), - selectionId(index) == QmlDebug::Key ? tr("Keyboard Event") : tr("Mouse Event")); result.insert(QLatin1String("Timestamp"), QmlProfilerDataModel::formatTime(startTime(index))); + QString type; + const InputEvent &event = m_data[index]; + switch (event.type) { + case QmlDebug::InputKeyPress: + type = QLatin1String("Key Press"); + case QmlDebug::InputKeyRelease: + if (type.isEmpty()) + type = QLatin1String("Key Release"); + if (event.a != 0) { + result.insert(QLatin1String("Key"), QLatin1String( + QMetaEnum::fromType<Qt::Key>().valueToKey(event.a))); + } + if (event.b != 0) { + result.insert(QLatin1String("Modifiers"), QLatin1String( + QMetaEnum::fromType<Qt::KeyboardModifiers>().valueToKeys(event.b))); + } + break; + case QmlDebug::InputMouseDoubleClick: + type = QLatin1String("Double Click"); + case QmlDebug::InputMousePress: + if (type.isEmpty()) + type = QLatin1String("Mouse Press"); + case QmlDebug::InputMouseRelease: + if (type.isEmpty()) + type = QLatin1String("Mouse Release"); + result.insert(QLatin1String("Button"), QLatin1String( + QMetaEnum::fromType<Qt::MouseButtons>().valueToKey(event.a))); + result.insert(QLatin1String("Result"), QLatin1String( + QMetaEnum::fromType<Qt::MouseButtons>().valueToKeys(event.b))); + break; + case QmlDebug::InputMouseMove: + type = QLatin1String("Mouse Move"); + result.insert(QLatin1String("X"), QString::number(event.a)); + result.insert(QLatin1String("Y"), QString::number(event.b)); + break; + case QmlDebug::InputMouseWheel: + type = QLatin1String("Mouse Wheel"); + result.insert(QLatin1String("Angle X"), QString::number(event.a)); + result.insert(QLatin1String("Angle Y"), QString::number(event.b)); + break; + case QmlDebug::InputKeyUnknown: + type = QLatin1String("Keyboard Event"); + break; + case QmlDebug::InputMouseUnknown: + type = QLatin1String("Mouse Event"); + break; + default: + Q_UNREACHABLE(); + break; + } + + result.insert(QLatin1String("displayName"), type); + return result; } @@ -90,7 +145,11 @@ void InputEventsModel::loadData() const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex]; if (!accepted(type)) continue; - insert(event.startTime, 0, type.detailType); + + m_data.insert(insert(event.startTime, 0, type.detailType), + InputEvent(static_cast<QmlDebug::InputEventType>(event.numericData1), + event.numericData2, event.numericData3)); + if (type.detailType == QmlDebug::Mouse) { if (m_mouseTypeId == -1) m_mouseTypeId = event.typeIndex; @@ -116,5 +175,10 @@ bool InputEventsModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &ev (event.detailType == QmlDebug::Mouse || event.detailType == QmlDebug::Key); } +InputEventsModel::InputEvent::InputEvent(QmlDebug::InputEventType type, int a, int b) : + type(type), a(a), b(b) +{ +} + } } diff --git a/plugins/qmlprofiler/inputeventsmodel.h b/plugins/qmlprofiler/inputeventsmodel.h index 43a9dc4498..8c0ff17216 100644 --- a/plugins/qmlprofiler/inputeventsmodel.h +++ b/plugins/qmlprofiler/inputeventsmodel.h @@ -32,6 +32,14 @@ protected: bool accepted(const QmlProfiler::QmlProfilerDataModel::QmlEventTypeData &event) const; public: + struct InputEvent { + InputEvent(QmlDebug::InputEventType type = QmlDebug::MaximumInputEventType, int a = 0, + int b = 0); + QmlDebug::InputEventType type; + int a; + int b; + }; + InputEventsModel(QmlProfiler::QmlProfilerModelManager *manager, QObject *parent = 0); int typeId(int index) const; @@ -47,6 +55,7 @@ private: int m_keyTypeId; int m_mouseTypeId; + QVector<InputEvent> m_data; }; } |