2014-09-08 18:33:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2015-01-15 10:33:32 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd
|
2014-09-08 18:33:02 +02:00
|
|
|
** All rights reserved.
|
2015-01-15 10:33:32 +01:00
|
|
|
** For any questions to The Qt Company, please use contact form at http://www.qt.io/contact-us
|
2014-09-08 18:33:02 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of the Qt Enterprise Qt Quick Profiler Add-on.
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Enterprise licenses may use this file in
|
|
|
|
|
** accordance with the Qt Enterprise License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-15 10:33:32 +01:00
|
|
|
** a written agreement between you and The Qt Company.
|
2014-09-08 18:33:02 +02:00
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please use
|
2015-01-15 10:33:32 +01:00
|
|
|
** contact form at http://www.qt.io/contact-us
|
2014-09-08 18:33:02 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "inputeventsmodel.h"
|
|
|
|
|
#include "qmldebug/qmlprofilereventtypes.h"
|
|
|
|
|
#include "qmlprofiler/qmlprofilermodelmanager.h"
|
|
|
|
|
|
|
|
|
|
namespace QmlProfilerExtension {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
using namespace QmlProfiler;
|
|
|
|
|
|
2014-10-29 10:31:28 +01:00
|
|
|
InputEventsModel::InputEventsModel(QmlProfilerModelManager *manager, QObject *parent) :
|
|
|
|
|
QmlProfilerTimelineModel(manager,
|
|
|
|
|
tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileInputEvents)),
|
|
|
|
|
QmlDebug::Event, QmlDebug::MaximumRangeType, parent),
|
2014-10-28 14:30:04 +01:00
|
|
|
m_keyTypeId(-1), m_mouseTypeId(-1)
|
2014-09-08 18:33:02 +02:00
|
|
|
{
|
2014-10-28 17:39:23 +01:00
|
|
|
announceFeatures(1 << QmlDebug::ProfileInputEvents);
|
2014-09-08 18:33:02 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-28 14:30:04 +01:00
|
|
|
int InputEventsModel::typeId(int index) const
|
2014-10-10 18:10:15 +02:00
|
|
|
{
|
2014-10-28 14:30:04 +01:00
|
|
|
return selectionId(index) == QmlDebug::Mouse ? m_mouseTypeId : m_keyTypeId;
|
2014-10-10 18:10:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QColor InputEventsModel::color(int index) const
|
|
|
|
|
{
|
|
|
|
|
return colorBySelectionId(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantList InputEventsModel::labels() const
|
|
|
|
|
{
|
|
|
|
|
QVariantList result;
|
|
|
|
|
|
2014-10-29 10:42:22 +01:00
|
|
|
QVariantMap element;
|
|
|
|
|
element.insert(QLatin1String("description"), QVariant(tr("Mouse Events")));
|
|
|
|
|
element.insert(QLatin1String("id"), QVariant(QmlDebug::Mouse));
|
|
|
|
|
result << element;
|
2014-10-10 18:10:15 +02:00
|
|
|
|
2014-10-29 10:42:22 +01:00
|
|
|
element.clear();
|
|
|
|
|
element.insert(QLatin1String("description"), QVariant(tr("Keyboard Events")));
|
|
|
|
|
element.insert(QLatin1String("id"), QVariant(QmlDebug::Key));
|
|
|
|
|
result << element;
|
2014-10-10 18:10:15 +02:00
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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"), QmlProfilerBaseModel::formatTime(startTime(index)));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-17 13:30:53 +01:00
|
|
|
int InputEventsModel::expandedRow(int index) const
|
2014-10-10 18:10:15 +02:00
|
|
|
{
|
|
|
|
|
return selectionId(index) == QmlDebug::Mouse ? 1 : 2;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-17 13:30:53 +01:00
|
|
|
int InputEventsModel::collapsedRow(int index) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(index)
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-10 18:10:15 +02:00
|
|
|
void InputEventsModel::loadData()
|
|
|
|
|
{
|
|
|
|
|
clear();
|
2014-10-27 19:54:23 +01:00
|
|
|
QmlProfilerDataModel *simpleModel = modelManager()->qmlModel();
|
2014-10-10 18:10:15 +02:00
|
|
|
if (simpleModel->isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = simpleModel->getEventTypes();
|
|
|
|
|
foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) {
|
|
|
|
|
const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex];
|
|
|
|
|
if (!accepted(type))
|
|
|
|
|
continue;
|
2014-10-28 14:30:04 +01:00
|
|
|
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;
|
|
|
|
|
}
|
2014-10-27 19:54:23 +01:00
|
|
|
updateProgress(count(), simpleModel->getEvents().count());
|
2014-10-10 18:10:15 +02:00
|
|
|
}
|
2014-10-27 19:54:23 +01:00
|
|
|
setCollapsedRowCount(2);
|
|
|
|
|
setExpandedRowCount(3);
|
|
|
|
|
updateProgress(1, 1);
|
2014-10-10 18:10:15 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-28 14:30:04 +01:00
|
|
|
void InputEventsModel::clear()
|
|
|
|
|
{
|
|
|
|
|
m_keyTypeId = m_mouseTypeId = -1;
|
2014-10-29 10:31:28 +01:00
|
|
|
QmlProfilerTimelineModel::clear();
|
2014-10-28 14:30:04 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-10 18:10:15 +02:00
|
|
|
bool InputEventsModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const
|
|
|
|
|
{
|
2014-10-29 10:31:28 +01:00
|
|
|
return QmlProfilerTimelineModel::accepted(event) &&
|
2014-10-10 18:10:15 +02:00
|
|
|
(event.detailType == QmlDebug::Mouse || event.detailType == QmlDebug::Key);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-08 18:33:02 +02:00
|
|
|
}
|
|
|
|
|
}
|