diff --git a/src/plugins/qmlprofiler/abstracttimelinemodel.cpp b/src/plugins/qmlprofiler/abstracttimelinemodel.cpp index 38251620c5e..e7a85979550 100644 --- a/src/plugins/qmlprofiler/abstracttimelinemodel.cpp +++ b/src/plugins/qmlprofiler/abstracttimelinemodel.cpp @@ -53,7 +53,7 @@ void AbstractTimelineModel::setModelManager(QmlProfilerModelManager *modelManage { Q_D(AbstractTimelineModel); d->modelManager = modelManager; - connect(d->modelManager->simpleModel(),SIGNAL(changed()),this,SLOT(dataChanged())); + connect(d->modelManager->qmlModel(),SIGNAL(changed()),this,SLOT(dataChanged())); d->modelId = d->modelManager->registerModelProxy(); } diff --git a/src/plugins/qmlprofiler/abstracttimelinemodel.h b/src/plugins/qmlprofiler/abstracttimelinemodel.h index 99d95ea8609..fc9c594f8c4 100644 --- a/src/plugins/qmlprofiler/abstracttimelinemodel.h +++ b/src/plugins/qmlprofiler/abstracttimelinemodel.h @@ -33,7 +33,7 @@ #include "qmlprofiler_global.h" #include "qmlprofilermodelmanager.h" -#include "qmlprofilersimplemodel.h" +#include "qmlprofilerdatamodel.h" #include #include #include @@ -79,7 +79,7 @@ public: Q_INVOKABLE virtual QColor getColor(int index) const = 0; Q_INVOKABLE virtual const QVariantList getLabelsForCategory(int category) const = 0; Q_INVOKABLE virtual const QVariantList getEventDetails(int index) const = 0; - virtual bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const = 0; + virtual bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const = 0; virtual int getEventType(int index) const = 0; virtual int getEventCategory(int index) const = 0; virtual int getEventRow(int index) const = 0; diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro index 34f8bc9b5f6..71d32f056cf 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.pro +++ b/src/plugins/qmlprofiler/qmlprofiler.pro @@ -22,8 +22,6 @@ SOURCES += \ qmlprofilerstatewidget.cpp \ qmlprofilerruncontrolfactory.cpp \ qmlprofilermodelmanager.cpp \ - qmlprofilersimplemodel.cpp \ - qmlprofilerprocessedmodel.cpp \ qmlprofilereventsmodelproxy.cpp \ qmlprofilertimelinemodelproxy.cpp \ qmlprofilertreeview.cpp \ @@ -33,7 +31,8 @@ SOURCES += \ qmlprofilerpainteventsmodelproxy.cpp \ sortedtimelinemodel.cpp \ qmlprofilerbasemodel.cpp \ - singlecategorytimelinemodel.cpp + singlecategorytimelinemodel.cpp \ + qmlprofilerdatamodel.cpp HEADERS += \ qmlprofilerconstants.h \ @@ -56,8 +55,6 @@ HEADERS += \ qmlprofilerstatewidget.h \ qmlprofilerruncontrolfactory.h \ qmlprofilermodelmanager.h \ - qmlprofilersimplemodel.h \ - qmlprofilerprocessedmodel.h \ qmlprofilereventsmodelproxy.h \ qmlprofilertimelinemodelproxy.h \ qmlprofilertreeview.h \ @@ -69,7 +66,8 @@ HEADERS += \ qmlprofilerbasemodel.h \ abstracttimelinemodel_p.h \ singlecategorytimelinemodel.h \ - singlecategorytimelinemodel_p.h + singlecategorytimelinemodel_p.h \ + qmlprofilerdatamodel.h RESOURCES += \ qml/qmlprofiler.qrc diff --git a/src/plugins/qmlprofiler/qmlprofiler.qbs b/src/plugins/qmlprofiler/qmlprofiler.qbs index 364e56f3cc2..aadb049735e 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.qbs +++ b/src/plugins/qmlprofiler/qmlprofiler.qbs @@ -31,6 +31,7 @@ QtcPlugin { "qmlprofilerbasemodel.cpp", "qmlprofilerbasemodel.h", "qmlprofilerclientmanager.cpp", "qmlprofilerclientmanager.h", "qmlprofilerconstants.h", + "qmlprofilerdatamodel.cpp", "qmlprofilerdatamodel.h", "qmlprofilerdetailsrewriter.cpp", "qmlprofilerdetailsrewriter.h", "qmlprofilerengine.cpp", "qmlprofilerengine.h", "qmlprofilereventsmodelproxy.cpp", "qmlprofilereventsmodelproxy.h", @@ -38,9 +39,7 @@ QtcPlugin { "qmlprofilermodelmanager.cpp", "qmlprofilermodelmanager.h", "qmlprofilerpainteventsmodelproxy.h", "qmlprofilerpainteventsmodelproxy.cpp", "qmlprofilerplugin.cpp", "qmlprofilerplugin.h", - "qmlprofilerprocessedmodel.cpp", "qmlprofilerprocessedmodel.h", "qmlprofilerruncontrolfactory.cpp", "qmlprofilerruncontrolfactory.h", - "qmlprofilersimplemodel.cpp", "qmlprofilersimplemodel.h", "qmlprofilerstatemanager.cpp", "qmlprofilerstatemanager.h", "qmlprofilerstatewidget.cpp", "qmlprofilerstatewidget.h", "qmlprofilertimelinemodelproxy.cpp", "qmlprofilertimelinemodelproxy.h", diff --git a/src/plugins/qmlprofiler/qmlprofilerbasemodel.cpp b/src/plugins/qmlprofiler/qmlprofilerbasemodel.cpp index 2ea14f9db5c..5cdcd703143 100644 --- a/src/plugins/qmlprofiler/qmlprofilerbasemodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerbasemodel.cpp @@ -32,21 +32,42 @@ namespace QmlProfiler { -QmlProfilerBaseModel::QmlProfilerBaseModel(QmlProfilerModelManager *manager) : - m_modelManager(manager), m_processingDone(false) +QmlProfilerBaseModel::QmlProfilerBaseModel(Utils::FileInProjectFinder *fileFinder, + QmlProfilerModelManager *manager) : + m_modelManager(manager), m_processingDone(false), m_detailsRewriter(this, fileFinder) { Q_ASSERT(m_modelManager); m_modelId = m_modelManager->registerModelProxy(); + connect(&m_detailsRewriter, SIGNAL(rewriteDetailsString(int,QString)), + this, SLOT(detailsChanged(int,QString))); + connect(&m_detailsRewriter, SIGNAL(eventDetailsChanged()), + this, SLOT(detailsDone())); } void QmlProfilerBaseModel::clear() { + m_detailsRewriter.clearRequests(); m_modelManager->modelProxyCountUpdated(m_modelId, 0, 1); m_processingDone = false; emit changed(); } void QmlProfilerBaseModel::complete() +{ + m_detailsRewriter.reloadDocuments(); +} + +QString QmlProfilerBaseModel::formatTime(qint64 timestamp) +{ + if (timestamp < 1e6) + return QString::number(timestamp/1e3f,'f',3) + trUtf8(" \xc2\xb5s"); + if (timestamp < 1e9) + return QString::number(timestamp/1e6f,'f',3) + tr(" ms"); + + return QString::number(timestamp/1e9f,'f',3) + tr(" s"); +} + +void QmlProfilerBaseModel::detailsDone() { emit changed(); m_processingDone = true; diff --git a/src/plugins/qmlprofiler/qmlprofilerbasemodel.h b/src/plugins/qmlprofiler/qmlprofilerbasemodel.h index b565ea194b3..973472c50ec 100644 --- a/src/plugins/qmlprofiler/qmlprofilerbasemodel.h +++ b/src/plugins/qmlprofiler/qmlprofilerbasemodel.h @@ -31,6 +31,7 @@ #define QMLPROFILERBASEMODEL_H #include "qmlprofiler_global.h" +#include "qmlprofilerdetailsrewriter.h" #include namespace QmlProfiler { @@ -40,7 +41,7 @@ class QmlProfilerModelManager; class QMLPROFILER_EXPORT QmlProfilerBaseModel : public QObject { Q_OBJECT public: - QmlProfilerBaseModel(QmlProfilerModelManager *manager); + QmlProfilerBaseModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *manager); virtual ~QmlProfilerBaseModel() {} virtual void complete(); @@ -48,10 +49,17 @@ public: virtual bool isEmpty() const = 0; bool processingDone() const { return m_processingDone; } + static QString formatTime(qint64 timestamp); + protected: QmlProfilerModelManager *m_modelManager; int m_modelId; bool m_processingDone; + Internal::QmlProfilerDetailsRewriter m_detailsRewriter; + +protected slots: + virtual void detailsChanged(int requestId, const QString &newString) = 0; + virtual void detailsDone(); signals: void changed(); diff --git a/src/plugins/qmlprofiler/qmlprofilerprocessedmodel.cpp b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp similarity index 53% rename from src/plugins/qmlprofiler/qmlprofilerprocessedmodel.cpp rename to src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp index d022f863a86..b443c3f4c51 100644 --- a/src/plugins/qmlprofiler/qmlprofilerprocessedmodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp @@ -27,7 +27,7 @@ ** ****************************************************************************/ -#include "qmlprofilerprocessedmodel.h" +#include "qmlprofilerdatamodel.h" #include "qmlprofilermodelmanager.h" #include #include @@ -35,13 +35,12 @@ #include namespace QmlProfiler { -namespace Internal { -QmlDebug::QmlEventLocation getLocation(const QmlProfilerSimpleModel::QmlEventData &event); -QString getDisplayName(const QmlProfilerSimpleModel::QmlEventData &event); -QString getInitialDetails(const QmlProfilerSimpleModel::QmlEventData &event); +QmlDebug::QmlEventLocation getLocation(const QmlProfilerDataModel::QmlEventData &event); +QString getDisplayName(const QmlProfilerDataModel::QmlEventData &event); +QString getInitialDetails(const QmlProfilerDataModel::QmlEventData &event); -QmlDebug::QmlEventLocation getLocation(const QmlProfilerSimpleModel::QmlEventData &event) +QmlDebug::QmlEventLocation getLocation(const QmlProfilerDataModel::QmlEventData &event) { QmlDebug::QmlEventLocation eventLocation = event.location; if ((event.eventType == QmlDebug::Creating || event.eventType == QmlDebug::Compiling) @@ -53,14 +52,14 @@ QmlDebug::QmlEventLocation getLocation(const QmlProfilerSimpleModel::QmlEventDat return eventLocation; } -QString getDisplayName(const QmlProfilerSimpleModel::QmlEventData &event) +QString getDisplayName(const QmlProfilerDataModel::QmlEventData &event) { const QmlDebug::QmlEventLocation eventLocation = getLocation(event); QString displayName; // generate hash if (eventLocation.filename.isEmpty()) { - displayName = QmlProfilerProcessedModel::tr(""); + displayName = QmlProfilerDataModel::tr(""); } else { const QString filePath = QUrl(eventLocation.filename).path(); displayName = filePath.mid(filePath.lastIndexOf(QLatin1Char('/')) + 1) + QLatin1Char(':') + @@ -70,16 +69,16 @@ QString getDisplayName(const QmlProfilerSimpleModel::QmlEventData &event) return displayName; } -QString getInitialDetails(const QmlProfilerSimpleModel::QmlEventData &event) +QString getInitialDetails(const QmlProfilerDataModel::QmlEventData &event) { QString details; // generate details string if (event.data.isEmpty()) - details = QmlProfilerProcessedModel::tr("Source code not available."); + details = QmlProfilerDataModel::tr("Source code not available."); else { details = event.data.join(QLatin1String(" ")).replace(QLatin1Char('\n'),QLatin1Char(' ')).simplified(); if (details.isEmpty()) { - details = QmlProfilerProcessedModel::tr("anonymous function"); + details = QmlProfilerDataModel::tr("anonymous function"); } else { QRegExp rewrite(QLatin1String("\\(function \\$(\\w+)\\(\\) \\{ (return |)(.+) \\}\\)")); bool match = rewrite.exactMatch(details); @@ -94,51 +93,54 @@ QString getInitialDetails(const QmlProfilerSimpleModel::QmlEventData &event) } -bool compareStartTimes(const QmlProfilerSimpleModel::QmlEventData &t1, const QmlProfilerSimpleModel::QmlEventData &t2) +bool compareStartTimes(const QmlProfilerDataModel::QmlEventData &t1, const QmlProfilerDataModel::QmlEventData &t2) { return t1.startTime < t2.startTime; } ////////////////////////////////////////////////////////////////////////////// -QmlProfilerProcessedModel::QmlProfilerProcessedModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent) - : QmlProfilerSimpleModel(parent) - , m_detailsRewriter(new QmlProfilerDetailsRewriter(this, fileFinder)) +QmlProfilerDataModel::QmlProfilerDataModel(Utils::FileInProjectFinder *fileFinder, + QmlProfilerModelManager *parent) + : QmlProfilerBaseModel(fileFinder, parent) { - m_processedModelId = m_modelManager->registerModelProxy(); // The document loading is very expensive. - m_modelManager->setProxyCountWeight(m_processedModelId, 3); - - connect(m_detailsRewriter, SIGNAL(rewriteDetailsString(int,QString)), - this, SLOT(detailsChanged(int,QString))); - connect(m_detailsRewriter, SIGNAL(eventDetailsChanged()), - this, SLOT(detailsDone())); + m_modelManager->setProxyCountWeight(m_modelId, 4); } -QmlProfilerProcessedModel::~QmlProfilerProcessedModel() +const QVector &QmlProfilerDataModel::getEvents() const { + return m_eventList; } -void QmlProfilerProcessedModel::clear() +int QmlProfilerDataModel::count() const { - m_detailsRewriter->clearRequests(); - m_modelManager->modelProxyCountUpdated(m_processedModelId, 0, 1); + return m_eventList.count(); +} + +void QmlProfilerDataModel::clear() +{ + m_eventList.clear(); // This call emits changed(). Don't emit it again here. - QmlProfilerSimpleModel::clear(); + QmlProfilerBaseModel::clear(); } -void QmlProfilerProcessedModel::complete() +bool QmlProfilerDataModel::isEmpty() const +{ + return m_eventList.isEmpty(); +} + +void QmlProfilerDataModel::complete() { - m_modelManager->modelProxyCountUpdated(m_processedModelId, 0, 1); // post-processing // sort events by start time - qSort(eventList.begin(), eventList.end(), compareStartTimes); + qSort(m_eventList.begin(), m_eventList.end(), compareStartTimes); // rewrite strings - int n = eventList.count(); + int n = m_eventList.count(); for (int i = 0; i < n; i++) { - QmlEventData *event = &eventList[i]; + QmlEventData *event = &m_eventList[i]; event->location = getLocation(*event); event->displayName = getDisplayName(*event); event->data = QStringList() << getInitialDetails(*event); @@ -158,30 +160,62 @@ void QmlProfilerProcessedModel::complete() if (event->location.column == -1) continue; - m_detailsRewriter->requestDetailsForLocation(i, event->location); - m_modelManager->modelProxyCountUpdated(m_processedModelId, i, n); + m_detailsRewriter.requestDetailsForLocation(i, event->location); + m_modelManager->modelProxyCountUpdated(m_modelId, i + n, n * 2); } - // Allow QmlProfilerBaseModel::complete() only after documents have been reloaded to avoid + // Allow changed() event only after documents have been reloaded to avoid // unnecessary updates of child models. - m_detailsRewriter->reloadDocuments(); + QmlProfilerBaseModel::complete(); } -void QmlProfilerProcessedModel::detailsChanged(int requestId, const QString &newString) +void QmlProfilerDataModel::addQmlEvent(int type, int bindingType, qint64 startTime, + qint64 duration, const QStringList &data, + const QmlDebug::QmlEventLocation &location, + qint64 ndata1, qint64 ndata2, qint64 ndata3, + qint64 ndata4, qint64 ndata5) { - QTC_ASSERT(requestId < eventList.count(), return); + QString displayName; + if (type == QmlDebug::Painting && bindingType == QmlDebug::AnimationFrame) { + displayName = tr("Animations"); + } else { + displayName = QString::fromLatin1("%1:%2").arg( + location.filename, + QString::number(location.line)); + } - QmlEventData *event = &eventList[requestId]; + QmlEventData eventData = {displayName, type, bindingType, startTime, duration, data, location, + ndata1, ndata2, ndata3, ndata4, ndata5}; + m_eventList.append(eventData); + + m_modelManager->modelProxyCountUpdated(m_modelId, startTime, + m_modelManager->estimatedProfilingTime() * 2); +} + +QString QmlProfilerDataModel::getHashString(const QmlProfilerDataModel::QmlEventData &event) +{ + return QString::fromLatin1("%1:%2:%3:%4:%5").arg( + event.location.filename, + QString::number(event.location.line), + QString::number(event.location.column), + QString::number(event.eventType), + QString::number(event.bindingType)); +} + +qint64 QmlProfilerDataModel::lastTimeMark() const +{ + if (m_eventList.isEmpty()) + return 0; + + return m_eventList.last().startTime + m_eventList.last().duration; +} + +void QmlProfilerDataModel::detailsChanged(int requestId, const QString &newString) +{ + QTC_ASSERT(requestId < m_eventList.count(), return); + + QmlEventData *event = &m_eventList[requestId]; event->data = QStringList(newString); } -void QmlProfilerProcessedModel::detailsDone() -{ - m_modelManager->modelProxyCountUpdated(m_processedModelId, 1, 1); - // The child models are supposed to synchronously update on changed(), triggered by - // QmlProfilerBaseModel::complete(). - QmlProfilerSimpleModel::complete(); -} - -} } diff --git a/src/plugins/qmlprofiler/qmlprofilersimplemodel.h b/src/plugins/qmlprofiler/qmlprofilerdatamodel.h similarity index 74% rename from src/plugins/qmlprofiler/qmlprofilersimplemodel.h rename to src/plugins/qmlprofiler/qmlprofilerdatamodel.h index 28c11ad0c41..927800872a0 100644 --- a/src/plugins/qmlprofiler/qmlprofilersimplemodel.h +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.h @@ -27,24 +27,14 @@ ** ****************************************************************************/ -#ifndef QMLPROFILERSIMPLEMODEL_H -#define QMLPROFILERSIMPLEMODEL_H +#ifndef QMLPROFILERDATAMODEL_H +#define QMLPROFILERDATAMODEL_H -#include "qmlprofiler_global.h" #include "qmlprofilerbasemodel.h" -#include - -#include -#include -#include - namespace QmlProfiler { -class QmlProfilerModelManager; - -// stores the data from the client as-is -class QMLPROFILER_EXPORT QmlProfilerSimpleModel : public QmlProfilerBaseModel +class QMLPROFILER_EXPORT QmlProfilerDataModel : public QmlProfilerBaseModel { Q_OBJECT public: @@ -63,22 +53,24 @@ public: qint64 numericData5; }; - explicit QmlProfilerSimpleModel(QmlProfilerModelManager *parent); - ~QmlProfilerSimpleModel(); + explicit QmlProfilerDataModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent = 0); - virtual void clear(); - bool isEmpty() const; const QVector &getEvents() const; int count() const; - void addQmlEvent(int type, int bindingType, qint64 startTime, qint64 duration, const QStringList &data, const QmlDebug::QmlEventLocation &location, + virtual void clear(); + virtual bool isEmpty() const; + virtual void complete(); + void addQmlEvent(int type, int bindingType, qint64 startTime, qint64 duration, + const QStringList &data, const QmlDebug::QmlEventLocation &location, qint64 ndata1, qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5); + static QString getHashString(const QmlProfilerDataModel::QmlEventData &event); qint64 lastTimeMark() const; - static QString getHashString(const QmlProfilerSimpleModel::QmlEventData &event); - static QString formatTime(qint64 timestamp); +protected slots: + void detailsChanged(int requestId, const QString &newString); -protected: - QVector eventList; +private: + QVector m_eventList; }; } diff --git a/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp index ca9b036f4b4..cfda67feee2 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp +++ b/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp @@ -29,7 +29,7 @@ #include "qmlprofilereventsmodelproxy.h" #include "qmlprofilermodelmanager.h" -#include "qmlprofilersimplemodel.h" +#include "qmlprofilerdatamodel.h" #include @@ -66,7 +66,7 @@ QmlProfilerEventsModelProxy::QmlProfilerEventsModelProxy(QmlProfilerModelManager : QObject(parent), d(new QmlProfilerEventsModelProxyPrivate(this)) { d->modelManager = modelManager; - connect(modelManager->simpleModel(), SIGNAL(changed()), this, SLOT(dataChanged())); + connect(modelManager->qmlModel(), SIGNAL(changed()), this, SLOT(dataChanged())); d->modelId = modelManager->registerModelProxy(); // We're iterating twice in loadData. @@ -120,16 +120,16 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd) const bool checkRanges = (rangeStart != -1) && (rangeEnd != -1); - const QVector eventList - = d->modelManager->simpleModel()->getEvents(); + const QVector eventList + = d->modelManager->qmlModel()->getEvents(); // used by binding loop detection - typedef QPair CallStackEntry; + typedef QPair CallStackEntry; QStack callStack; callStack.push(CallStackEntry(QString(), 0)); // artificial root for (int i = 0; i < eventList.size(); ++i) { - const QmlProfilerSimpleModel::QmlEventData *event = &eventList[i]; + const QmlProfilerDataModel::QmlEventData *event = &eventList[i]; if (!d->acceptedTypes.contains(event->eventType)) continue; @@ -141,7 +141,7 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd) } // put event in hash - QString hash = QmlProfilerSimpleModel::getHashString(*event); + QString hash = QmlProfilerDataModel::getHashString(*event); if (!d->data.contains(hash)) { QmlEventStats stats = { event->displayName, @@ -190,7 +190,7 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd) // // binding loop detection // - const QmlProfilerSimpleModel::QmlEventData *potentialParent = callStack.top().second; + const QmlProfilerDataModel::QmlEventData *potentialParent = callStack.top().second; while (potentialParent && !(potentialParent->startTime + potentialParent->duration > event->startTime)) { callStack.pop(); @@ -275,7 +275,7 @@ QmlProfilerEventRelativesModelProxy::QmlProfilerEventRelativesModelProxy(QmlProf { QTC_CHECK(modelManager); m_modelManager = modelManager; - connect(modelManager->simpleModel(), SIGNAL(changed()), this, SLOT(dataChanged())); + connect(modelManager->qmlModel(), SIGNAL(changed()), this, SLOT(dataChanged())); QTC_CHECK(eventsModel); m_eventsModel = eventsModel; @@ -325,13 +325,13 @@ QmlProfilerEventParentsModelProxy::~QmlProfilerEventParentsModelProxy() void QmlProfilerEventParentsModelProxy::loadData() { clear(); - QmlProfilerSimpleModel *simpleModel = m_modelManager->simpleModel(); + QmlProfilerDataModel *simpleModel = m_modelManager->qmlModel(); if (simpleModel->isEmpty()) return; - QHash cachedEvents; + QHash cachedEvents; QString rootEventName = tr(""); - QmlProfilerSimpleModel::QmlEventData rootEvent = { + QmlProfilerDataModel::QmlEventData rootEvent = { rootEventName, QmlDebug::Binding, 0, @@ -353,8 +353,8 @@ void QmlProfilerEventParentsModelProxy::loadData() // compute parent-child relationship and call count QHash lastParent; //for (int index = fromIndex; index <= toIndex; index++) { - const QVector eventList = simpleModel->getEvents(); - foreach (const QmlProfilerSimpleModel::QmlEventData &event, eventList) { + const QVector eventList = simpleModel->getEvents(); + foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) { // whitelist if (!m_acceptedTypes.contains(event.eventType)) continue; @@ -370,7 +370,7 @@ void QmlProfilerEventParentsModelProxy::loadData() QString parentHash = rootEventName; - QString eventHash = QmlProfilerSimpleModel::getHashString(event); + QString eventHash = QmlProfilerDataModel::getHashString(event); // save in cache if (!cachedEvents.contains(eventHash)) @@ -379,7 +379,7 @@ void QmlProfilerEventParentsModelProxy::loadData() if (level > QmlDebug::Constants::QML_MIN_LEVEL && lastParent.contains(level-1)) parentHash = lastParent[level-1]; - QmlProfilerSimpleModel::QmlEventData *parentEvent = &(cachedEvents[parentHash]); + QmlProfilerDataModel::QmlEventData *parentEvent = &(cachedEvents[parentHash]); // generate placeholder if needed if (!m_data.contains(eventHash)) @@ -418,7 +418,7 @@ QmlProfilerEventChildrenModelProxy::~QmlProfilerEventChildrenModelProxy() void QmlProfilerEventChildrenModelProxy::loadData() { clear(); - QmlProfilerSimpleModel *simpleModel = m_modelManager->simpleModel(); + QmlProfilerDataModel *simpleModel = m_modelManager->qmlModel(); if (simpleModel->isEmpty()) return; @@ -433,8 +433,8 @@ void QmlProfilerEventChildrenModelProxy::loadData() // compute parent-child relationship and call count QHash lastParent; - const QVector eventList = simpleModel->getEvents(); - foreach (const QmlProfilerSimpleModel::QmlEventData &event, eventList) { + const QVector eventList = simpleModel->getEvents(); + foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) { // whitelist if (!m_acceptedTypes.contains(event.eventType)) continue; @@ -449,7 +449,7 @@ void QmlProfilerEventChildrenModelProxy::loadData() endtimesPerLevel[level] = event.startTime + event.duration; QString parentHash = rootEventName; - QString eventHash = QmlProfilerSimpleModel::getHashString(event); + QString eventHash = QmlProfilerDataModel::getHashString(event); if (level > QmlDebug::Constants::QML_MIN_LEVEL && lastParent.contains(level-1)) parentHash = lastParent[level-1]; diff --git a/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.h b/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.h index d4305f6b7c2..080bd2eecba 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.h +++ b/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.h @@ -31,7 +31,7 @@ #ifndef QMLPROFILEREVENTSMODELPROXY_H #define QMLPROFILEREVENTSMODELPROXY_H -#include "qmlprofilersimplemodel.h" +#include "qmlprofilerdatamodel.h" #include #include #include diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.cpp b/src/plugins/qmlprofiler/qmlprofilereventview.cpp index 5e213955523..97a0568f807 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilereventview.cpp @@ -544,7 +544,7 @@ void QmlProfilerEventsMainView::parseModelProxy() } if (d->m_fieldShown[TotalTime]) { - newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.duration)); + newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.duration)); newRow.last()->setData(QVariant(event.duration)); } @@ -554,22 +554,22 @@ void QmlProfilerEventsMainView::parseModelProxy() } if (d->m_fieldShown[TimePerCall]) { - newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.timePerCall)); + newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.timePerCall)); newRow.last()->setData(QVariant(event.timePerCall)); } if (d->m_fieldShown[MedianTime]) { - newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.medianTime)); + newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.medianTime)); newRow.last()->setData(QVariant(event.medianTime)); } if (d->m_fieldShown[MaxTime]) { - newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.maxTime)); + newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.maxTime)); newRow.last()->setData(QVariant(event.maxTime)); } if (d->m_fieldShown[MinTime]) { - newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.minTime)); + newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.minTime)); newRow.last()->setData(QVariant(event.minTime)); } @@ -818,13 +818,13 @@ void QmlProfilerEventRelativesView::rebuildTree(QmlProfilerEventRelativesModelPr // no indirections at this level of abstraction! newRow << new EventsViewItem(event.displayName); newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event.eventType)); - newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.duration)); + newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.duration)); newRow << new EventsViewItem(QString::number(event.calls)); newRow << new EventsViewItem(event.details); // newRow << new EventsViewItem(event->reference->displayName); // newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event->reference->eventType)); -// newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event->duration)); +// newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event->duration)); // newRow << new EventsViewItem(QString::number(event->calls)); // newRow << new EventsViewItem(event->reference->details); newRow.at(0)->setData(QVariant(key), EventHashStrRole); diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp index e9cc9769cfe..8f27f6a56a6 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp @@ -28,8 +28,7 @@ ****************************************************************************/ #include "qmlprofilermodelmanager.h" -#include "qmlprofilersimplemodel.h" -#include "qmlprofilerprocessedmodel.h" +#include "qmlprofilerdatamodel.h" #include "qv8profilerdatamodel.h" #include "qmlprofilertracefile.h" @@ -139,7 +138,7 @@ public: ~QmlProfilerModelManagerPrivate() {} QmlProfilerModelManager *q; - QmlProfilerSimpleModel *model; + QmlProfilerDataModel *model; QV8ProfilerDataModel *v8Model; QmlProfilerDataState *dataState; QmlProfilerTraceTime *traceTime; @@ -160,7 +159,7 @@ QmlProfilerModelManager::QmlProfilerModelManager(Utils::FileInProjectFinder *fin QObject(parent), d(new QmlProfilerModelManagerPrivate(this)) { d->totalWeight = 0; - d->model = new QmlProfilerProcessedModel(finder, this); + d->model = new QmlProfilerDataModel(finder, this); d->v8Model = new QV8ProfilerDataModel(finder, this); // d->model = new QmlProfilerSimpleModel(this); d->dataState = new QmlProfilerDataState(this, this); @@ -177,7 +176,7 @@ QmlProfilerTraceTime *QmlProfilerModelManager::traceTime() const return d->traceTime; } -QmlProfilerSimpleModel *QmlProfilerModelManager::simpleModel() const +QmlProfilerDataModel *QmlProfilerModelManager::qmlModel() const { return d->model; } diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.h b/src/plugins/qmlprofiler/qmlprofilermodelmanager.h index 1c76756d66a..c9e2047cead 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.h +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.h @@ -38,12 +38,12 @@ #include namespace QmlProfiler { -class QmlProfilerSimpleModel; class QmlProfilerModelManager; +class QmlProfilerDataModel; +class QV8ProfilerDataModel; namespace Internal { -class QV8ProfilerDataModel; class QmlProfilerDataState : public QObject { Q_OBJECT @@ -109,7 +109,7 @@ public: QmlProfilerDataState::State state() const; QmlProfilerTraceTime *traceTime() const; - QmlProfilerSimpleModel *simpleModel() const; + QmlProfilerDataModel *qmlModel() const; QV8ProfilerDataModel *v8Model() const; bool isEmpty() const; diff --git a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp index 96478bcfde5..b57e842debe 100644 --- a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp @@ -29,7 +29,7 @@ #include "qmlprofilerpainteventsmodelproxy.h" #include "qmlprofilermodelmanager.h" -#include "qmlprofilersimplemodel.h" +#include "qmlprofilerdatamodel.h" #include "sortedtimelinemodel.h" #include "singlecategorytimelinemodel_p.h" #include @@ -85,7 +85,7 @@ void PaintEventsModelProxy::clear() d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1); } -bool PaintEventsModelProxy::eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const +bool PaintEventsModelProxy::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const { return SingleCategoryTimelineModel::eventAccepted(event) && event.bindingType == QmlDebug::AnimationFrame; @@ -95,17 +95,17 @@ void PaintEventsModelProxy::loadData() { Q_D(PaintEventsModelProxy); clear(); - QmlProfilerSimpleModel *simpleModel = d->modelManager->simpleModel(); + QmlProfilerDataModel *simpleModel = d->modelManager->qmlModel(); if (simpleModel->isEmpty()) return; // collect events - const QVector referenceList = simpleModel->getEvents(); + const QVector referenceList = simpleModel->getEvents(); QmlPaintEventData lastEvent; qint64 minNextStartTime = 0; - foreach (const QmlProfilerSimpleModel::QmlEventData &event, referenceList) { + foreach (const QmlProfilerDataModel::QmlEventData &event, referenceList) { if (!eventAccepted(event)) { if (event.eventType == QmlDebug::Painting) d->seenForeignPaintEvent = true; @@ -238,7 +238,7 @@ const QVariantList PaintEventsModelProxy::getEventDetails(int index) const { QVariantMap valuePair; valuePair.insert(QCoreApplication::translate(trContext, "Duration:"), - QVariant(QmlProfilerSimpleModel::formatTime(d->range(index).duration))); + QVariant(QmlProfilerBaseModel::formatTime(d->range(index).duration))); result << valuePair; } diff --git a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h index fcff44826de..4947c57d56c 100644 --- a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h +++ b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h @@ -39,7 +39,7 @@ //#include #include //#include -#include "qmlprofilersimplemodel.h" +#include "qmlprofilerdatamodel.h" #include @@ -76,7 +76,7 @@ public: Q_INVOKABLE const QVariantList getEventDetails(int index) const; private slots: - bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const; + bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const; private: class PaintEventsModelProxyPrivate; diff --git a/src/plugins/qmlprofiler/qmlprofilerprocessedmodel.h b/src/plugins/qmlprofiler/qmlprofilerprocessedmodel.h deleted file mode 100644 index ca24675151b..00000000000 --- a/src/plugins/qmlprofiler/qmlprofilerprocessedmodel.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QMLPROFILERPROCESSEDMODEL_H -#define QMLPROFILERPROCESSEDMODEL_H - -#include "qmlprofilersimplemodel.h" -#include "qmlprofilerdetailsrewriter.h" - -namespace QmlProfiler { -namespace Internal { - -class QmlProfilerProcessedModel : public QmlProfilerSimpleModel -{ - Q_OBJECT - -public: - explicit QmlProfilerProcessedModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent = 0); - ~QmlProfilerProcessedModel(); - - virtual void clear(); - virtual void complete(); - -private slots: - void detailsChanged(int requestId, const QString &newString); - void detailsDone(); - -private: - int m_processedModelId; - QmlProfilerDetailsRewriter *m_detailsRewriter; -}; - -} -} - -#endif diff --git a/src/plugins/qmlprofiler/qmlprofilersimplemodel.cpp b/src/plugins/qmlprofiler/qmlprofilersimplemodel.cpp deleted file mode 100644 index 5d13ad9622c..00000000000 --- a/src/plugins/qmlprofiler/qmlprofilersimplemodel.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qmlprofilersimplemodel.h" - -#include "qmlprofilermodelmanager.h" - -#include - -#include -#include -#include - -namespace QmlProfiler { - -QmlProfilerSimpleModel::QmlProfilerSimpleModel(QmlProfilerModelManager *parent) - : QmlProfilerBaseModel(parent) -{ - m_modelManager->setProxyCountWeight(m_modelId, 2); -} - -QmlProfilerSimpleModel::~QmlProfilerSimpleModel() -{ -} - -void QmlProfilerSimpleModel::clear() -{ - eventList.clear(); - QmlProfilerBaseModel::clear(); -} - -bool QmlProfilerSimpleModel::isEmpty() const -{ - return eventList.isEmpty(); -} - -const QVector &QmlProfilerSimpleModel::getEvents() const -{ - return eventList; -} - -int QmlProfilerSimpleModel::count() const -{ - return eventList.count(); -} - -void QmlProfilerSimpleModel::addQmlEvent(int type, int bindingType, qint64 startTime, qint64 duration, const QStringList &data, const QmlDebug::QmlEventLocation &location, qint64 ndata1, qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5) -{ - QString displayName; - if (type == QmlDebug::Painting && bindingType == QmlDebug::AnimationFrame) { - displayName = tr("Animations"); - } else { - displayName = QString::fromLatin1("%1:%2").arg( - location.filename, - QString::number(location.line)); - } - - QmlEventData eventData = {displayName, type, bindingType, startTime, duration, data, location, ndata1, ndata2, ndata3, ndata4, ndata5}; - eventList.append(eventData); - - m_modelManager->modelProxyCountUpdated(m_modelId, startTime, m_modelManager->estimatedProfilingTime()); -} - -qint64 QmlProfilerSimpleModel::lastTimeMark() const -{ - if (eventList.isEmpty()) - return 0; - - return eventList.last().startTime + eventList.last().duration; -} - -QString QmlProfilerSimpleModel::getHashString(const QmlProfilerSimpleModel::QmlEventData &event) -{ - return QString::fromLatin1("%1:%2:%3:%4:%5").arg( - event.location.filename, - QString::number(event.location.line), - QString::number(event.location.column), - QString::number(event.eventType), - QString::number(event.bindingType)); -} - -QString QmlProfilerSimpleModel::formatTime(qint64 timestamp) -{ - if (timestamp < 1e6) - return QString::number(timestamp/1e3f,'f',3) + trUtf8(" \xc2\xb5s"); - if (timestamp < 1e9) - return QString::number(timestamp/1e6f,'f',3) + tr(" ms"); - - return QString::number(timestamp/1e9f,'f',3) + tr(" s"); -} - -} diff --git a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp index 99eaaa5ba6e..1e75b2fefd1 100644 --- a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp @@ -29,7 +29,7 @@ #include "qmlprofilertimelinemodelproxy.h" #include "qmlprofilermodelmanager.h" -#include "qmlprofilersimplemodel.h" +#include "qmlprofilerdatamodel.h" #include "sortedtimelinemodel.h" #include @@ -96,7 +96,7 @@ void BasicTimelineModel::BasicTimelineModelPrivate::prepare() } } -bool BasicTimelineModel::eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const +bool BasicTimelineModel::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const { // only accept Qt4.x Painting events if (event.eventType == QmlDebug::Painting) @@ -109,7 +109,7 @@ void BasicTimelineModel::loadData() { Q_D(BasicTimelineModel); clear(); - QmlProfilerSimpleModel *simpleModel = d->modelManager->simpleModel(); + QmlProfilerDataModel *simpleModel = d->modelManager->qmlModel(); if (simpleModel->isEmpty()) return; @@ -118,14 +118,14 @@ void BasicTimelineModel::loadData() d->prepare(); // collect events - const QVector eventList = simpleModel->getEvents(); - foreach (const QmlProfilerSimpleModel::QmlEventData &event, eventList) { + const QVector eventList = simpleModel->getEvents(); + foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) { if (!eventAccepted(event)) continue; if (event.eventType == QmlDebug::Painting) d->seenPaintEvent = true; - QString eventHash = QmlProfilerSimpleModel::getHashString(event); + QString eventHash = QmlProfilerDataModel::getHashString(event); // store in dictionary if (!d->eventHashes.contains(eventHash)) { @@ -413,7 +413,7 @@ const QVariantList BasicTimelineModel::getEventDetails(int index) const { QVariantMap valuePair; valuePair.insert(QCoreApplication::translate(trContext, "Duration:"), - QVariant(QmlProfilerSimpleModel::formatTime(d->range(index).duration))); + QVariant(QmlProfilerBaseModel::formatTime(d->range(index).duration))); result << valuePair; } diff --git a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h index d255c89d19e..e7ac70012e7 100644 --- a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h +++ b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h @@ -39,7 +39,7 @@ //#include #include //#include -#include "qmlprofilersimplemodel.h" +#include "qmlprofilerdatamodel.h" #include @@ -108,7 +108,7 @@ public: Q_INVOKABLE int getEventIdForLocation(const QString &filename, int line, int column) const; private slots: - bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const; + bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const; private: class BasicTimelineModelPrivate; diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp index 0aca1d08fd9..91610fba42f 100644 --- a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp @@ -401,10 +401,10 @@ void QmlProfilerFileWriter::setV8DataModel(QV8ProfilerDataModel *dataModel) m_v8Model = dataModel; } -void QmlProfilerFileWriter::setQmlEvents(const QVector &events) +void QmlProfilerFileWriter::setQmlEvents(const QVector &events) { - foreach (const QmlProfilerSimpleModel::QmlEventData &event, events) { - const QString hashStr = QmlProfilerSimpleModel::getHashString(event); + foreach (const QmlProfilerDataModel::QmlEventData &event, events) { + const QString hashStr = QmlProfilerDataModel::getHashString(event); if (!m_qmlEvents.contains(hashStr)) { QmlEvent e = { event.displayName, event.location.filename, @@ -524,7 +524,7 @@ void QmlProfilerFileWriter::save(QIODevice *device) stream.writeEndDocument(); } -void QmlProfilerFileWriter::calculateMeasuredTime(const QVector &events) +void QmlProfilerFileWriter::calculateMeasuredTime(const QVector &events) { // measured time isn't used, but old clients might still need it // -> we calculate it explicitly @@ -535,7 +535,7 @@ void QmlProfilerFileWriter::calculateMeasuredTime(const QVector #include -#include "qmlprofilersimplemodel.h" +#include "qmlprofilerdatamodel.h" #include "qv8profilerdatamodel.h" QT_FORWARD_DECLARE_CLASS(QIODevice) @@ -112,12 +112,12 @@ public: void setTraceTime(qint64 startTime, qint64 endTime, qint64 measturedTime); void setV8DataModel(QV8ProfilerDataModel *dataModel); - void setQmlEvents(const QVector &events); + void setQmlEvents(const QVector &events); void save(QIODevice *device); private: - void calculateMeasuredTime(const QVector &events); + void calculateMeasuredTime(const QVector &events); qint64 m_startTime, m_endTime, m_measuredTime; diff --git a/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp b/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp index 5e9e501adc9..d4edb6dbac2 100644 --- a/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp +++ b/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp @@ -35,12 +35,11 @@ #include QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(QmlProfiler::Internal::QV8EventData, Q_MOVABLE_TYPE); -Q_DECLARE_TYPEINFO(QmlProfiler::Internal::QV8EventSub, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QmlProfiler::QV8EventData, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QmlProfiler::QV8EventSub, Q_MOVABLE_TYPE); QT_END_NAMESPACE namespace QmlProfiler { -namespace Internal { typedef QHash EventHash; @@ -101,35 +100,23 @@ class QV8ProfilerDataModel::QV8ProfilerDataModelPrivate public: QV8ProfilerDataModelPrivate(QV8ProfilerDataModel *qq) {Q_UNUSED(qq);} - void clearV8RootEvent(); - void collectV8Statistics(); - QHash v8EventHash; QList pendingRewrites; QHash v8parents; QV8EventData v8RootEvent; qint64 v8MeasuredTime; - QmlProfilerDetailsRewriter *detailsRewriter; }; QV8ProfilerDataModel::QV8ProfilerDataModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent) - : QmlProfilerBaseModel(parent) - , d(new QV8ProfilerDataModelPrivate(this)) + : QmlProfilerBaseModel(fileFinder, parent), d(new QV8ProfilerDataModelPrivate(this)) { - d->detailsRewriter = new QmlProfilerDetailsRewriter(this, fileFinder); d->v8MeasuredTime = 0; - d->clearV8RootEvent(); - - connect(d->detailsRewriter, SIGNAL(rewriteDetailsString(int,QString)), - this, SLOT(detailsChanged(int,QString))); - connect(d->detailsRewriter, SIGNAL(eventDetailsChanged()), - this, SLOT(detailsDone())); + clearV8RootEvent(); } QV8ProfilerDataModel::~QV8ProfilerDataModel() { - delete d->detailsRewriter; delete d; } @@ -138,9 +125,8 @@ void QV8ProfilerDataModel::clear() qDeleteAll(d->v8EventHash.values()); d->v8EventHash.clear(); d->v8parents.clear(); - d->clearV8RootEvent(); + clearV8RootEvent(); d->v8MeasuredTime = 0; - d->detailsRewriter->clearRequests(); d->pendingRewrites.clear(); QmlProfilerBaseModel::clear(); @@ -243,28 +229,21 @@ void QV8ProfilerDataModel::addV8Event(int depth, void QV8ProfilerDataModel::detailsChanged(int requestId, const QString &newString) { QTC_ASSERT(requestId < d->pendingRewrites.count(), return); - - QV8EventData *event = d->pendingRewrites[requestId]; - event->filename = newString; + d->pendingRewrites[requestId]->filename = newString; } void QV8ProfilerDataModel::detailsDone() { d->pendingRewrites.clear(); - QmlProfilerBaseModel::complete(); + QmlProfilerBaseModel::detailsDone(); } -void QV8ProfilerDataModel::collectV8Statistics() +void QV8ProfilerDataModel::complete() { - d->collectV8Statistics(); -} - -void QV8ProfilerDataModel::QV8ProfilerDataModelPrivate::collectV8Statistics() -{ - if (!v8EventHash.isEmpty()) { - double totalTimes = v8MeasuredTime; + if (!d->v8EventHash.isEmpty()) { + double totalTimes = d->v8MeasuredTime; double selfTimes = 0; - foreach (const QV8EventData *v8event, v8EventHash) { + foreach (const QV8EventData *v8event, d->v8EventHash) { selfTimes += v8event->selfTime; } @@ -276,58 +255,59 @@ void QV8ProfilerDataModel::QV8ProfilerDataModelPrivate::collectV8Statistics() // insert root event in eventlist // the +1 ns is to get it on top of the sorted list - v8RootEvent.totalTime = v8MeasuredTime + 1; - v8RootEvent.selfTime = 0; + d->v8RootEvent.totalTime = d->v8MeasuredTime + 1; + d->v8RootEvent.selfTime = 0; QString rootEventHash = getHashStringForV8Event( tr(""), tr("Main Program")); - QV8EventData *v8RootEventPointer = v8EventHash[rootEventHash]; + QV8EventData *v8RootEventPointer = d->v8EventHash[rootEventHash]; if (v8RootEventPointer) { - v8RootEvent = *v8RootEventPointer; + d->v8RootEvent = *v8RootEventPointer; } else { - v8EventHash[rootEventHash] = new QV8EventData; - *v8EventHash[rootEventHash] = v8RootEvent; + d->v8EventHash[rootEventHash] = new QV8EventData; + *(d->v8EventHash[rootEventHash]) = d->v8RootEvent; } - foreach (QV8EventData *v8event, v8EventHash) { + foreach (QV8EventData *v8event, d->v8EventHash) { v8event->totalPercent = v8event->totalTime * 100.0 / totalTimes; v8event->SelfTimeInPercent = v8event->selfTime * 100.0 / selfTimes; } - int index = pendingRewrites.size(); - foreach (QV8EventData *v8event, v8EventHash.values()) { + int index = d->pendingRewrites.size(); + foreach (QV8EventData *v8event, d->v8EventHash.values()) { v8event->eventId = index++; - pendingRewrites << v8event; - detailsRewriter->requestDetailsForLocation(index, + d->pendingRewrites << v8event; + m_detailsRewriter.requestDetailsForLocation(index, QmlDebug::QmlEventLocation(v8event->filename, v8event->line, 1)); } - v8RootEvent.eventId = v8EventHash[rootEventHash]->eventId; + d->v8RootEvent.eventId = d->v8EventHash[rootEventHash]->eventId; } else { // On empty data, still add a fake root event clearV8RootEvent(); } - detailsRewriter->reloadDocuments(); + + QmlProfilerBaseModel::complete(); } -void QV8ProfilerDataModel::QV8ProfilerDataModelPrivate::clearV8RootEvent() +void QV8ProfilerDataModel::clearV8RootEvent() { - v8RootEvent.displayName = tr(""); - v8RootEvent.eventHashStr = tr(""); - v8RootEvent.functionName = tr("Main Program"); + d->v8RootEvent.displayName = tr(""); + d->v8RootEvent.eventHashStr = tr(""); + d->v8RootEvent.functionName = tr("Main Program"); - v8RootEvent.line = -1; - v8RootEvent.totalTime = 0; - v8RootEvent.totalPercent = 0; - v8RootEvent.selfTime = 0; - v8RootEvent.SelfTimeInPercent = 0; - v8RootEvent.eventId = -1; + d->v8RootEvent.line = -1; + d->v8RootEvent.totalTime = 0; + d->v8RootEvent.totalPercent = 0; + d->v8RootEvent.selfTime = 0; + d->v8RootEvent.SelfTimeInPercent = 0; + d->v8RootEvent.eventId = -1; - qDeleteAll(v8RootEvent.parentHash.values()); - qDeleteAll(v8RootEvent.childrenHash.values()); - v8RootEvent.parentHash.clear(); - v8RootEvent.childrenHash.clear(); + qDeleteAll(d->v8RootEvent.parentHash.values()); + qDeleteAll(d->v8RootEvent.childrenHash.values()); + d->v8RootEvent.parentHash.clear(); + d->v8RootEvent.childrenHash.clear(); } void QV8ProfilerDataModel::save(QXmlStreamWriter &stream) @@ -509,14 +489,7 @@ void QV8ProfilerDataModel::load(QXmlStreamReader &stream) d->v8EventHash[storedV8Event->eventHashStr] = storedV8Event; } - d->collectV8Statistics(); - + complete(); } -void QV8ProfilerDataModel::complete() -{ - collectV8Statistics(); -} - -} // namespace Internal } // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qv8profilerdatamodel.h b/src/plugins/qmlprofiler/qv8profilerdatamodel.h index 2dab1608007..48492405bf5 100644 --- a/src/plugins/qmlprofiler/qv8profilerdatamodel.h +++ b/src/plugins/qmlprofiler/qv8profilerdatamodel.h @@ -40,7 +40,6 @@ #include namespace QmlProfiler { -namespace Internal { struct QV8EventSub; @@ -86,7 +85,6 @@ public: QV8EventData *v8EventDescription(int eventId) const; qint64 v8MeasuredTime() const; - void collectV8Statistics(); void save(QXmlStreamWriter &stream); void load(QXmlStreamReader &stream); @@ -106,9 +104,9 @@ public slots: private: class QV8ProfilerDataModelPrivate; QV8ProfilerDataModelPrivate *d; + void clearV8RootEvent(); }; -} // namespace Internal } // namespace QmlProfiler #endif // QV8PROFILERDATAMODEL_H diff --git a/src/plugins/qmlprofiler/qv8profilereventview.cpp b/src/plugins/qmlprofiler/qv8profilereventview.cpp index 71166cb4b9a..dc87af30612 100644 --- a/src/plugins/qmlprofiler/qv8profilereventview.cpp +++ b/src/plugins/qmlprofiler/qv8profilereventview.cpp @@ -443,7 +443,7 @@ void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFr } if (m_fieldShown[TotalTime]) { - newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(v8event->totalTime)); + newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(v8event->totalTime)); newRow.last()->setData(QVariant(v8event->totalTime)); } @@ -453,7 +453,7 @@ void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFr } if (m_fieldShown[SelfTime]) { - newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(v8event->selfTime)); + newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(v8event->selfTime)); newRow.last()->setData(QVariant(v8event->selfTime)); } @@ -665,7 +665,7 @@ void QV8ProfilerEventRelativesView::rebuildTree(QList events) foreach (QV8EventSub *event, events) { QList newRow; newRow << new EventsViewItem(event->reference->displayName); - newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event->totalTime)); + newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event->totalTime)); newRow << new EventsViewItem(event->reference->functionName); newRow.at(0)->setData(QVariant(event->reference->eventId), EventIdRole); newRow.at(1)->setData(QVariant(event->totalTime)); diff --git a/src/plugins/qmlprofiler/qv8profilereventview.h b/src/plugins/qmlprofiler/qv8profilereventview.h index 54dda682133..6224d526263 100644 --- a/src/plugins/qmlprofiler/qv8profilereventview.h +++ b/src/plugins/qmlprofiler/qv8profilereventview.h @@ -41,11 +41,12 @@ #include "qmlprofilerviewmanager.h" namespace QmlProfiler { +struct QV8EventSub; + namespace Internal { class QV8ProfilerEventsMainView; class QV8ProfilerEventRelativesView; -struct QV8EventSub; class QV8ProfilerEventsWidget : public QWidget diff --git a/src/plugins/qmlprofiler/singlecategorytimelinemodel.cpp b/src/plugins/qmlprofiler/singlecategorytimelinemodel.cpp index 604e299cc78..61b1da3cc0e 100644 --- a/src/plugins/qmlprofiler/singlecategorytimelinemodel.cpp +++ b/src/plugins/qmlprofiler/singlecategorytimelinemodel.cpp @@ -45,7 +45,7 @@ SingleCategoryTimelineModel::SingleCategoryTimelineModel(SingleCategoryTimelineM /////////////////// QML interface -bool SingleCategoryTimelineModel::eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const +bool SingleCategoryTimelineModel::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const { Q_D(const SingleCategoryTimelineModel); return (event.eventType == d->eventType); diff --git a/src/plugins/qmlprofiler/singlecategorytimelinemodel.h b/src/plugins/qmlprofiler/singlecategorytimelinemodel.h index e14ab7e818d..005f7c2a6db 100644 --- a/src/plugins/qmlprofiler/singlecategorytimelinemodel.h +++ b/src/plugins/qmlprofiler/singlecategorytimelinemodel.h @@ -39,7 +39,7 @@ class QMLPROFILER_EXPORT SingleCategoryTimelineModel : public AbstractTimelineMo { Q_OBJECT public: - bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const; + bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const; Q_INVOKABLE bool expanded(int) const; Q_INVOKABLE void setExpanded(int, bool expanded); diff --git a/src/plugins/qmlprofiler/timelinemodelaggregator.cpp b/src/plugins/qmlprofiler/timelinemodelaggregator.cpp index 571b46e62c3..53a16db8137 100644 --- a/src/plugins/qmlprofiler/timelinemodelaggregator.cpp +++ b/src/plugins/qmlprofiler/timelinemodelaggregator.cpp @@ -143,7 +143,7 @@ bool TimelineModelAggregator::isEmpty() const return true; } -bool TimelineModelAggregator::eventAccepted(const QmlProfilerSimpleModel::QmlEventData &/*event*/) const +bool TimelineModelAggregator::eventAccepted(const QmlProfilerDataModel::QmlEventData &/*event*/) const { // accept all events return true; diff --git a/src/plugins/qmlprofiler/timelinemodelaggregator.h b/src/plugins/qmlprofiler/timelinemodelaggregator.h index 06ba24401f7..8ec686d0aab 100644 --- a/src/plugins/qmlprofiler/timelinemodelaggregator.h +++ b/src/plugins/qmlprofiler/timelinemodelaggregator.h @@ -61,7 +61,7 @@ public: bool isEmpty() const; - bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const; + bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const; Q_INVOKABLE int basicModelIndex() const;