diff --git a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp index 0a412c75884..c6410bc693b 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp @@ -126,6 +126,18 @@ const QVector &QmlProfilerDataModel::get return d->eventTypes; } +void QmlProfilerDataModel::setData(const QVector &types, + const QVector &events) +{ + Q_D(QmlProfilerDataModel); + d->eventList = events; + d->eventTypes = types; + for (int id = 0; id < types.count(); ++id) + d->eventTypeIds[types[id]] = id; + // Half the work is done. complete() will do the rest. + d->modelManager->modelProxyCountUpdated(d->modelId, 1, 2); +} + int QmlProfilerDataModel::count() const { Q_D(const QmlProfilerDataModel); diff --git a/src/plugins/qmlprofiler/qmlprofilerdatamodel.h b/src/plugins/qmlprofiler/qmlprofilerdatamodel.h index c23fa118e37..59bd596df70 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.h +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.h @@ -63,6 +63,8 @@ public: const QVector &getEvents() const; const QVector &getEventTypes() const; + void setData(const QVector &types, const QVector &events); + int count() const; virtual void clear(); virtual bool isEmpty() const; diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp index c7bcd297ae4..4e633cbdd48 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp @@ -367,15 +367,10 @@ void QmlProfilerModelManager::load() QmlProfilerFileReader reader; connect(&reader, SIGNAL(error(QString)), this, SIGNAL(error(QString))); - connect(&reader, SIGNAL(rangedEvent(QmlDebug::Message,QmlDebug::RangeType,int,qint64,qint64, - QString,QmlDebug::QmlEventLocation, - qint64, qint64, qint64, qint64, qint64)), - this, SLOT(addQmlEvent(QmlDebug::Message,QmlDebug::RangeType,int,qint64,qint64, - QString,QmlDebug::QmlEventLocation, - qint64, qint64, qint64, qint64, qint64))); connect(&reader, SIGNAL(traceStartTime(qint64)), traceTime(), SLOT(setStartTime(qint64))); connect(&reader, SIGNAL(traceEndTime(qint64)), traceTime(), SLOT(setEndTime(qint64))); reader.setV8DataModel(d->v8Model); + reader.setQmlDataModel(d->model); reader.load(&file); complete(); diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp index ab06970e04c..637043053f9 100644 --- a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp @@ -130,6 +130,11 @@ void QmlProfilerFileReader::setV8DataModel(QV8ProfilerDataModel *dataModel) m_v8Model = dataModel; } +void QmlProfilerFileReader::setQmlDataModel(QmlProfilerDataModel *dataModel) +{ + m_qmlModel = dataModel; +} + bool QmlProfilerFileReader::load(QIODevice *device) { QXmlStreamReader stream(device); @@ -180,8 +185,7 @@ bool QmlProfilerFileReader::load(QIODevice *device) emit error(tr("Error while parsing trace data file: %1").arg(stream.errorString())); return false; } else { - processQmlEvents(); - + m_qmlModel->setData(m_qmlEvents, m_ranges); return true; } } @@ -372,28 +376,6 @@ void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream) } } -void QmlProfilerFileReader::processQmlEvents() -{ - for (int i = 0; i < m_ranges.size(); ++i) { - const QmlProfilerDataModel::QmlEventData &range = m_ranges[i]; - int eventIndex = range.typeIndex; - - if (eventIndex < 0 || eventIndex >= m_qmlEvents.size()) { - qWarning() << ".qtd file - range index" << eventIndex - << "is outside of bounds (0, " << m_qmlEvents.size() << ")"; - continue; - } - - const QmlProfilerDataModel::QmlEventTypeData &event = m_qmlEvents[eventIndex]; - - emit rangedEvent(event.message, event.rangeType, event.detailType, range.startTime, - range.duration, event.data, event.location, - range.numericData1,range.numericData2, range.numericData3, - range.numericData4, range.numericData5); - - } -} - QmlProfilerFileWriter::QmlProfilerFileWriter(QObject *parent) : QObject(parent), m_startTime(0), diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.h b/src/plugins/qmlprofiler/qmlprofilertracefile.h index 676819a99f6..fa40d9bae61 100644 --- a/src/plugins/qmlprofiler/qmlprofilertracefile.h +++ b/src/plugins/qmlprofiler/qmlprofilertracefile.h @@ -55,6 +55,7 @@ public: explicit QmlProfilerFileReader(QObject *parent = 0); void setV8DataModel(QV8ProfilerDataModel *dataModel); + void setQmlDataModel(QmlProfilerDataModel *dataModel); bool load(QIODevice *device); @@ -62,20 +63,14 @@ signals: void traceStartTime(qint64 traceStartTime); void traceEndTime(qint64 traceStartTime); - void rangedEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType, int detailType, - qint64 startTime, qint64 length, const QString &data, - const QmlDebug::QmlEventLocation &location, - qint64 param1, qint64 param2, qint64 param3, qint64 param4, qint64 param5); void error(const QString &error); private: void loadEventData(QXmlStreamReader &reader); void loadProfilerDataModel(QXmlStreamReader &reader); - void processQmlEvents(); - - QV8ProfilerDataModel *m_v8Model; + QmlProfilerDataModel *m_qmlModel; QVector m_qmlEvents; QVector m_ranges; };