From 54b1106f4b5f912220f8dd1dc77129e81d59e05b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 26 Apr 2016 12:26:46 +0200 Subject: [PATCH] QmlProfiler: Move notes into the notes model There is not reason to keep them in the general data model and cross reference between the models all the time. Change-Id: Ic77c518928dcd6234555cb3f6a830bcc3dc4a1a4 Reviewed-by: Joerg Bornemann --- .../qmlprofiler/qmlprofilerdatamodel.cpp | 14 ------- .../qmlprofiler/qmlprofilerdatamodel.h | 3 -- .../qmlprofiler/qmlprofilermodelmanager.cpp | 5 +-- .../qmlprofiler/qmlprofilernotesmodel.cpp | 37 ++++++++++++------- .../qmlprofiler/qmlprofilernotesmodel.h | 8 +++- .../qmlprofiler/qmlprofilertracefile.h | 2 +- 6 files changed, 32 insertions(+), 37 deletions(-) diff --git a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp index e81e41c8103..43395b94d3a 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp @@ -41,7 +41,6 @@ class QmlProfilerDataModel::QmlProfilerDataModelPrivate public: QVector eventTypes; QVector eventList; - QVector eventNotes; QHash eventTypeIds; QmlProfilerModelManager *modelManager; @@ -136,12 +135,6 @@ const QVector &QmlProfilerDataModel::eventTypes() const return d->eventTypes; } -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) @@ -156,12 +149,6 @@ void QmlProfilerDataModel::setData(qint64 traceStart, qint64 traceEnd, d->modelManager->modelProxyCountUpdated(d->modelId, 1, 2); } -void QmlProfilerDataModel::setNotes(const QVector ¬es) -{ - Q_D(QmlProfilerDataModel); - d->eventNotes = notes; -} - int QmlProfilerDataModel::count() const { Q_D(const QmlProfilerDataModel); @@ -174,7 +161,6 @@ void QmlProfilerDataModel::clear() d->eventList.clear(); d->eventTypes.clear(); d->eventTypeIds.clear(); - d->eventNotes.clear(); d->detailsRewriter->clearRequests(); d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1); emit changed(); diff --git a/src/plugins/qmlprofiler/qmlprofilerdatamodel.h b/src/plugins/qmlprofiler/qmlprofilerdatamodel.h index c46cfa26087..8e2f490149a 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.h +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.h @@ -30,7 +30,6 @@ #include "qmlprofilereventlocation.h" #include "qmleventtype.h" #include "qmlevent.h" -#include "qmlnote.h" #include @@ -48,10 +47,8 @@ public: 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; diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp index 37799cd9e72..c8c71a27c28 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp @@ -164,7 +164,6 @@ QmlProfilerModelManager::QmlProfilerModelManager(Utils::FileInProjectFinder *fin d->state = Empty; d->traceTime = new QmlProfilerTraceTime(this); d->notesModel = new QmlProfilerNotesModel(this); - d->notesModel->setModelManager(this); } QmlProfilerModelManager::~QmlProfilerModelManager() @@ -335,7 +334,7 @@ void QmlProfilerModelManager::save(const QString &filename) writer->setTraceTime(traceTime()->startTime(), traceTime()->endTime(), traceTime()->duration()); writer->setData(d->model->eventTypes(), d->model->events()); - writer->setNotes(d->model->notes()); + writer->setNotes(d->notesModel->notes()); connect(writer, &QObject::destroyed, this, &QmlProfilerModelManager::saveFinished, Qt::QueuedConnection); @@ -373,7 +372,7 @@ void QmlProfilerModelManager::load(const QString &filename) connect(reader, &QmlProfilerFileReader::success, this, [this, reader]() { d->model->setData(reader->traceStart(), qMax(reader->traceStart(), reader->traceEnd()), reader->eventTypes(), reader->events()); - d->model->setNotes(reader->notes()); + d->notesModel->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 c656763c674..8717c5dc323 100644 --- a/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp @@ -28,16 +28,10 @@ namespace QmlProfiler { -QmlProfilerNotesModel::QmlProfilerNotesModel(QObject *parent) : TimelineNotesModel(parent), - m_modelManager(0) +QmlProfilerNotesModel::QmlProfilerNotesModel(QObject *parent) : TimelineNotesModel(parent) { } -void QmlProfilerNotesModel::setModelManager(QmlProfilerModelManager *modelManager) -{ - m_modelManager = modelManager; -} - int QmlProfilerNotesModel::add(int typeId, qint64 start, qint64 duration, const QString &text) { int timelineModel = -1; @@ -69,10 +63,9 @@ int QmlProfilerNotesModel::add(int typeId, qint64 start, qint64 duration, const void QmlProfilerNotesModel::loadData() { blockSignals(true); - clear(); - const QVector ¬es = m_modelManager->qmlModel()->notes(); - for (int i = 0; i != notes.size(); ++i) { - const QmlNote ¬e = notes[i]; + TimelineNotesModel::clear(); + for (int i = 0; i != m_notes.size(); ++i) { + const QmlNote ¬e = m_notes[i]; add(note.typeIndex, note.startTime, note.duration, note.text); } resetModified(); @@ -82,7 +75,7 @@ void QmlProfilerNotesModel::loadData() void QmlProfilerNotesModel::saveData() { - QVector notes; + m_notes.clear(); for (int i = 0; i < count(); ++i) { const Timeline::TimelineModel *model = timelineModelByModelId(timelineModel(i)); if (!model) @@ -95,9 +88,25 @@ void QmlProfilerNotesModel::saveData() model->duration(index), text(i) }; - notes.append(save); + m_notes.append(save); } - m_modelManager->qmlModel()->setNotes(notes); resetModified(); } + +const QVector &QmlProfilerNotesModel::notes() const +{ + return m_notes; } + +void QmlProfilerNotesModel::setNotes(const QVector ¬es) +{ + m_notes = notes; +} + +void QmlProfilerNotesModel::clear() +{ + TimelineNotesModel::clear(); + m_notes.clear(); +} + +} // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmlprofilernotesmodel.h b/src/plugins/qmlprofiler/qmlprofilernotesmodel.h index c5bc56bb85f..26f56c102fa 100644 --- a/src/plugins/qmlprofiler/qmlprofilernotesmodel.h +++ b/src/plugins/qmlprofiler/qmlprofilernotesmodel.h @@ -26,6 +26,7 @@ #pragma once #include "qmlprofilermodelmanager.h" +#include "qmlnote.h" #include "timeline/timelinenotesmodel.h" #include #include @@ -36,12 +37,15 @@ class QMLPROFILER_EXPORT QmlProfilerNotesModel : public Timeline::TimelineNotesM public: QmlProfilerNotesModel(QObject *parent); - void setModelManager(QmlProfilerModelManager *modelManager); void loadData(); void saveData(); + const QVector ¬es() const; + void setNotes(const QVector ¬es); + void clear(); + protected: - QmlProfilerModelManager *m_modelManager; + QVector m_notes; int add(int typeId, qint64 startTime, qint64 duration, const QString &text); }; diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.h b/src/plugins/qmlprofiler/qmlprofilertracefile.h index 6d5c9b15e7b..831e4d4fe4c 100644 --- a/src/plugins/qmlprofiler/qmlprofilertracefile.h +++ b/src/plugins/qmlprofiler/qmlprofilertracefile.h @@ -28,6 +28,7 @@ #include "qmlprofilereventlocation.h" #include "qmlprofilereventtypes.h" #include "qmlprofilerdatamodel.h" +#include "qmlnote.h" #include #include @@ -37,7 +38,6 @@ QT_FORWARD_DECLARE_CLASS(QIODevice) QT_FORWARD_DECLARE_CLASS(QXmlStreamReader) - namespace QmlProfiler { namespace Internal {