forked from qt-creator/qt-creator
Implement the input events model
Change-Id: Ifae1ac725518d1a7fb12b46bd36485cd46ebf082 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -43,5 +43,84 @@ quint64 InputEventsModel::features() const
|
||||
return 1 << QmlDebug::ProfileInputEvents;
|
||||
}
|
||||
|
||||
int InputEventsModel::selectionId(int index) const
|
||||
{
|
||||
Q_D(const InputEventsModel);
|
||||
return d->modelManager->qmlModel()->getEventTypes()[range(index).typeId].detailType;
|
||||
}
|
||||
|
||||
QColor InputEventsModel::color(int index) const
|
||||
{
|
||||
return colorBySelectionId(index);
|
||||
}
|
||||
|
||||
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("Keyboard Events")));
|
||||
element.insert(QLatin1String("id"), QVariant(QmlDebug::Key));
|
||||
result << element;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int InputEventsModel::row(int index) const
|
||||
{
|
||||
if (!expanded())
|
||||
return 1;
|
||||
return selectionId(index) == QmlDebug::Mouse ? 1 : 2;
|
||||
}
|
||||
|
||||
void InputEventsModel::loadData()
|
||||
{
|
||||
Q_D(InputEventsModel);
|
||||
clear();
|
||||
QmlProfilerDataModel *simpleModel = d->modelManager->qmlModel();
|
||||
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;
|
||||
insert(event.startTime, 0, event.typeIndex);
|
||||
d->modelManager->modelProxyCountUpdated(d->modelId, count(),
|
||||
simpleModel->getEvents().count());
|
||||
}
|
||||
d->collapsedRowCount = 2;
|
||||
d->expandedRowCount = 3;
|
||||
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1);
|
||||
}
|
||||
|
||||
bool InputEventsModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const
|
||||
{
|
||||
return AbstractTimelineModel::accepted(event) &&
|
||||
(event.detailType == QmlDebug::Mouse || event.detailType == QmlDebug::Key);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -30,17 +30,19 @@ class InputEventsModel : public QmlProfiler::AbstractTimelineModel
|
||||
class InputEventsModelPrivate;
|
||||
Q_DECLARE_PRIVATE(InputEventsModel)
|
||||
|
||||
protected:
|
||||
bool accepted(const QmlProfiler::QmlProfilerDataModel::QmlEventTypeData &event) const;
|
||||
|
||||
public:
|
||||
InputEventsModel(QObject *parent = 0);
|
||||
quint64 features() const;
|
||||
|
||||
int rowCount() const {return 0;}
|
||||
int selectionId(int) const {return -1;}
|
||||
QColor color(int) const {return QColor();}
|
||||
QVariantList labels() const {return QVariantList();}
|
||||
QVariantMap details(int) const {return QVariantMap();}
|
||||
int row(int) const {return -1;}
|
||||
void loadData() {}
|
||||
int selectionId(int index) const;
|
||||
QColor color(int index) const;
|
||||
QVariantList labels() const;
|
||||
QVariantMap details(int index) const;
|
||||
int row(int index) const;
|
||||
void loadData();
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user