diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2016-04-26 12:26:46 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2016-05-06 10:26:13 +0000 |
commit | 54b1106f4b5f912220f8dd1dc77129e81d59e05b (patch) | |
tree | 3dad7e04fd04e799a3b3b16df9b7677e94bc3881 | |
parent | d6f351b689ed5fd91af94f695ab753ba6d8897d9 (diff) | |
download | qt-creator-54b1106f4b5f912220f8dd1dc77129e81d59e05b.tar.gz |
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 <joerg.bornemann@theqtcompany.com>
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp | 14 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerdatamodel.h | 3 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp | 5 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp | 37 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilernotesmodel.h | 8 | ||||
-rw-r--r-- | src/plugins/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 e81e41c810..43395b94d3 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp @@ -41,7 +41,6 @@ class QmlProfilerDataModel::QmlProfilerDataModelPrivate public: QVector<QmlEventType> eventTypes; QVector<QmlEvent> eventList; - QVector<QmlNote> eventNotes; QHash<QmlEventType, int> eventTypeIds; QmlProfilerModelManager *modelManager; @@ -136,12 +135,6 @@ const QVector<QmlEventType> &QmlProfilerDataModel::eventTypes() const return d->eventTypes; } -const QVector<QmlNote> &QmlProfilerDataModel::notes() const -{ - Q_D(const QmlProfilerDataModel); - return d->eventNotes; -} - void QmlProfilerDataModel::setData(qint64 traceStart, qint64 traceEnd, const QVector<QmlEventType> &types, const QVector<QmlEvent> &events) @@ -156,12 +149,6 @@ void QmlProfilerDataModel::setData(qint64 traceStart, qint64 traceEnd, d->modelManager->modelProxyCountUpdated(d->modelId, 1, 2); } -void QmlProfilerDataModel::setNotes(const QVector<QmlNote> ¬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 c46cfa2608..8e2f490149 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 <utils/fileinprojectfinder.h> @@ -48,10 +47,8 @@ public: const QVector<QmlEvent> &events() const; const QVector<QmlEventType> &eventTypes() const; - const QVector<QmlNote> ¬es() const; void setData(qint64 traceStart, qint64 traceEnd, const QVector<QmlEventType> &types, const QVector<QmlEvent> &events); - void setNotes(const QVector<QmlNote> ¬es); void processData(); int count() const; diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp index 37799cd9e7..c8c71a27c2 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 c656763c67..8717c5dc32 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<QmlNote> ¬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<QmlNote> 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<QmlNote> &QmlProfilerNotesModel::notes() const +{ + return m_notes; +} + +void QmlProfilerNotesModel::setNotes(const QVector<QmlNote> ¬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 c5bc56bb85..26f56c102f 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 <QList> #include <QHash> @@ -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<QmlNote> ¬es() const; + void setNotes(const QVector<QmlNote> ¬es); + void clear(); + protected: - QmlProfilerModelManager *m_modelManager; + QVector<QmlNote> 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 6d5c9b15e7..831e4d4fe4 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 <QFutureInterface> #include <QObject> @@ -37,7 +38,6 @@ QT_FORWARD_DECLARE_CLASS(QIODevice) QT_FORWARD_DECLARE_CLASS(QXmlStreamReader) - namespace QmlProfiler { namespace Internal { |