diff options
Diffstat (limited to 'plugins/qmlprofilerextension/inputeventsmodel.cpp')
-rw-r--r-- | plugins/qmlprofilerextension/inputeventsmodel.cpp | 87 |
1 files changed, 42 insertions, 45 deletions
diff --git a/plugins/qmlprofilerextension/inputeventsmodel.cpp b/plugins/qmlprofilerextension/inputeventsmodel.cpp index 7d67f2b7734..41403d90164 100644 --- a/plugins/qmlprofilerextension/inputeventsmodel.cpp +++ b/plugins/qmlprofilerextension/inputeventsmodel.cpp @@ -19,34 +19,24 @@ #include "inputeventsmodel.h" #include "qmldebug/qmlprofilereventtypes.h" #include "qmlprofiler/qmlprofilermodelmanager.h" -#include "qmlprofiler/abstracttimelinemodel_p.h" namespace QmlProfilerExtension { namespace Internal { using namespace QmlProfiler; -class InputEventsModel::InputEventsModelPrivate : public AbstractTimelineModelPrivate +InputEventsModel::InputEventsModel(QmlProfilerModelManager *manager, QObject *parent) : + QmlProfilerTimelineModel(manager, + tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileInputEvents)), + QmlDebug::Event, QmlDebug::MaximumRangeType, parent), + m_keyTypeId(-1), m_mouseTypeId(-1) { - Q_DECLARE_PUBLIC(InputEventsModel) -}; - -InputEventsModel::InputEventsModel(QObject *parent) - : AbstractTimelineModel(new InputEventsModelPrivate(), - tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileInputEvents)), - QmlDebug::Event, QmlDebug::MaximumRangeType, parent) -{ -} - -quint64 InputEventsModel::features() const -{ - return 1 << QmlDebug::ProfileInputEvents; + announceFeatures(1 << QmlDebug::ProfileInputEvents); } -int InputEventsModel::selectionId(int index) const +int InputEventsModel::typeId(int index) const { - Q_D(const InputEventsModel); - return d->modelManager->qmlModel()->getEventTypes()[range(index).typeId].detailType; + return selectionId(index) == QmlDebug::Mouse ? m_mouseTypeId : m_keyTypeId; } QColor InputEventsModel::color(int index) const @@ -56,24 +46,17 @@ QColor InputEventsModel::color(int index) const QVariantList InputEventsModel::labels() const { - Q_D(const InputEventsModel); QVariantList result; - if (d->expanded && !d->hidden && !isEmpty()) { - { - QVariantMap element; - element.insert(QLatin1String("description"), QVariant(tr("Mouse Events"))); - element.insert(QLatin1String("id"), QVariant(QmlDebug::Mouse)); - result << element; - } + QVariantMap element; + element.insert(QLatin1String("description"), QVariant(tr("Mouse Events"))); + element.insert(QLatin1String("id"), QVariant(QmlDebug::Mouse)); + result << element; - { - QVariantMap element; - element.insert(QLatin1String("description"), QVariant(tr("Keyboard Events"))); - element.insert(QLatin1String("id"), QVariant(QmlDebug::Key)); - result << element; - } - } + element.clear(); + element.insert(QLatin1String("description"), QVariant(tr("Keyboard Events"))); + element.insert(QLatin1String("id"), QVariant(QmlDebug::Key)); + result << element; return result; } @@ -87,18 +70,21 @@ QVariantMap InputEventsModel::details(int index) const return result; } -int InputEventsModel::row(int index) const +int InputEventsModel::expandedRow(int index) const { - if (!expanded()) - return 1; return selectionId(index) == QmlDebug::Mouse ? 1 : 2; } +int InputEventsModel::collapsedRow(int index) const +{ + Q_UNUSED(index) + return 1; +} + void InputEventsModel::loadData() { - Q_D(InputEventsModel); clear(); - QmlProfilerDataModel *simpleModel = d->modelManager->qmlModel(); + QmlProfilerDataModel *simpleModel = modelManager()->qmlModel(); if (simpleModel->isEmpty()) return; @@ -107,18 +93,29 @@ void InputEventsModel::loadData() const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex]; if (!accepted(type)) continue; - insert(event.startTime, 0, event.typeIndex); - d->modelManager->modelProxyCountUpdated(d->modelId, count(), - simpleModel->getEvents().count()); + insert(event.startTime, 0, type.detailType); + if (type.detailType == QmlDebug::Mouse) { + if (m_mouseTypeId == -1) + m_mouseTypeId = event.typeIndex; + } else if (m_keyTypeId == -1) { + m_keyTypeId = event.typeIndex; + } + updateProgress(count(), simpleModel->getEvents().count()); } - d->collapsedRowCount = 2; - d->expandedRowCount = 3; - d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1); + setCollapsedRowCount(2); + setExpandedRowCount(3); + updateProgress(1, 1); +} + +void InputEventsModel::clear() +{ + m_keyTypeId = m_mouseTypeId = -1; + QmlProfilerTimelineModel::clear(); } bool InputEventsModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const { - return AbstractTimelineModel::accepted(event) && + return QmlProfilerTimelineModel::accepted(event) && (event.detailType == QmlDebug::Mouse || event.detailType == QmlDebug::Key); } |