forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
};
|
||||
|
@@ -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 {
|
||||
|
||||
|
Reference in New Issue
Block a user