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:
|
public:
|
||||||
QVector<QmlEventType> eventTypes;
|
QVector<QmlEventType> eventTypes;
|
||||||
QVector<QmlEvent> eventList;
|
QVector<QmlEvent> eventList;
|
||||||
QVector<QmlNote> eventNotes;
|
|
||||||
QHash<QmlEventType, int> eventTypeIds;
|
QHash<QmlEventType, int> eventTypeIds;
|
||||||
|
|
||||||
QmlProfilerModelManager *modelManager;
|
QmlProfilerModelManager *modelManager;
|
||||||
@@ -136,12 +135,6 @@ const QVector<QmlEventType> &QmlProfilerDataModel::eventTypes() const
|
|||||||
return d->eventTypes;
|
return d->eventTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<QmlNote> &QmlProfilerDataModel::notes() const
|
|
||||||
{
|
|
||||||
Q_D(const QmlProfilerDataModel);
|
|
||||||
return d->eventNotes;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProfilerDataModel::setData(qint64 traceStart, qint64 traceEnd,
|
void QmlProfilerDataModel::setData(qint64 traceStart, qint64 traceEnd,
|
||||||
const QVector<QmlEventType> &types,
|
const QVector<QmlEventType> &types,
|
||||||
const QVector<QmlEvent> &events)
|
const QVector<QmlEvent> &events)
|
||||||
@@ -156,12 +149,6 @@ void QmlProfilerDataModel::setData(qint64 traceStart, qint64 traceEnd,
|
|||||||
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 2);
|
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerDataModel::setNotes(const QVector<QmlNote> ¬es)
|
|
||||||
{
|
|
||||||
Q_D(QmlProfilerDataModel);
|
|
||||||
d->eventNotes = notes;
|
|
||||||
}
|
|
||||||
|
|
||||||
int QmlProfilerDataModel::count() const
|
int QmlProfilerDataModel::count() const
|
||||||
{
|
{
|
||||||
Q_D(const QmlProfilerDataModel);
|
Q_D(const QmlProfilerDataModel);
|
||||||
@@ -174,7 +161,6 @@ void QmlProfilerDataModel::clear()
|
|||||||
d->eventList.clear();
|
d->eventList.clear();
|
||||||
d->eventTypes.clear();
|
d->eventTypes.clear();
|
||||||
d->eventTypeIds.clear();
|
d->eventTypeIds.clear();
|
||||||
d->eventNotes.clear();
|
|
||||||
d->detailsRewriter->clearRequests();
|
d->detailsRewriter->clearRequests();
|
||||||
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
|
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
|
||||||
emit changed();
|
emit changed();
|
||||||
|
@@ -30,7 +30,6 @@
|
|||||||
#include "qmlprofilereventlocation.h"
|
#include "qmlprofilereventlocation.h"
|
||||||
#include "qmleventtype.h"
|
#include "qmleventtype.h"
|
||||||
#include "qmlevent.h"
|
#include "qmlevent.h"
|
||||||
#include "qmlnote.h"
|
|
||||||
|
|
||||||
#include <utils/fileinprojectfinder.h>
|
#include <utils/fileinprojectfinder.h>
|
||||||
|
|
||||||
@@ -48,10 +47,8 @@ public:
|
|||||||
|
|
||||||
const QVector<QmlEvent> &events() const;
|
const QVector<QmlEvent> &events() const;
|
||||||
const QVector<QmlEventType> &eventTypes() const;
|
const QVector<QmlEventType> &eventTypes() const;
|
||||||
const QVector<QmlNote> ¬es() const;
|
|
||||||
void setData(qint64 traceStart, qint64 traceEnd, const QVector<QmlEventType> &types,
|
void setData(qint64 traceStart, qint64 traceEnd, const QVector<QmlEventType> &types,
|
||||||
const QVector<QmlEvent> &events);
|
const QVector<QmlEvent> &events);
|
||||||
void setNotes(const QVector<QmlNote> ¬es);
|
|
||||||
void processData();
|
void processData();
|
||||||
|
|
||||||
int count() const;
|
int count() const;
|
||||||
|
@@ -164,7 +164,6 @@ QmlProfilerModelManager::QmlProfilerModelManager(Utils::FileInProjectFinder *fin
|
|||||||
d->state = Empty;
|
d->state = Empty;
|
||||||
d->traceTime = new QmlProfilerTraceTime(this);
|
d->traceTime = new QmlProfilerTraceTime(this);
|
||||||
d->notesModel = new QmlProfilerNotesModel(this);
|
d->notesModel = new QmlProfilerNotesModel(this);
|
||||||
d->notesModel->setModelManager(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerModelManager::~QmlProfilerModelManager()
|
QmlProfilerModelManager::~QmlProfilerModelManager()
|
||||||
@@ -335,7 +334,7 @@ void QmlProfilerModelManager::save(const QString &filename)
|
|||||||
writer->setTraceTime(traceTime()->startTime(), traceTime()->endTime(),
|
writer->setTraceTime(traceTime()->startTime(), traceTime()->endTime(),
|
||||||
traceTime()->duration());
|
traceTime()->duration());
|
||||||
writer->setData(d->model->eventTypes(), d->model->events());
|
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,
|
connect(writer, &QObject::destroyed, this, &QmlProfilerModelManager::saveFinished,
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
@@ -373,7 +372,7 @@ void QmlProfilerModelManager::load(const QString &filename)
|
|||||||
connect(reader, &QmlProfilerFileReader::success, this, [this, reader]() {
|
connect(reader, &QmlProfilerFileReader::success, this, [this, reader]() {
|
||||||
d->model->setData(reader->traceStart(), qMax(reader->traceStart(), reader->traceEnd()),
|
d->model->setData(reader->traceStart(), qMax(reader->traceStart(), reader->traceEnd()),
|
||||||
reader->eventTypes(), reader->events());
|
reader->eventTypes(), reader->events());
|
||||||
d->model->setNotes(reader->notes());
|
d->notesModel->setNotes(reader->notes());
|
||||||
setRecordedFeatures(reader->loadedFeatures());
|
setRecordedFeatures(reader->loadedFeatures());
|
||||||
d->traceTime->increaseEndTime(d->model->lastTimeMark());
|
d->traceTime->increaseEndTime(d->model->lastTimeMark());
|
||||||
delete reader;
|
delete reader;
|
||||||
|
@@ -28,16 +28,10 @@
|
|||||||
|
|
||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
|
|
||||||
QmlProfilerNotesModel::QmlProfilerNotesModel(QObject *parent) : TimelineNotesModel(parent),
|
QmlProfilerNotesModel::QmlProfilerNotesModel(QObject *parent) : TimelineNotesModel(parent)
|
||||||
m_modelManager(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerNotesModel::setModelManager(QmlProfilerModelManager *modelManager)
|
|
||||||
{
|
|
||||||
m_modelManager = modelManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
int QmlProfilerNotesModel::add(int typeId, qint64 start, qint64 duration, const QString &text)
|
int QmlProfilerNotesModel::add(int typeId, qint64 start, qint64 duration, const QString &text)
|
||||||
{
|
{
|
||||||
int timelineModel = -1;
|
int timelineModel = -1;
|
||||||
@@ -69,10 +63,9 @@ int QmlProfilerNotesModel::add(int typeId, qint64 start, qint64 duration, const
|
|||||||
void QmlProfilerNotesModel::loadData()
|
void QmlProfilerNotesModel::loadData()
|
||||||
{
|
{
|
||||||
blockSignals(true);
|
blockSignals(true);
|
||||||
clear();
|
TimelineNotesModel::clear();
|
||||||
const QVector<QmlNote> ¬es = m_modelManager->qmlModel()->notes();
|
for (int i = 0; i != m_notes.size(); ++i) {
|
||||||
for (int i = 0; i != notes.size(); ++i) {
|
const QmlNote ¬e = m_notes[i];
|
||||||
const QmlNote ¬e = notes[i];
|
|
||||||
add(note.typeIndex, note.startTime, note.duration, note.text);
|
add(note.typeIndex, note.startTime, note.duration, note.text);
|
||||||
}
|
}
|
||||||
resetModified();
|
resetModified();
|
||||||
@@ -82,7 +75,7 @@ void QmlProfilerNotesModel::loadData()
|
|||||||
|
|
||||||
void QmlProfilerNotesModel::saveData()
|
void QmlProfilerNotesModel::saveData()
|
||||||
{
|
{
|
||||||
QVector<QmlNote> notes;
|
m_notes.clear();
|
||||||
for (int i = 0; i < count(); ++i) {
|
for (int i = 0; i < count(); ++i) {
|
||||||
const Timeline::TimelineModel *model = timelineModelByModelId(timelineModel(i));
|
const Timeline::TimelineModel *model = timelineModelByModelId(timelineModel(i));
|
||||||
if (!model)
|
if (!model)
|
||||||
@@ -95,9 +88,25 @@ void QmlProfilerNotesModel::saveData()
|
|||||||
model->duration(index),
|
model->duration(index),
|
||||||
text(i)
|
text(i)
|
||||||
};
|
};
|
||||||
notes.append(save);
|
m_notes.append(save);
|
||||||
}
|
}
|
||||||
m_modelManager->qmlModel()->setNotes(notes);
|
|
||||||
resetModified();
|
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
|
#pragma once
|
||||||
|
|
||||||
#include "qmlprofilermodelmanager.h"
|
#include "qmlprofilermodelmanager.h"
|
||||||
|
#include "qmlnote.h"
|
||||||
#include "timeline/timelinenotesmodel.h"
|
#include "timeline/timelinenotesmodel.h"
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
@@ -36,12 +37,15 @@ class QMLPROFILER_EXPORT QmlProfilerNotesModel : public Timeline::TimelineNotesM
|
|||||||
public:
|
public:
|
||||||
QmlProfilerNotesModel(QObject *parent);
|
QmlProfilerNotesModel(QObject *parent);
|
||||||
|
|
||||||
void setModelManager(QmlProfilerModelManager *modelManager);
|
|
||||||
void loadData();
|
void loadData();
|
||||||
void saveData();
|
void saveData();
|
||||||
|
|
||||||
|
const QVector<QmlNote> ¬es() const;
|
||||||
|
void setNotes(const QVector<QmlNote> ¬es);
|
||||||
|
void clear();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QmlProfilerModelManager *m_modelManager;
|
QVector<QmlNote> m_notes;
|
||||||
|
|
||||||
int add(int typeId, qint64 startTime, qint64 duration, const QString &text);
|
int add(int typeId, qint64 startTime, qint64 duration, const QString &text);
|
||||||
};
|
};
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "qmlprofilereventlocation.h"
|
#include "qmlprofilereventlocation.h"
|
||||||
#include "qmlprofilereventtypes.h"
|
#include "qmlprofilereventtypes.h"
|
||||||
#include "qmlprofilerdatamodel.h"
|
#include "qmlprofilerdatamodel.h"
|
||||||
|
#include "qmlnote.h"
|
||||||
|
|
||||||
#include <QFutureInterface>
|
#include <QFutureInterface>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -37,7 +38,6 @@
|
|||||||
QT_FORWARD_DECLARE_CLASS(QIODevice)
|
QT_FORWARD_DECLARE_CLASS(QIODevice)
|
||||||
QT_FORWARD_DECLARE_CLASS(QXmlStreamReader)
|
QT_FORWARD_DECLARE_CLASS(QXmlStreamReader)
|
||||||
|
|
||||||
|
|
||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user