diff --git a/src/plugins/qmlprofiler/debugmessagesmodel.cpp b/src/plugins/qmlprofiler/debugmessagesmodel.cpp index d53f4fb5fb7..7ea435fdd2b 100644 --- a/src/plugins/qmlprofiler/debugmessagesmodel.cpp +++ b/src/plugins/qmlprofiler/debugmessagesmodel.cpp @@ -28,7 +28,7 @@ namespace QmlProfiler { namespace Internal { -bool DebugMessagesModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const +bool DebugMessagesModel::accepted(const QmlEventType &event) const { return event.message == DebugMessage; } @@ -78,8 +78,7 @@ QVariantList DebugMessagesModel::labels() const QVariantMap DebugMessagesModel::details(int index) const { - const QmlProfilerDataModel::QmlEventTypeData &type = - modelManager()->qmlModel()->getEventTypes()[m_data[index].typeId]; + const QmlEventType &type = modelManager()->qmlModel()->eventTypes()[m_data[index].typeId]; QVariantMap result; result.insert(QLatin1String("displayName"), messageType(type.detailType)); @@ -106,10 +105,10 @@ void DebugMessagesModel::loadData() if (simpleModel->isEmpty()) return; - const QVector &types = simpleModel->getEventTypes(); + const QVector &types = simpleModel->eventTypes(); - foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { - const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex()]; + foreach (const QmlEvent &event, simpleModel->events()) { + const QmlEventType &type = types[event.typeIndex()]; if (!accepted(type) || event.startTime() < 0) continue; @@ -117,7 +116,7 @@ void DebugMessagesModel::loadData() MessageData(event.stringData(), event.typeIndex())); if (type.detailType > m_maximumMsgType) m_maximumMsgType = event.typeIndex(); - updateProgress(count(), simpleModel->getEvents().count()); + updateProgress(count(), simpleModel->events().count()); } setCollapsedRowCount(2); setExpandedRowCount(m_maximumMsgType + 2); diff --git a/src/plugins/qmlprofiler/debugmessagesmodel.h b/src/plugins/qmlprofiler/debugmessagesmodel.h index 07cdbff92c3..8b23d6ac8e4 100644 --- a/src/plugins/qmlprofiler/debugmessagesmodel.h +++ b/src/plugins/qmlprofiler/debugmessagesmodel.h @@ -35,7 +35,7 @@ class DebugMessagesModel : public QmlProfilerTimelineModel Q_OBJECT protected: - bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const override; + bool accepted(const QmlEventType &event) const override; public: DebugMessagesModel(QmlProfilerModelManager *manager, QObject *parent = 0); diff --git a/src/plugins/qmlprofiler/flamegraphmodel.cpp b/src/plugins/qmlprofiler/flamegraphmodel.cpp index 45f26843fb8..8a11e5f840f 100644 --- a/src/plugins/qmlprofiler/flamegraphmodel.cpp +++ b/src/plugins/qmlprofiler/flamegraphmodel.cpp @@ -102,20 +102,18 @@ void FlameGraphModel::loadData(qint64 rangeStart, qint64 rangeEnd) beginResetModel(); clear(); - const QVector &eventList - = m_modelManager->qmlModel()->getEvents(); - const QVector &typesList - = m_modelManager->qmlModel()->getEventTypes(); + const QVector &eventList = m_modelManager->qmlModel()->events(); + const QVector &typesList = m_modelManager->qmlModel()->eventTypes(); // used by binding loop detection - QStack callStack; + QStack callStack; callStack.append(0); FlameGraphData *stackTop = &m_stackBottom; for (int i = 0; i < eventList.size(); ++i) { - const QmlProfilerDataModel::QmlEventData *event = &eventList[i]; + const QmlEvent *event = &eventList[i]; int typeIndex = event->typeIndex(); - const QmlProfilerDataModel::QmlEventTypeData *type = &typesList[typeIndex]; + const QmlEventType *type = &typesList[typeIndex]; if (!m_acceptedTypes.contains(type->rangeType)) continue; @@ -126,7 +124,7 @@ void FlameGraphModel::loadData(qint64 rangeStart, qint64 rangeEnd) continue; } - const QmlProfilerDataModel::QmlEventData *potentialParent = callStack.top(); + const QmlEvent *potentialParent = callStack.top(); while (potentialParent && potentialParent->startTime() + potentialParent->duration() <= event->startTime()) { callStack.pop(); @@ -187,9 +185,8 @@ QVariant FlameGraphModel::lookup(const FlameGraphData &stats, int role) const } if (stats.typeIndex != -1) { - const QVector &typeList = - m_modelManager->qmlModel()->getEventTypes(); - const QmlProfilerDataModel::QmlEventTypeData &type = typeList[stats.typeIndex]; + const QVector &typeList = m_modelManager->qmlModel()->eventTypes(); + const QmlEventType &type = typeList[stats.typeIndex]; switch (role) { case FilenameRole: return type.location.filename; @@ -216,7 +213,7 @@ FlameGraphData::~FlameGraphData() } FlameGraphData *FlameGraphModel::pushChild( - FlameGraphData *parent, const QmlProfilerDataModel::QmlEventData *data) + FlameGraphData *parent, const QmlEvent *data) { foreach (FlameGraphData *child, parent->children) { if (child->typeIndex == data->typeIndex()) { diff --git a/src/plugins/qmlprofiler/flamegraphmodel.h b/src/plugins/qmlprofiler/flamegraphmodel.h index d5815321d46..e2cd2cbd4da 100644 --- a/src/plugins/qmlprofiler/flamegraphmodel.h +++ b/src/plugins/qmlprofiler/flamegraphmodel.h @@ -91,8 +91,7 @@ private: QVariant lookup(const FlameGraphData &data, int role) const; void clear(); - FlameGraphData *pushChild(FlameGraphData *parent, - const QmlProfilerDataModel::QmlEventData *data); + FlameGraphData *pushChild(FlameGraphData *parent, const QmlEvent *data); int m_selectedTypeIndex; FlameGraphData m_stackBottom; diff --git a/src/plugins/qmlprofiler/inputeventsmodel.cpp b/src/plugins/qmlprofiler/inputeventsmodel.cpp index 010d5d21bbe..cda21cd4459 100644 --- a/src/plugins/qmlprofiler/inputeventsmodel.cpp +++ b/src/plugins/qmlprofiler/inputeventsmodel.cpp @@ -146,9 +146,9 @@ void InputEventsModel::loadData() if (simpleModel->isEmpty()) return; - const QVector &types = simpleModel->getEventTypes(); - foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { - const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex()]; + const QVector &types = simpleModel->eventTypes(); + foreach (const QmlEvent &event, simpleModel->events()) { + const QmlEventType &type = types[event.typeIndex()]; if (!accepted(type)) continue; @@ -162,7 +162,7 @@ void InputEventsModel::loadData() } else if (m_keyTypeId == -1) { m_keyTypeId = event.typeIndex(); } - updateProgress(count(), simpleModel->getEvents().count()); + updateProgress(count(), simpleModel->events().count()); } setCollapsedRowCount(2); setExpandedRowCount(3); @@ -176,7 +176,7 @@ void InputEventsModel::clear() QmlProfilerTimelineModel::clear(); } -bool InputEventsModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const +bool InputEventsModel::accepted(const QmlEventType &event) const { return QmlProfilerTimelineModel::accepted(event) && (event.detailType == Mouse || event.detailType == Key); diff --git a/src/plugins/qmlprofiler/inputeventsmodel.h b/src/plugins/qmlprofiler/inputeventsmodel.h index 0bb1d86b7bb..45b4b997e43 100644 --- a/src/plugins/qmlprofiler/inputeventsmodel.h +++ b/src/plugins/qmlprofiler/inputeventsmodel.h @@ -35,7 +35,7 @@ class InputEventsModel : public QmlProfilerTimelineModel Q_OBJECT protected: - bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const; + bool accepted(const QmlEventType &event) const; public: struct InputEvent { diff --git a/src/plugins/qmlprofiler/memoryusagemodel.cpp b/src/plugins/qmlprofiler/memoryusagemodel.cpp index 7f247d93004..1b988c96b57 100644 --- a/src/plugins/qmlprofiler/memoryusagemodel.cpp +++ b/src/plugins/qmlprofiler/memoryusagemodel.cpp @@ -82,7 +82,7 @@ QVariantMap MemoryUsageModel::location(int index) const int originType = m_data[index].originTypeIndex; if (originType > -1) { const QmlEventLocation &location = - modelManager()->qmlModel()->getEventTypes().at(originType).location; + modelManager()->qmlModel()->eventTypes().at(originType).location; result.insert(file, location.filename); result.insert(line, location.line); @@ -132,7 +132,7 @@ QVariantMap MemoryUsageModel::details(int index) const if (ev->originTypeIndex != -1) { result.insert(tr("Location"), - modelManager()->qmlModel()->getEventTypes().at(ev->originTypeIndex).displayName); + modelManager()->qmlModel()->eventTypes().at(ev->originTypeIndex).displayName); } return result; } @@ -159,9 +159,9 @@ void MemoryUsageModel::loadData() QStack rangeStack; - const QVector &types = simpleModel->getEventTypes(); - foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { - const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex()]; + const QVector &types = simpleModel->eventTypes(); + foreach (const QmlEvent &event, simpleModel->events()) { + const QmlEventType &type = types[event.typeIndex()]; while (!rangeStack.empty() && rangeStack.top().endTime < event.startTime()) rangeStack.pop(); if (!accepted(type)) { @@ -218,7 +218,7 @@ void MemoryUsageModel::loadData() } } - updateProgress(count(), simpleModel->getEvents().count()); + updateProgress(count(), simpleModel->events().count()); } if (currentJSHeapIndex != -1) diff --git a/src/plugins/qmlprofiler/pixmapcachemodel.cpp b/src/plugins/qmlprofiler/pixmapcachemodel.cpp index 895dc7ce39b..35aad750e52 100644 --- a/src/plugins/qmlprofiler/pixmapcachemodel.cpp +++ b/src/plugins/qmlprofiler/pixmapcachemodel.cpp @@ -174,9 +174,9 @@ void PixmapCacheModel::loadData() int lastCacheSizeEvent = -1; int cumulatedCount = 0; - const QVector &types = simpleModel->getEventTypes(); - foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { - const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex()]; + const QVector &types = simpleModel->eventTypes(); + foreach (const QmlEvent &event, simpleModel->events()) { + const QmlEventType &type = types[event.typeIndex()]; if (!accepted(type)) continue; @@ -398,7 +398,7 @@ void PixmapCacheModel::loadData() break; } - updateProgress(count(), 2 * simpleModel->getEvents().count()); + updateProgress(count(), 2 * simpleModel->events().count()); } if (lastCacheSizeEvent != -1) diff --git a/src/plugins/qmlprofiler/qmlevent.h b/src/plugins/qmlprofiler/qmlevent.h new file mode 100644 index 00000000000..830510c78df --- /dev/null +++ b/src/plugins/qmlprofiler/qmlevent.h @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#pragma once + +#include + +namespace QmlProfiler { + +struct QmlEvent { + QmlEvent(qint64 startTime = -1, qint64 duration = -1, int typeIndex = -1, + qint64 num0 = 0, qint64 num1 = 0, qint64 num2 = 0, qint64 num3 = 0, + qint64 num4 = 0) : + m_startTime(startTime), m_duration(duration), m_dataType(NumericData), + m_typeIndex(typeIndex) + { + m_numericData[0] = num0; + m_numericData[1] = num1; + m_numericData[2] = num2; + m_numericData[3] = num3; + m_numericData[4] = num4; + } + + QmlEvent(qint64 startTime, qint64 duration, int typeIndex, const QString &data) + : m_startTime(startTime), m_duration(duration), m_typeIndex(typeIndex) + { + assignStringData(data); + } + + QmlEvent(const QmlEvent &other) : + m_startTime(other.m_startTime), m_duration(other.m_duration), + m_dataType(other.m_dataType), m_typeIndex(other.m_typeIndex) + { + assignData(other); + } + + QmlEvent &operator=(const QmlEvent &other) + { + if (this != &other) { + if (m_dataType == StringData) + delete m_stringData; + + m_startTime = other.m_startTime; + m_duration = other.m_duration; + m_typeIndex = other.m_typeIndex; + m_dataType = other.m_dataType; + assignData(other); + } + return *this; + } + + ~QmlEvent() + { + if (m_dataType == StringData) + delete m_stringData; + } + + qint64 startTime() const { return m_startTime; } + void setStartTime(qint64 startTime) { m_startTime = startTime; } + + qint64 duration() const { return m_duration; } + void setDuration(qint64 duration) { m_duration = duration; } + + int typeIndex() const { return m_typeIndex; } + void setTypeIndex(int typeIndex) { m_typeIndex = typeIndex; } + + qint64 numericData(int i) const { return m_dataType == NumericData ? m_numericData[i] : 0; } + void setNumericData(int i, qint64 data) + { + if (m_dataType == StringData) + delete m_stringData; + + m_dataType = NumericData; + m_numericData[i] = data; + } + + QString stringData() const + { + switch (m_dataType) { + case NumericData: return QString(); + case StringData: return *m_stringData; + default: return QString::fromUtf8(m_characterData, m_characterDataLength); + } + } + + void setStringData(const QString &data) + { + if (m_dataType == StringData) + delete m_stringData; + + assignStringData(data); + } + + bool isValid() const + { + return m_startTime != -1; + } + +private: + + static const quint8 StringData = 254; + static const quint8 NumericData = 255; + + qint64 m_startTime; + qint64 m_duration; + union { + qint64 m_numericData[5]; + QString *m_stringData; + char m_characterData[5 * sizeof(qint64) + 3]; + }; + + union { + quint8 m_dataType; + quint8 m_characterDataLength; + }; + qint32 m_typeIndex; + + void assignData(const QmlEvent &other) + { + switch (m_dataType) { + case StringData: + m_stringData = new QString(*other.m_stringData); + break; + case NumericData: + for (int i = 0; i < 5; ++i) + m_numericData[i] = other.m_numericData[i]; + break; + default: + memcpy(m_characterData, other.m_characterData, m_characterDataLength); + break; + } + } + + void assignStringData(const QString &data) + { + QByteArray cdata = data.toUtf8(); + if (cdata.length() <= (int)sizeof(m_characterData)) { + m_characterDataLength = cdata.length(); + memcpy(m_characterData, cdata.constData(), m_characterDataLength); + } else { + m_dataType = StringData; + m_stringData = new QString(data); + } + } +}; + +} // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmleventtype.h b/src/plugins/qmlprofiler/qmleventtype.h new file mode 100644 index 00000000000..2a8c2385306 --- /dev/null +++ b/src/plugins/qmlprofiler/qmleventtype.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#pragma once + +#include "qmlprofilereventlocation.h" +#include "qmlprofilereventtypes.h" +#include + +namespace QmlProfiler { + +struct QmlEventType { + QmlEventType(const QString &displayName = QString(), + const QmlEventLocation &location = QmlEventLocation(), + Message message = MaximumMessage, RangeType rangeType = MaximumRangeType, + int detailType = -1, const QString &data = QString()) : + displayName(displayName), location(location), message(message), rangeType(rangeType), + detailType(detailType), data(data) + {} + + QString displayName; + QmlEventLocation location; + Message message; + RangeType rangeType; + int detailType; // can be EventType, BindingType, PixmapEventType or SceneGraphFrameType + QString data; +}; + +} // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmlnote.h b/src/plugins/qmlprofiler/qmlnote.h new file mode 100644 index 00000000000..cdfd768668b --- /dev/null +++ b/src/plugins/qmlprofiler/qmlnote.h @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#pragma once + +#include + +namespace QmlProfiler { + +struct QmlNote { + QmlNote(int typeIndex = -1, qint64 startTime = -1, qint64 duration = -1, + const QString &text = QString()) : + typeIndex(typeIndex), startTime(startTime), duration(duration), text(text) + {} + + int typeIndex; + qint64 startTime; + qint64 duration; + QString text; +}; + +} // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro index b0c5a3b529d..8fe65c66ffb 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.pro +++ b/src/plugins/qmlprofiler/qmlprofiler.pro @@ -50,6 +50,9 @@ HEADERS += \ localqmlprofilerrunner.h \ memoryusagemodel.h \ pixmapcachemodel.h \ + qmlevent.h \ + qmleventtype.h \ + qmlnote.h \ qmlprofiler_global.h \ qmlprofileranimationsmodel.h \ qmlprofilerattachdialog.h \ @@ -81,7 +84,7 @@ HEADERS += \ qmlprofilertracefile.h \ qmlprofilertraceview.h \ qmlprofilerviewmanager.h \ - scenegraphtimelinemodel.h \ + scenegraphtimelinemodel.h RESOURCES += \ qml/qmlprofiler.qrc diff --git a/src/plugins/qmlprofiler/qmlprofiler.qbs b/src/plugins/qmlprofiler/qmlprofiler.qbs index 7ab2feb1593..8dac527a66f 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.qbs +++ b/src/plugins/qmlprofiler/qmlprofiler.qbs @@ -27,6 +27,7 @@ QtcPlugin { "localqmlprofilerrunner.cpp", "localqmlprofilerrunner.h", "memoryusagemodel.cpp", "memoryusagemodel.h", "pixmapcachemodel.cpp", "pixmapcachemodel.h", + "qmlevent.h", "qmleventtype.h", "qmlnote.h", "qmlprofiler_global.h", "qmlprofileranimationsmodel.h", "qmlprofileranimationsmodel.cpp", "qmlprofilerattachdialog.cpp", "qmlprofilerattachdialog.h", diff --git a/src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp b/src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp index 65479c0429b..40158aa357e 100644 --- a/src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp @@ -54,7 +54,7 @@ void QmlProfilerAnimationsModel::clear() QmlProfilerTimelineModel::clear(); } -bool QmlProfilerAnimationsModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const +bool QmlProfilerAnimationsModel::accepted(const QmlEventType &event) const { return QmlProfilerTimelineModel::accepted(event) && event.detailType == AnimationFrame; } @@ -66,15 +66,15 @@ void QmlProfilerAnimationsModel::loadData() return; // collect events - const QVector &referenceList = simpleModel->getEvents(); - const QVector &typeList = simpleModel->getEventTypes(); + const QVector &referenceList = simpleModel->events(); + const QVector &typeList = simpleModel->eventTypes(); AnimationThread lastThread; QmlPaintEventData lastEvent; qint64 minNextStartTimes[] = {0, 0}; - foreach (const QmlProfilerDataModel::QmlEventData &event, referenceList) { - const QmlProfilerDataModel::QmlEventTypeData &type = typeList[event.typeIndex()]; + foreach (const QmlEvent &event, referenceList) { + const QmlEventType &type = typeList[event.typeIndex()]; if (!accepted(type)) continue; diff --git a/src/plugins/qmlprofiler/qmlprofileranimationsmodel.h b/src/plugins/qmlprofiler/qmlprofileranimationsmodel.h index 049a39d2330..2812c8b9b87 100644 --- a/src/plugins/qmlprofiler/qmlprofileranimationsmodel.h +++ b/src/plugins/qmlprofiler/qmlprofileranimationsmodel.h @@ -64,7 +64,7 @@ public: QVariantList labels() const; QVariantMap details(int index) const; - bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const; + bool accepted(const QmlEventType &event) const; protected: void loadData(); diff --git a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp index 72eadc8be3b..e81e41c8103 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp @@ -39,17 +39,17 @@ namespace QmlProfiler { class QmlProfilerDataModel::QmlProfilerDataModelPrivate { public: - QVector eventTypes; - QVector eventList; - QVector eventNotes; - QHash eventTypeIds; + QVector eventTypes; + QVector eventList; + QVector eventNotes; + QHash eventTypeIds; QmlProfilerModelManager *modelManager; int modelId; Internal::QmlProfilerDetailsRewriter *detailsRewriter; }; -QString getDisplayName(const QmlProfilerDataModel::QmlEventTypeData &event) +QString getDisplayName(const QmlEventType &event) { if (event.location.filename.isEmpty()) { return QmlProfilerDataModel::tr(""); @@ -60,7 +60,7 @@ QString getDisplayName(const QmlProfilerDataModel::QmlEventTypeData &event) } } -QString getInitialDetails(const QmlProfilerDataModel::QmlEventTypeData &event) +QString getInitialDetails(const QmlEventType &event) { QString details; // generate details string @@ -124,27 +124,27 @@ QmlProfilerDataModel::~QmlProfilerDataModel() delete d; } -const QVector &QmlProfilerDataModel::getEvents() const +const QVector &QmlProfilerDataModel::events() const { Q_D(const QmlProfilerDataModel); return d->eventList; } -const QVector &QmlProfilerDataModel::getEventTypes() const +const QVector &QmlProfilerDataModel::eventTypes() const { Q_D(const QmlProfilerDataModel); return d->eventTypes; } -const QVector &QmlProfilerDataModel::getEventNotes() const +const QVector &QmlProfilerDataModel::notes() const { Q_D(const QmlProfilerDataModel); return d->eventNotes; } void QmlProfilerDataModel::setData(qint64 traceStart, qint64 traceEnd, - const QVector &types, - const QVector &events) + const QVector &types, + const QVector &events) { Q_D(QmlProfilerDataModel); d->modelManager->traceTime()->setTime(traceStart, traceEnd); @@ -156,7 +156,7 @@ void QmlProfilerDataModel::setData(qint64 traceStart, qint64 traceEnd, d->modelManager->modelProxyCountUpdated(d->modelId, 1, 2); } -void QmlProfilerDataModel::setNoteData(const QVector ¬es) +void QmlProfilerDataModel::setNotes(const QVector ¬es) { Q_D(QmlProfilerDataModel); d->eventNotes = notes; @@ -186,13 +186,12 @@ bool QmlProfilerDataModel::isEmpty() const return d->eventList.isEmpty(); } -inline static bool operator<(const QmlProfilerDataModel::QmlEventData &t1, - const QmlProfilerDataModel::QmlEventData &t2) +inline static bool operator<(const QmlEvent &t1, const QmlEvent &t2) { return t1.startTime() < t2.startTime(); } -inline static uint qHash(const QmlProfilerDataModel::QmlEventTypeData &type) +inline static uint qHash(const QmlEventType &type) { return qHash(type.location.filename) ^ ((type.location.line & 0xfff) | // 12 bits of line number @@ -202,8 +201,8 @@ inline static uint qHash(const QmlProfilerDataModel::QmlEventTypeData &type) ((type.detailType << 28) & 0xf0000000)); // 4 bits of detailType } -inline static bool operator==(const QmlProfilerDataModel::QmlEventTypeData &type1, - const QmlProfilerDataModel::QmlEventTypeData &type2) +inline static bool operator==(const QmlEventType &type1, + const QmlEventType &type2) { return type1.message == type2.message && type1.rangeType == type2.rangeType && type1.detailType == type2.detailType && type1.location.line == type2.location.line && @@ -223,7 +222,7 @@ void QmlProfilerDataModel::processData() // rewrite strings int n = d->eventTypes.count(); for (int i = 0; i < n; i++) { - QmlEventTypeData *event = &d->eventTypes[i]; + QmlEventType *event = &d->eventTypes[i]; event->displayName = getDisplayName(*event); event->data = getInitialDetails(*event); @@ -251,21 +250,21 @@ void QmlProfilerDataModel::processData() emit requestReload(); } -void QmlProfilerDataModel::addQmlEvent(Message message, RangeType rangeType, int detailType, - qint64 startTime, qint64 duration, const QString &data, - const QmlEventLocation &location, qint64 ndata1, - qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5) +void QmlProfilerDataModel::addEvent(Message message, RangeType rangeType, int detailType, + qint64 startTime, qint64 duration, const QString &data, + const QmlEventLocation &location, qint64 ndata1, qint64 ndata2, + qint64 ndata3, qint64 ndata4, qint64 ndata5) { Q_D(QmlProfilerDataModel); QString displayName; - QmlEventTypeData typeData(displayName, location, message, rangeType, detailType, + QmlEventType typeData(displayName, location, message, rangeType, detailType, message == DebugMessage ? QString() : data); - QmlEventData eventData = (message == DebugMessage) ? - QmlEventData(startTime, duration, -1, data) : - QmlEventData(startTime, duration, -1, ndata1, ndata2, ndata3, ndata4, ndata5); + QmlEvent eventData = (message == DebugMessage) ? + QmlEvent(startTime, duration, -1, data) : + QmlEvent(startTime, duration, -1, ndata1, ndata2, ndata3, ndata4, ndata5); - QHash::Iterator it = d->eventTypeIds.find(typeData); + QHash::Iterator it = d->eventTypeIds.find(typeData); if (it != d->eventTypeIds.end()) { eventData.setTypeIndex(it.value()); } else { @@ -294,7 +293,7 @@ void QmlProfilerDataModel::detailsChanged(int requestId, const QString &newStrin Q_D(QmlProfilerDataModel); QTC_ASSERT(requestId < d->eventTypes.count(), return); - QmlEventTypeData *event = &d->eventTypes[requestId]; + QmlEventType *event = &d->eventTypes[requestId]; event->data = newString; } diff --git a/src/plugins/qmlprofiler/qmlprofilerdatamodel.h b/src/plugins/qmlprofiler/qmlprofilerdatamodel.h index cbb29df3b7a..c46cfa26087 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.h +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.h @@ -28,6 +28,9 @@ #include "qmlprofilermodelmanager.h" #include "qmlprofilereventtypes.h" #include "qmlprofilereventlocation.h" +#include "qmleventtype.h" +#include "qmlevent.h" +#include "qmlnote.h" #include @@ -37,188 +40,26 @@ class QMLPROFILER_EXPORT QmlProfilerDataModel : public QObject { Q_OBJECT public: - struct QmlEventTypeData { - QmlEventTypeData(const QString &displayName = QString(), - const QmlEventLocation &location = QmlEventLocation(), - Message message = MaximumMessage, RangeType rangeType = MaximumRangeType, - int detailType = -1, const QString &data = QString()) : - displayName(displayName), location(location), message(message), rangeType(rangeType), - detailType(detailType), data(data) - {} - - QString displayName; - QmlEventLocation location; - Message message; - RangeType rangeType; - int detailType; // can be EventType, BindingType, PixmapEventType or SceneGraphFrameType - QString data; - }; - - struct QmlEventData { - QmlEventData(qint64 startTime = -1, qint64 duration = -1, int typeIndex = -1, - qint64 num0 = 0, qint64 num1 = 0, qint64 num2 = 0, qint64 num3 = 0, - qint64 num4 = 0) : - m_startTime(startTime), m_duration(duration), m_dataType(NumericData), - m_typeIndex(typeIndex) - { - m_numericData[0] = num0; - m_numericData[1] = num1; - m_numericData[2] = num2; - m_numericData[3] = num3; - m_numericData[4] = num4; - } - - QmlEventData(qint64 startTime, qint64 duration, int typeIndex, const QString &data) - : m_startTime(startTime), m_duration(duration), m_typeIndex(typeIndex) - { - assignStringData(data); - } - - QmlEventData(const QmlEventData &other) : - m_startTime(other.m_startTime), m_duration(other.m_duration), - m_dataType(other.m_dataType), m_typeIndex(other.m_typeIndex) - { - assignData(other); - } - - QmlEventData &operator=(const QmlEventData &other) - { - if (this != &other) { - if (m_dataType == StringData) - delete m_stringData; - - m_startTime = other.m_startTime; - m_duration = other.m_duration; - m_typeIndex = other.m_typeIndex; - m_dataType = other.m_dataType; - assignData(other); - } - return *this; - } - - ~QmlEventData() - { - if (m_dataType == StringData) - delete m_stringData; - } - - qint64 startTime() const { return m_startTime; } - void setStartTime(qint64 startTime) { m_startTime = startTime; } - - qint64 duration() const { return m_duration; } - void setDuration(qint64 duration) { m_duration = duration; } - - int typeIndex() const { return m_typeIndex; } - void setTypeIndex(int typeIndex) { m_typeIndex = typeIndex; } - - qint64 numericData(int i) const { return m_dataType == NumericData ? m_numericData[i] : 0; } - void setNumericData(int i, qint64 data) - { - if (m_dataType == StringData) - delete m_stringData; - - m_dataType = NumericData; - m_numericData[i] = data; - } - - QString stringData() const - { - switch (m_dataType) { - case NumericData: return QString(); - case StringData: return *m_stringData; - default: return QString::fromUtf8(m_characterData, m_characterDataLength); - } - } - - void setStringData(const QString &data) - { - if (m_dataType == StringData) - delete m_stringData; - - assignStringData(data); - } - - private: - - static const quint8 StringData = 254; - static const quint8 NumericData = 255; - - qint64 m_startTime; - qint64 m_duration; - union { - qint64 m_numericData[5]; - QString *m_stringData; - char m_characterData[5 * sizeof(qint64) + 3]; - }; - - union { - quint8 m_dataType; - quint8 m_characterDataLength; - }; - qint32 m_typeIndex; - - void assignData(const QmlEventData &other) - { - switch (m_dataType) { - case StringData: - m_stringData = new QString(*other.m_stringData); - break; - case NumericData: - for (int i = 0; i < 5; ++i) - m_numericData[i] = other.m_numericData[i]; - break; - default: - memcpy(m_characterData, other.m_characterData, m_characterDataLength); - break; - } - } - - void assignStringData(const QString &data) - { - QByteArray cdata = data.toUtf8(); - if (cdata.length() <= (int)sizeof(m_characterData)) { - m_characterDataLength = cdata.length(); - memcpy(m_characterData, cdata.constData(), m_characterDataLength); - } else { - m_dataType = StringData; - m_stringData = new QString(data); - } - } - }; - - struct QmlEventNoteData { - QmlEventNoteData(int typeIndex = -1, qint64 startTime = -1, qint64 duration = -1, - const QString &text = QString()) : - typeIndex(typeIndex), startTime(startTime), duration(duration), text(text) - {} - - int typeIndex; - qint64 startTime; - qint64 duration; - QString text; - }; - static QString formatTime(qint64 timestamp); explicit QmlProfilerDataModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent); ~QmlProfilerDataModel(); - const QVector &getEvents() const; - const QVector &getEventTypes() const; - const QVector &getEventNotes() const; - void setData(qint64 traceStart, qint64 traceEnd, const QVector &types, - const QVector &events); - void setNoteData(const QVector ¬es); + const QVector &events() const; + const QVector &eventTypes() const; + const QVector ¬es() const; + void setData(qint64 traceStart, qint64 traceEnd, const QVector &types, + const QVector &events); + void setNotes(const QVector ¬es); void processData(); int count() const; void clear(); bool isEmpty() const; - void addQmlEvent(Message message, RangeType rangeType, int bindingType, - qint64 startTime, qint64 duration, const QString &data, - const QmlEventLocation &location, qint64 ndata1, qint64 ndata2, - qint64 ndata3, qint64 ndata4, qint64 ndata5); + void addEvent(Message message, RangeType rangeType, int bindingType, qint64 startTime, + qint64 duration, const QString &data, const QmlEventLocation &location, + qint64 ndata1, qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5); qint64 lastTimeMark() const; signals: @@ -235,4 +76,4 @@ private: Q_DECLARE_PRIVATE(QmlProfilerDataModel) }; -} +} // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp index e03726a99ea..37799cd9e72 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp @@ -290,16 +290,16 @@ void QmlProfilerModelManager::addQmlEvent(Message message, RangeType rangeType, d->traceTime->setTime(startTime, startTime + d->traceTime->duration()); QTC_ASSERT(state() == AcquiringData, /**/); - d->model->addQmlEvent(message, rangeType, detailType, startTime, length, data, location, - ndata1, ndata2, ndata3, ndata4, ndata5); + d->model->addEvent(message, rangeType, detailType, startTime, length, data, location, ndata1, + ndata2, ndata3, ndata4, ndata5); } void QmlProfilerModelManager::addDebugMessage(QtMsgType type, qint64 timestamp, const QString &text, const QmlEventLocation &location) { if (state() == AcquiringData) - d->model->addQmlEvent(DebugMessage, MaximumRangeType, type, timestamp, 0, text, location, 0, - 0, 0, 0, 0); + d->model->addEvent(DebugMessage, MaximumRangeType, type, timestamp, 0, text, location, 0, 0, + 0, 0, 0); } void QmlProfilerModelManager::acquiringDone() @@ -334,8 +334,8 @@ void QmlProfilerModelManager::save(const QString &filename) QmlProfilerFileWriter *writer = new QmlProfilerFileWriter(this); writer->setTraceTime(traceTime()->startTime(), traceTime()->endTime(), traceTime()->duration()); - writer->setQmlEvents(d->model->getEventTypes(), d->model->getEvents()); - writer->setNotes(d->model->getEventNotes()); + writer->setData(d->model->eventTypes(), d->model->events()); + writer->setNotes(d->model->notes()); connect(writer, &QObject::destroyed, this, &QmlProfilerModelManager::saveFinished, Qt::QueuedConnection); @@ -372,8 +372,8 @@ void QmlProfilerModelManager::load(const QString &filename) connect(reader, &QmlProfilerFileReader::success, this, [this, reader]() { d->model->setData(reader->traceStart(), qMax(reader->traceStart(), reader->traceEnd()), - reader->qmlEvents(), reader->ranges()); - d->model->setNoteData(reader->notes()); + reader->eventTypes(), reader->events()); + d->model->setNotes(reader->notes()); setRecordedFeatures(reader->loadedFeatures()); d->traceTime->increaseEndTime(d->model->lastTimeMark()); delete reader; diff --git a/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp b/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp index 0b18a3f979a..c656763c674 100644 --- a/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp @@ -70,10 +70,9 @@ void QmlProfilerNotesModel::loadData() { blockSignals(true); clear(); - const QVector ¬es = - m_modelManager->qmlModel()->getEventNotes(); + const QVector ¬es = m_modelManager->qmlModel()->notes(); for (int i = 0; i != notes.size(); ++i) { - const QmlProfilerDataModel::QmlEventNoteData ¬e = notes[i]; + const QmlNote ¬e = notes[i]; add(note.typeIndex, note.startTime, note.duration, note.text); } resetModified(); @@ -83,14 +82,14 @@ void QmlProfilerNotesModel::loadData() void QmlProfilerNotesModel::saveData() { - QVector notes; + QVector notes; for (int i = 0; i < count(); ++i) { const Timeline::TimelineModel *model = timelineModelByModelId(timelineModel(i)); if (!model) continue; int index = timelineIndex(i); - QmlProfilerDataModel::QmlEventNoteData save = { + QmlNote save = { model->typeId(index), model->startTime(index), model->duration(index), @@ -98,7 +97,7 @@ void QmlProfilerNotesModel::saveData() }; notes.append(save); } - m_modelManager->qmlModel()->setNoteData(notes); + m_modelManager->qmlModel()->setNotes(notes); resetModified(); } } diff --git a/src/plugins/qmlprofiler/qmlprofilerrangemodel.cpp b/src/plugins/qmlprofiler/qmlprofilerrangemodel.cpp index f93e0482600..35bfd566905 100644 --- a/src/plugins/qmlprofiler/qmlprofilerrangemodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerrangemodel.cpp @@ -71,10 +71,10 @@ void QmlProfilerRangeModel::loadData() return; // collect events - const QVector &eventList = simpleModel->getEvents(); - const QVector &typesList = simpleModel->getEventTypes(); - foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) { - const QmlProfilerDataModel::QmlEventTypeData &type = typesList[event.typeIndex()]; + const QVector &eventList = simpleModel->events(); + const QVector &typesList = simpleModel->eventTypes(); + foreach (const QmlEvent &event, eventList) { + const QmlEventType &type = typesList[event.typeIndex()]; if (!accepted(type)) continue; @@ -204,8 +204,7 @@ QVariantList QmlProfilerRangeModel::labels() const { QVariantList result; - const QVector &types = - modelManager()->qmlModel()->getEventTypes(); + const QVector &types = modelManager()->qmlModel()->eventTypes(); for (int i = 1; i < expandedRowCount(); i++) { // Ignore the -1 for the first row QVariantMap element; int typeId = m_expandedRowTypes[i]; @@ -222,8 +221,7 @@ QVariantMap QmlProfilerRangeModel::details(int index) const { QVariantMap result; int id = selectionId(index); - const QVector &types = - modelManager()->qmlModel()->getEventTypes(); + const QVector &types = modelManager()->qmlModel()->eventTypes(); result.insert(QStringLiteral("displayName"), tr(QmlProfilerModelManager::featureName(mainFeature()))); @@ -247,11 +245,10 @@ int QmlProfilerRangeModel::typeId(int index) const int QmlProfilerRangeModel::selectionIdForLocation(const QString &filename, int line, int column) const { // if this is called from v8 view, we don't have the column number, it will be -1 - const QVector &types = - modelManager()->qmlModel()->getEventTypes(); + const QVector &types = modelManager()->qmlModel()->eventTypes(); for (int i = 1; i < expandedRowCount(); ++i) { int typeId = m_expandedRowTypes[i]; - const QmlProfilerDataModel::QmlEventTypeData &eventData = types[typeId]; + const QmlEventType &eventData = types[typeId]; if (eventData.location.filename == filename && eventData.location.line == line && (column == -1 || eventData.location.column == column)) diff --git a/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp b/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp index 743a2b72fff..46baa6645a6 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp @@ -97,9 +97,9 @@ const QHash &QmlProfilerStatisti return d->data; } -const QVector &QmlProfilerStatisticsModel::getTypes() const +const QVector &QmlProfilerStatisticsModel::getTypes() const { - return d->modelManager->qmlModel()->getEventTypes(); + return d->modelManager->qmlModel()->eventTypes(); } const QHash &QmlProfilerStatisticsModel::getNotes() const @@ -176,18 +176,16 @@ void QmlProfilerStatisticsModel::loadData(qint64 rangeStart, qint64 rangeEnd) const bool checkRanges = (rangeStart != -1) && (rangeEnd != -1); - const QVector &eventList - = d->modelManager->qmlModel()->getEvents(); - const QVector &typesList - = d->modelManager->qmlModel()->getEventTypes(); + const QVector &eventList = d->modelManager->qmlModel()->events(); + const QVector &typesList = d->modelManager->qmlModel()->eventTypes(); // used by binding loop detection - QStack callStack; + QStack callStack; callStack.push(0); // artificial root for (int i = 0; i < eventList.size(); ++i) { - const QmlProfilerDataModel::QmlEventData *event = &eventList[i]; - const QmlProfilerDataModel::QmlEventTypeData *type = &typesList[event->typeIndex()]; + const QmlEvent *event = &eventList[i]; + const QmlEventType *type = &typesList[event->typeIndex()]; if (!d->acceptedTypes.contains(type->rangeType)) continue; @@ -221,7 +219,7 @@ void QmlProfilerStatisticsModel::loadData(qint64 rangeStart, qint64 rangeEnd) // // binding loop detection // - const QmlProfilerDataModel::QmlEventData *potentialParent = callStack.top(); + const QmlEvent *potentialParent = callStack.top(); while (potentialParent && !(potentialParent->startTime() + potentialParent->duration() > event->startTime())) { callStack.pop(); @@ -315,10 +313,9 @@ QmlProfilerStatisticsRelativesModel::getData(int typeId) const } } -const QVector & -QmlProfilerStatisticsRelativesModel::getTypes() const +const QVector &QmlProfilerStatisticsRelativesModel::getTypes() const { - return m_modelManager->qmlModel()->getEventTypes(); + return m_modelManager->qmlModel()->eventTypes(); } int QmlProfilerStatisticsRelativesModel::count() const @@ -360,9 +357,9 @@ void QmlProfilerStatisticsParentsModel::loadData() // compute parent-child relationship and call count QHash lastParent; - const QVector eventList = simpleModel->getEvents(); - const QVector typesList = simpleModel->getEventTypes(); - foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) { + const QVector eventList = simpleModel->events(); + const QVector typesList = simpleModel->eventTypes(); + foreach (const QmlEvent &event, eventList) { // whitelist if (!m_statisticsModel->eventTypeAccepted(typesList[event.typeIndex()].rangeType)) continue; @@ -422,9 +419,9 @@ void QmlProfilerStatisticsChildrenModel::loadData() // compute parent-child relationship and call count QHash lastParent; - const QVector &eventList = simpleModel->getEvents(); - const QVector &typesList = simpleModel->getEventTypes(); - foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) { + const QVector &eventList = simpleModel->events(); + const QVector &typesList = simpleModel->eventTypes(); + foreach (const QmlEvent &event, eventList) { // whitelist if (!m_statisticsModel->eventTypeAccepted(typesList[event.typeIndex()].rangeType)) continue; diff --git a/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.h b/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.h index 9ac8fe3e81f..c81c074113d 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.h +++ b/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.h @@ -65,7 +65,7 @@ public: bool eventTypeAccepted(RangeType) const; const QHash &getData() const; - const QVector &getTypes() const; + const QVector &getTypes() const; const QHash &getNotes() const; int count() const; @@ -112,7 +112,7 @@ public: void clear(); const QmlStatisticsRelativesMap &getData(int typeId) const; - const QVector &getTypes() const; + const QVector &getTypes() const; protected: virtual void loadData() = 0; diff --git a/src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp b/src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp index 43c8d026bd8..00b5ef1edb6 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp @@ -57,7 +57,7 @@ struct Colors { QColor defaultBackground; }; -struct RootEventType : public QmlProfilerDataModel::QmlEventTypeData { +struct RootEventType : public QmlEventType { RootEventType() { QString rootEventName = QmlProfilerStatisticsMainView::tr(""); @@ -555,8 +555,7 @@ void QmlProfilerStatisticsMainView::buildModel() void QmlProfilerStatisticsMainView::updateNotes(int typeIndex) { - const QHash &eventList = - d->model->getData(); + const QHash &eventList = d->model->getData(); const QHash ¬eList = d->model->getNotes(); QStandardItem *parentItem = d->m_model->invisibleRootItem(); @@ -585,17 +584,15 @@ void QmlProfilerStatisticsMainView::updateNotes(int typeIndex) void QmlProfilerStatisticsMainView::parseModel() { - const QHash &eventList = - d->model->getData(); - const QVector &typeList = d->model->getTypes(); + const QHash &eventList = d->model->getData(); + const QVector &typeList = d->model->getTypes(); QHash::ConstIterator it; for (it = eventList.constBegin(); it != eventList.constEnd(); ++it) { int typeIndex = it.key(); const QmlProfilerStatisticsModel::QmlEventStats &stats = it.value(); - const QmlProfilerDataModel::QmlEventTypeData &event = - (typeIndex != -1 ? typeList[typeIndex] : *rootEventType()); + const QmlEventType &event = (typeIndex != -1 ? typeList[typeIndex] : *rootEventType()); QStandardItem *parentItem = d->m_model->invisibleRootItem(); QList newRow; @@ -889,14 +886,13 @@ void QmlProfilerStatisticsRelativesView::rebuildTree( treeModel()->clear(); QStandardItem *topLevelItem = treeModel()->invisibleRootItem(); - const QVector &typeList = d->model->getTypes(); + const QVector &typeList = d->model->getTypes(); QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesMap::const_iterator it; for (it = map.constBegin(); it != map.constEnd(); ++it) { const QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesData &event = it.value(); int typeIndex = it.key(); - const QmlProfilerDataModel::QmlEventTypeData &type = - (typeIndex != -1 ? typeList[typeIndex] : *rootEventType()); + const QmlEventType &type = (typeIndex != -1 ? typeList[typeIndex] : *rootEventType()); QList newRow; // ToDo: here we were going to search for the data in the other model diff --git a/src/plugins/qmlprofiler/qmlprofilertimelinemodel.cpp b/src/plugins/qmlprofiler/qmlprofilertimelinemodel.cpp index 7e1f9136124..f67aeca8ec6 100644 --- a/src/plugins/qmlprofiler/qmlprofilertimelinemodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertimelinemodel.cpp @@ -57,7 +57,7 @@ ProfileFeature QmlProfilerTimelineModel::mainFeature() const return m_mainFeature; } -bool QmlProfilerTimelineModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const +bool QmlProfilerTimelineModel::accepted(const QmlEventType &event) const { return (event.rangeType == m_rangeType && event.message == m_message); } @@ -67,7 +67,7 @@ bool QmlProfilerTimelineModel::handlesTypeId(int typeIndex) const if (typeIndex < 0) return false; - return accepted(modelManager()->qmlModel()->getEventTypes().at(typeIndex)); + return accepted(modelManager()->qmlModel()->eventTypes().at(typeIndex)); } void QmlProfilerTimelineModel::clear() @@ -127,7 +127,7 @@ QVariantMap QmlProfilerTimelineModel::locationFromTypeId(int index) const if (id < 0) return result; - auto types = modelManager()->qmlModel()->getEventTypes(); + auto types = modelManager()->qmlModel()->eventTypes(); if (id >= types.length()) return result; diff --git a/src/plugins/qmlprofiler/qmlprofilertimelinemodel.h b/src/plugins/qmlprofiler/qmlprofilertimelinemodel.h index a16bb12925b..816db44710b 100644 --- a/src/plugins/qmlprofiler/qmlprofilertimelinemodel.h +++ b/src/plugins/qmlprofiler/qmlprofilertimelinemodel.h @@ -48,7 +48,7 @@ public: Message message() const; ProfileFeature mainFeature() const; - virtual bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const; + virtual bool accepted(const QmlEventType &event) const; bool handlesTypeId(int typeId) const; Q_INVOKABLE virtual int bindingLoopDest(int index) const; QVariantMap locationFromTypeId(int index) const; diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp index 567b167bdfc..62c78c85f7d 100644 --- a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp @@ -158,17 +158,17 @@ bool QmlProfilerFileReader::load(QIODevice *device) } if (elementName == _("eventData")) { - loadEventData(stream); + loadEventTypes(stream); break; } if (elementName == _("profilerDataModel")) { - loadProfilerDataModel(stream); + loadEvents(stream); break; } if (elementName == _("noteData")) { - loadNoteData(stream); + loadNotes(stream); break; } @@ -192,13 +192,13 @@ quint64 QmlProfilerFileReader::loadedFeatures() const return m_loadedFeatures; } -ProfileFeature featureFromEvent(const QmlProfilerDataModel::QmlEventTypeData &event) { - if (event.rangeType < MaximumRangeType) - return featureFromRangeType(event.rangeType); +ProfileFeature featureFromType(const QmlEventType &type) { + if (type.rangeType < MaximumRangeType) + return featureFromRangeType(type.rangeType); - switch (event.message) { + switch (type.message) { case Event: - switch (event.detailType) { + switch (type.detailType) { case AnimationFrame: return ProfileAnimations; case Key: @@ -220,12 +220,12 @@ ProfileFeature featureFromEvent(const QmlProfilerDataModel::QmlEventTypeData &ev } } -void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream) +void QmlProfilerFileReader::loadEventTypes(QXmlStreamReader &stream) { QTC_ASSERT(stream.name() == _("eventData"), return); - int eventIndex = -1; - QmlProfilerDataModel::QmlEventTypeData event = { + int typeIndex = -1; + QmlEventType type = { QString(), // displayname QmlEventLocation(), MaximumMessage, @@ -233,7 +233,7 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream) QmlBinding, // bindingType, set for backwards compatibility QString(), // details }; - const QmlProfilerDataModel::QmlEventTypeData defaultEvent = event; + const QmlEventType defaultEvent = type; while (!stream.atEnd() && !stream.hasError()) { if (isCanceled()) @@ -246,14 +246,14 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream) case QXmlStreamReader::StartElement: { if (elementName == _("event")) { progress(stream.device()); - event = defaultEvent; + type = defaultEvent; const QXmlStreamAttributes attributes = stream.attributes(); if (attributes.hasAttribute(_("index"))) { - eventIndex = attributes.value(_("index")).toInt(); + typeIndex = attributes.value(_("index")).toInt(); } else { // ignore event - eventIndex = -1; + typeIndex = -1; } break; } @@ -265,47 +265,47 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream) const QString readData = stream.text().toString(); if (elementName == _("displayname")) { - event.displayName = readData; + type.displayName = readData; break; } if (elementName == _("type")) { QPair enums = qmlTypeAsEnum(readData); - event.message = enums.first; - event.rangeType = enums.second; + type.message = enums.first; + type.rangeType = enums.second; break; } if (elementName == _("filename")) { - event.location.filename = readData; + type.location.filename = readData; break; } if (elementName == _("line")) { - event.location.line = readData.toInt(); + type.location.line = readData.toInt(); break; } if (elementName == _("column")) { - event.location.column = readData.toInt(); + type.location.column = readData.toInt(); break; } if (elementName == _("details")) { - event.data = readData; + type.data = readData; break; } if (elementName == _("animationFrame")) { - event.detailType = readData.toInt(); + type.detailType = readData.toInt(); // new animation frames used to be saved as ranges of range type Painting with // binding type 4 (which was called "AnimationFrame" to make everything even more // confusing), even though they clearly aren't ranges. Convert that to something // sane here. - if (event.detailType == 4) { - event.message = Event; - event.rangeType = MaximumRangeType; - event.detailType = AnimationFrame; + if (type.detailType == 4) { + type.message = Event; + type.rangeType = MaximumRangeType; + type.detailType = AnimationFrame; } } @@ -316,7 +316,7 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream) elementName == _("mouseEvent") || elementName == _("keyEvent") || elementName == _("level")) { - event.detailType = readData.toInt(); + type.detailType = readData.toInt(); break; } @@ -324,11 +324,11 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream) } case QXmlStreamReader::EndElement: { if (elementName == _("event")) { - if (eventIndex >= 0) { - if (eventIndex >= m_qmlEvents.size()) - m_qmlEvents.resize(eventIndex + 1); - m_qmlEvents[eventIndex] = event; - ProfileFeature feature = featureFromEvent(event); + if (typeIndex >= 0) { + if (typeIndex >= m_eventTypes.size()) + m_eventTypes.resize(typeIndex + 1); + m_eventTypes[typeIndex] = type; + ProfileFeature feature = featureFromType(type); if (feature != MaximumProfileFeature) m_loadedFeatures |= (1ULL << static_cast(feature)); } @@ -346,7 +346,7 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream) } } -void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream) +void QmlProfilerFileReader::loadEvents(QXmlStreamReader &stream) { QTC_ASSERT(stream.name() == _("profilerDataModel"), return); @@ -361,7 +361,7 @@ void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream) case QXmlStreamReader::StartElement: { if (elementName == _("range")) { progress(stream.device()); - QmlProfilerDataModel::QmlEventData range(0, 0, -1, 0, 0, 0, 0, 0); + QmlEvent event(0, 0, -1, 0, 0, 0, 0, 0); const QXmlStreamAttributes attributes = stream.attributes(); if (!attributes.hasAttribute(_("startTime")) @@ -370,47 +370,47 @@ void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream) continue; } - range.setStartTime(attributes.value(_("startTime")).toLongLong()); + event.setStartTime(attributes.value(_("startTime")).toLongLong()); if (attributes.hasAttribute(_("duration"))) - range.setDuration(attributes.value(_("duration")).toLongLong()); + event.setDuration(attributes.value(_("duration")).toLongLong()); // attributes for special events if (attributes.hasAttribute(_("framerate"))) - range.setNumericData(0, attributes.value(_("framerate")).toLongLong()); + event.setNumericData(0, attributes.value(_("framerate")).toLongLong()); if (attributes.hasAttribute(_("animationcount"))) - range.setNumericData(1, attributes.value(_("animationcount")).toLongLong()); + event.setNumericData(1, attributes.value(_("animationcount")).toLongLong()); if (attributes.hasAttribute(_("thread"))) - range.setNumericData(2, attributes.value(_("thread")).toLongLong()); + event.setNumericData(2, attributes.value(_("thread")).toLongLong()); if (attributes.hasAttribute(_("width"))) - range.setNumericData(0, attributes.value(_("width")).toLongLong()); + event.setNumericData(0, attributes.value(_("width")).toLongLong()); if (attributes.hasAttribute(_("height"))) - range.setNumericData(1, attributes.value(_("height")).toLongLong()); + event.setNumericData(1, attributes.value(_("height")).toLongLong()); if (attributes.hasAttribute(_("refCount"))) - range.setNumericData(2, attributes.value(_("refCount")).toLongLong()); + event.setNumericData(2, attributes.value(_("refCount")).toLongLong()); if (attributes.hasAttribute(_("amount"))) - range.setNumericData(0, attributes.value(_("amount")).toLongLong()); + event.setNumericData(0, attributes.value(_("amount")).toLongLong()); if (attributes.hasAttribute(_("timing1"))) - range.setNumericData(0, attributes.value(_("timing1")).toLongLong()); + event.setNumericData(0, attributes.value(_("timing1")).toLongLong()); if (attributes.hasAttribute(_("timing2"))) - range.setNumericData(1, attributes.value(_("timing2")).toLongLong()); + event.setNumericData(1, attributes.value(_("timing2")).toLongLong()); if (attributes.hasAttribute(_("timing3"))) - range.setNumericData(2, attributes.value(_("timing3")).toLongLong()); + event.setNumericData(2, attributes.value(_("timing3")).toLongLong()); if (attributes.hasAttribute(_("timing4"))) - range.setNumericData(3, attributes.value(_("timing4")).toLongLong()); + event.setNumericData(3, attributes.value(_("timing4")).toLongLong()); if (attributes.hasAttribute(_("timing5"))) - range.setNumericData(4, attributes.value(_("timing5")).toLongLong()); + event.setNumericData(4, attributes.value(_("timing5")).toLongLong()); if (attributes.hasAttribute(_("type"))) - range.setNumericData(0, attributes.value(_("type")).toLongLong()); + event.setNumericData(0, attributes.value(_("type")).toLongLong()); if (attributes.hasAttribute(_("data1"))) - range.setNumericData(1, attributes.value(_("data1")).toLongLong()); + event.setNumericData(1, attributes.value(_("data1")).toLongLong()); if (attributes.hasAttribute(_("data2"))) - range.setNumericData(2, attributes.value(_("data2")).toLongLong()); + event.setNumericData(2, attributes.value(_("data2")).toLongLong()); if (attributes.hasAttribute(_("text"))) - range.setStringData(attributes.value(_("text")).toString()); + event.setStringData(attributes.value(_("text")).toString()); - range.setTypeIndex(attributes.value(_("eventIndex")).toInt()); + event.setTypeIndex(attributes.value(_("eventIndex")).toInt()); - m_ranges.append(range); + m_events.append(event); } break; } @@ -426,9 +426,9 @@ void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream) } } -void QmlProfilerFileReader::loadNoteData(QXmlStreamReader &stream) +void QmlProfilerFileReader::loadNotes(QXmlStreamReader &stream) { - QmlProfilerDataModel::QmlEventNoteData currentNote; + QmlNote currentNote; while (!stream.atEnd() && !stream.hasError()) { if (isCanceled()) return; @@ -494,14 +494,14 @@ void QmlProfilerFileWriter::setTraceTime(qint64 startTime, qint64 endTime, qint6 m_measuredTime = measuredTime; } -void QmlProfilerFileWriter::setQmlEvents(const QVector &types, - const QVector &events) +void QmlProfilerFileWriter::setData(const QVector &types, + const QVector &events) { - m_qmlEvents = types; - m_ranges = events; + m_eventTypes = types; + m_events = events; } -void QmlProfilerFileWriter::setNotes(const QVector ¬es) +void QmlProfilerFileWriter::setNotes(const QVector ¬es) { m_notes = notes; } @@ -515,7 +515,7 @@ void QmlProfilerFileWriter::save(QIODevice *device) { if (m_future) { m_future->setProgressRange(0, - qMax(m_qmlEvents.size() + m_ranges.size() + m_notes.size(), 1)); + qMax(m_eventTypes.size() + m_events.size() + m_notes.size(), 1)); m_future->setProgressValue(0); m_newProgressValue = 0; } @@ -534,49 +534,49 @@ void QmlProfilerFileWriter::save(QIODevice *device) stream.writeStartElement(_("eventData")); stream.writeAttribute(_("totalTime"), QString::number(m_measuredTime)); - for (int typeIndex = 0; typeIndex < m_qmlEvents.size(); ++typeIndex) { + for (int typeIndex = 0; typeIndex < m_eventTypes.size(); ++typeIndex) { if (isCanceled()) return; - const QmlProfilerDataModel::QmlEventTypeData &event = m_qmlEvents[typeIndex]; + const QmlEventType &type = m_eventTypes[typeIndex]; stream.writeStartElement(_("event")); stream.writeAttribute(_("index"), QString::number(typeIndex)); - stream.writeTextElement(_("displayname"), event.displayName); - stream.writeTextElement(_("type"), qmlTypeAsString(event.message, event.rangeType)); - if (!event.location.filename.isEmpty()) { - stream.writeTextElement(_("filename"), event.location.filename); - stream.writeTextElement(_("line"), QString::number(event.location.line)); - stream.writeTextElement(_("column"), QString::number(event.location.column)); + stream.writeTextElement(_("displayname"), type.displayName); + stream.writeTextElement(_("type"), qmlTypeAsString(type.message, type.rangeType)); + if (!type.location.filename.isEmpty()) { + stream.writeTextElement(_("filename"), type.location.filename); + stream.writeTextElement(_("line"), QString::number(type.location.line)); + stream.writeTextElement(_("column"), QString::number(type.location.column)); } - if (!event.data.isEmpty()) - stream.writeTextElement(_("details"), event.data); + if (!type.data.isEmpty()) + stream.writeTextElement(_("details"), type.data); - if (event.rangeType == Binding) { - stream.writeTextElement(_("bindingType"), QString::number(event.detailType)); - } else if (event.message == Event) { - switch (event.detailType) { + if (type.rangeType == Binding) { + stream.writeTextElement(_("bindingType"), QString::number(type.detailType)); + } else if (type.message == Event) { + switch (type.detailType) { case AnimationFrame: - stream.writeTextElement(_("animationFrame"), QString::number(event.detailType)); + stream.writeTextElement(_("animationFrame"), QString::number(type.detailType)); break; case Key: - stream.writeTextElement(_("keyEvent"), QString::number(event.detailType)); + stream.writeTextElement(_("keyEvent"), QString::number(type.detailType)); break; case Mouse: - stream.writeTextElement(_("mouseEvent"), QString::number(event.detailType)); + stream.writeTextElement(_("mouseEvent"), QString::number(type.detailType)); break; default: break; } - } else if (event.message == PixmapCacheEvent) { - stream.writeTextElement(_("cacheEventType"), QString::number(event.detailType)); - } else if (event.message == SceneGraphFrame) { - stream.writeTextElement(_("sgEventType"), QString::number(event.detailType)); - } else if (event.message == MemoryAllocation) { - stream.writeTextElement(_("memoryEventType"), QString::number(event.detailType)); - } else if (event.message == DebugMessage) { - stream.writeTextElement(_("level"), QString::number(event.detailType)); + } else if (type.message == PixmapCacheEvent) { + stream.writeTextElement(_("cacheEventType"), QString::number(type.detailType)); + } else if (type.message == SceneGraphFrame) { + stream.writeTextElement(_("sgEventType"), QString::number(type.detailType)); + } else if (type.message == MemoryAllocation) { + stream.writeTextElement(_("memoryEventType"), QString::number(type.detailType)); + } else if (type.message == DebugMessage) { + stream.writeTextElement(_("level"), QString::number(type.detailType)); } stream.writeEndElement(); incrementProgress(); @@ -585,67 +585,67 @@ void QmlProfilerFileWriter::save(QIODevice *device) stream.writeStartElement(_("profilerDataModel")); - for (int rangeIndex = 0; rangeIndex < m_ranges.size(); ++rangeIndex) { + for (int rangeIndex = 0; rangeIndex < m_events.size(); ++rangeIndex) { if (isCanceled()) return; - const QmlProfilerDataModel::QmlEventData &range = m_ranges[rangeIndex]; + const QmlEvent &event = m_events[rangeIndex]; stream.writeStartElement(_("range")); - stream.writeAttribute(_("startTime"), QString::number(range.startTime())); - if (range.duration() > 0) // no need to store duration of instantaneous events - stream.writeAttribute(_("duration"), QString::number(range.duration())); - stream.writeAttribute(_("eventIndex"), QString::number(range.typeIndex())); + stream.writeAttribute(_("startTime"), QString::number(event.startTime())); + if (event.duration() > 0) // no need to store duration of instantaneous events + stream.writeAttribute(_("duration"), QString::number(event.duration())); + stream.writeAttribute(_("eventIndex"), QString::number(event.typeIndex())); - const QmlProfilerDataModel::QmlEventTypeData &event = m_qmlEvents[range.typeIndex()]; + const QmlEventType &type = m_eventTypes[event.typeIndex()]; - if (event.message == Event) { - if (event.detailType == AnimationFrame) { + if (type.message == Event) { + if (type.detailType == AnimationFrame) { // special: animation event - stream.writeAttribute(_("framerate"), QString::number(range.numericData(0))); - stream.writeAttribute(_("animationcount"), QString::number(range.numericData(1))); - stream.writeAttribute(_("thread"), QString::number(range.numericData(2))); - } else if (event.detailType == Key || event.detailType == Mouse) { + stream.writeAttribute(_("framerate"), QString::number(event.numericData(0))); + stream.writeAttribute(_("animationcount"), QString::number(event.numericData(1))); + stream.writeAttribute(_("thread"), QString::number(event.numericData(2))); + } else if (type.detailType == Key || type.detailType == Mouse) { // special: input event - stream.writeAttribute(_("type"), QString::number(range.numericData(0))); - stream.writeAttribute(_("data1"), QString::number(range.numericData(1))); - stream.writeAttribute(_("data2"), QString::number(range.numericData(2))); + stream.writeAttribute(_("type"), QString::number(event.numericData(0))); + stream.writeAttribute(_("data1"), QString::number(event.numericData(1))); + stream.writeAttribute(_("data2"), QString::number(event.numericData(2))); } } // special: pixmap cache event - if (event.message == PixmapCacheEvent) { - if (event.detailType == PixmapSizeKnown) { - stream.writeAttribute(_("width"), QString::number(range.numericData(0))); - stream.writeAttribute(_("height"), QString::number(range.numericData(1))); + if (type.message == PixmapCacheEvent) { + if (type.detailType == PixmapSizeKnown) { + stream.writeAttribute(_("width"), QString::number(event.numericData(0))); + stream.writeAttribute(_("height"), QString::number(event.numericData(1))); } - if (event.detailType == PixmapReferenceCountChanged || - event.detailType == PixmapCacheCountChanged) - stream.writeAttribute(_("refCount"), QString::number(range.numericData(2))); + if (type.detailType == PixmapReferenceCountChanged || + type.detailType == PixmapCacheCountChanged) + stream.writeAttribute(_("refCount"), QString::number(event.numericData(2))); } - if (event.message == SceneGraphFrame) { + if (type.message == SceneGraphFrame) { // special: scenegraph frame events - if (range.numericData(0) > 0) - stream.writeAttribute(_("timing1"), QString::number(range.numericData(0))); - if (range.numericData(1) > 0) - stream.writeAttribute(_("timing2"), QString::number(range.numericData(1))); - if (range.numericData(2) > 0) - stream.writeAttribute(_("timing3"), QString::number(range.numericData(2))); - if (range.numericData(3) > 0) - stream.writeAttribute(_("timing4"), QString::number(range.numericData(3))); - if (range.numericData(4) > 0) - stream.writeAttribute(_("timing5"), QString::number(range.numericData(4))); + if (event.numericData(0) > 0) + stream.writeAttribute(_("timing1"), QString::number(event.numericData(0))); + if (event.numericData(1) > 0) + stream.writeAttribute(_("timing2"), QString::number(event.numericData(1))); + if (event.numericData(2) > 0) + stream.writeAttribute(_("timing3"), QString::number(event.numericData(2))); + if (event.numericData(3) > 0) + stream.writeAttribute(_("timing4"), QString::number(event.numericData(3))); + if (event.numericData(4) > 0) + stream.writeAttribute(_("timing5"), QString::number(event.numericData(4))); } // special: memory allocation event - if (event.message == MemoryAllocation) - stream.writeAttribute(_("amount"), QString::number(range.numericData(0))); + if (type.message == MemoryAllocation) + stream.writeAttribute(_("amount"), QString::number(event.numericData(0))); - if (event.message == DebugMessage) - stream.writeAttribute(_("text"), range.stringData()); + if (type.message == DebugMessage) + stream.writeAttribute(_("text"), event.stringData()); stream.writeEndElement(); incrementProgress(); @@ -657,7 +657,7 @@ void QmlProfilerFileWriter::save(QIODevice *device) if (isCanceled()) return; - const QmlProfilerDataModel::QmlEventNoteData ¬es = m_notes[noteIndex]; + const QmlNote ¬es = m_notes[noteIndex]; stream.writeStartElement(_("note")); stream.writeAttribute(_("startTime"), QString::number(notes.startTime)); stream.writeAttribute(_("duration"), QString::number(notes.duration)); diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.h b/src/plugins/qmlprofiler/qmlprofilertracefile.h index 2da149d40cc..6d5c9b15e7b 100644 --- a/src/plugins/qmlprofiler/qmlprofilertracefile.h +++ b/src/plugins/qmlprofiler/qmlprofilertracefile.h @@ -56,26 +56,26 @@ public: qint64 traceStart() const { return m_traceStart; } qint64 traceEnd() const { return m_traceEnd; } - const QVector &qmlEvents() const { return m_qmlEvents; } - const QVector &ranges() const { return m_ranges; } - const QVector ¬es() const { return m_notes; } + const QVector &eventTypes() const { return m_eventTypes; } + const QVector &events() const { return m_events; } + const QVector ¬es() const { return m_notes; } signals: void error(const QString &error); void success(); private: - void loadEventData(QXmlStreamReader &reader); - void loadProfilerDataModel(QXmlStreamReader &reader); - void loadNoteData(QXmlStreamReader &reader); + void loadEventTypes(QXmlStreamReader &reader); + void loadEvents(QXmlStreamReader &reader); + void loadNotes(QXmlStreamReader &reader); void progress(QIODevice *device); bool isCanceled() const; qint64 m_traceStart, m_traceEnd; QFutureInterface *m_future; - QVector m_qmlEvents; - QVector m_ranges; - QVector m_notes; + QVector m_eventTypes; + QVector m_events; + QVector m_notes; quint64 m_loadedFeatures; }; @@ -88,9 +88,8 @@ public: explicit QmlProfilerFileWriter(QObject *parent = 0); void setTraceTime(qint64 startTime, qint64 endTime, qint64 measturedTime); - void setQmlEvents(const QVector &types, - const QVector &events); - void setNotes(const QVector ¬es); + void setData(const QVector &types, const QVector &events); + void setNotes(const QVector ¬es); void setFuture(QFutureInterface *future); void save(QIODevice *device); @@ -102,9 +101,9 @@ private: qint64 m_startTime, m_endTime, m_measuredTime; QFutureInterface *m_future; - QVector m_qmlEvents; - QVector m_ranges; - QVector m_notes; + QVector m_eventTypes; + QVector m_events; + QVector m_notes; int m_newProgressValue; }; diff --git a/src/plugins/qmlprofiler/scenegraphtimelinemodel.cpp b/src/plugins/qmlprofiler/scenegraphtimelinemodel.cpp index 1607d4a8583..cf0723b3296 100644 --- a/src/plugins/qmlprofiler/scenegraphtimelinemodel.cpp +++ b/src/plugins/qmlprofiler/scenegraphtimelinemodel.cpp @@ -138,9 +138,9 @@ void SceneGraphTimelineModel::loadData() return; // combine the data of several eventtypes into two rows - const QVector &types = simpleModel->getEventTypes(); - foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { - const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex()]; + const QVector &types = simpleModel->eventTypes(); + foreach (const QmlEvent &event, simpleModel->events()) { + const QmlEventType &type = types[event.typeIndex()]; if (!accepted(type)) continue; @@ -220,7 +220,7 @@ void SceneGraphTimelineModel::loadData() default: break; } - updateProgress(count(), simpleModel->getEvents().count()); + updateProgress(count(), simpleModel->events().count()); } computeNesting();