QmlProfiler: Don't expose the vector of event types

We always want either the total number of event types or one specific
type. There is no need to expose the fact that we keep them as a vector.

Also, use int as the type of the "number" methods as that aligns better
with Qt containers, and rename the methods. We don't need to state the
fact that we've loaded the events and types at some point.

Change-Id: Iaf680ec9fa10e1070ddee6bcc079800e401775f0
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Ulf Hermann
2018-03-28 09:42:28 +02:00
parent 7ca958fa85
commit dcd8d37f35
19 changed files with 77 additions and 66 deletions

View File

@@ -127,9 +127,8 @@ QStringList QmlProfilerStatisticsModel::details(int typeIndex) const
QString data;
QString displayName;
const QVector<QmlEventType> &eventTypes = m_modelManager->eventTypes();
if (typeIndex >= 0 && typeIndex < eventTypes.count()) {
const QmlEventType &type = eventTypes.at(typeIndex);
if (typeIndex >= 0 && typeIndex < m_modelManager->numEventTypes()) {
const QmlEventType &type = m_modelManager->eventType(typeIndex);
displayName = nameForType(type.rangeType());
const QChar ellipsisChar(0x2026);
@@ -272,7 +271,7 @@ QVariant QmlProfilerStatisticsModel::data(const QModelIndex &index, int role) co
return dataForMainEntry(index, role);
const int typeIndex = index.row();
const QmlEventType &type = m_modelManager->eventTypes().at(typeIndex);
const QmlEventType &type = m_modelManager->eventType(typeIndex);
const QmlEventStats &stats = m_data.at(typeIndex);
switch (role) {
@@ -448,7 +447,7 @@ void QmlProfilerStatisticsModel::loadEvent(const QmlEvent &event, const QmlEvent
case RangeStart:
stack.push(event);
if (m_data.length() <= typeIndex)
m_data.resize(m_modelManager->numLoadedEventTypes());
m_data.resize(m_modelManager->numEventTypes());
break;
case RangeEnd: {
// update stats
@@ -610,13 +609,11 @@ QVariant QmlProfilerStatisticsRelativesModel::data(const QModelIndex &index, int
const QmlStatisticsRelativesData &stats = data.at(row);
QTC_ASSERT(stats.typeIndex >= 0, return QVariant());
const QVector<QmlEventType> &eventTypes = m_modelManager->eventTypes();
if (stats.typeIndex == QmlProfilerStatisticsModel::s_mainEntryTypeId)
return dataForMainEntry(stats.duration, role, index.column());
QTC_ASSERT(stats.typeIndex < eventTypes.size(), return QVariant());
const QmlEventType &type = eventTypes.at(stats.typeIndex);
QTC_ASSERT(stats.typeIndex < m_modelManager->numEventTypes(), return QVariant());
const QmlEventType &type = m_modelManager->eventType(stats.typeIndex);
switch (role) {
case TypeIdRole: