forked from qt-creator/qt-creator
QmlProfiler: Use generic timeline classes where applicable.
Change-Id: I7bab7b20f3467f000a7ba4917919caa8f15ecf22 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
@@ -47,9 +47,9 @@ void QmlProfilerNotesModel::setModelManager(QmlProfilerModelManager *modelManage
|
||||
m_modelManager = modelManager;
|
||||
}
|
||||
|
||||
void QmlProfilerNotesModel::addTimelineModel(const QmlProfilerTimelineModel *timelineModel)
|
||||
void QmlProfilerNotesModel::addTimelineModel(const TimelineModel *timelineModel)
|
||||
{
|
||||
connect(timelineModel, &QmlProfilerTimelineModel::destroyed,
|
||||
connect(timelineModel, &TimelineModel::destroyed,
|
||||
this, &QmlProfilerNotesModel::removeTimelineModel);
|
||||
m_timelineModels.insert(timelineModel->modelId(), timelineModel);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ int QmlProfilerNotesModel::get(int timelineModel, int timelineIndex) const
|
||||
|
||||
int QmlProfilerNotesModel::add(int timelineModel, int timelineIndex, const QString &text)
|
||||
{
|
||||
const QmlProfilerTimelineModel *model = m_timelineModels[timelineModel];
|
||||
const TimelineModel *model = m_timelineModels[timelineModel];
|
||||
int typeId = model->typeId(timelineIndex);
|
||||
Note note = { text, timelineModel, timelineIndex };
|
||||
m_data << note;
|
||||
@@ -160,10 +160,8 @@ int QmlProfilerNotesModel::add(int typeId, qint64 start, qint64 duration, const
|
||||
{
|
||||
int timelineModel = -1;
|
||||
int timelineIndex = -1;
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
|
||||
m_modelManager->qmlModel()->getEventTypes();
|
||||
foreach (const QmlProfilerTimelineModel *model, m_timelineModels) {
|
||||
if (model->accepted(types[typeId])) {
|
||||
foreach (const TimelineModel *model, m_timelineModels) {
|
||||
if (model->handlesTypeId(typeId)) {
|
||||
for (int i = model->firstIndex(start); i <= model->lastIndex(start + duration); ++i) {
|
||||
if (i < 0)
|
||||
continue;
|
||||
@@ -237,7 +235,7 @@ void QmlProfilerNotesModel::saveData()
|
||||
if (it == m_timelineModels.end())
|
||||
continue;
|
||||
|
||||
const QmlProfilerTimelineModel *model = it.value();
|
||||
const TimelineModel *model = it.value();
|
||||
QmlProfilerDataModel::QmlEventNoteData save = {
|
||||
model->typeId(note.timelineIndex), model->startTime(note.timelineIndex),
|
||||
model->duration(note.timelineIndex), note.text
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
int count() const;
|
||||
|
||||
void setModelManager(QmlProfilerModelManager *modelManager);
|
||||
void addTimelineModel(const QmlProfilerTimelineModel *timelineModel);
|
||||
void addTimelineModel(const TimelineModel *timelineModel);
|
||||
|
||||
Q_INVOKABLE int typeId(int index) const;
|
||||
Q_INVOKABLE QString text(int index) const;
|
||||
@@ -86,7 +86,7 @@ private slots:
|
||||
protected:
|
||||
QmlProfilerModelManager *m_modelManager;
|
||||
QList<Note> m_data;
|
||||
QHash<int, const QmlProfilerTimelineModel *> m_timelineModels;
|
||||
QHash<int, const TimelineModel *> m_timelineModels;
|
||||
bool m_modified;
|
||||
|
||||
int add(int typeId, qint64 startTime, qint64 duration, const QString &text);
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "timelinemodelaggregator.h"
|
||||
#include "qmlprofilernotesmodel.h"
|
||||
#include "qmlprofileranimationsmodel.h"
|
||||
#include "qmlprofilerrangemodel.h"
|
||||
#include "qmlprofilerplugin.h"
|
||||
|
||||
// Needed for the load&save actions in the context menu
|
||||
#include <analyzerbase/ianalyzertool.h>
|
||||
@@ -117,11 +120,9 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
|
||||
|
||||
d->m_profilerTool = profilerTool;
|
||||
d->m_viewContainer = container;
|
||||
d->m_modelManager = modelManager;
|
||||
d->m_modelProxy = new TimelineModelAggregator(this);
|
||||
d->m_modelProxy->setModelManager(modelManager);
|
||||
connect(d->m_modelManager, SIGNAL(stateChanged()),
|
||||
this, SLOT(profilerDataModelStateChanged()));
|
||||
|
||||
d->m_modelProxy = new TimelineModelAggregator(modelManager->notesModel(), this);
|
||||
setModelManager(modelManager);
|
||||
d->m_mainView->rootContext()->setContextProperty(QLatin1String("qmlProfilerModelProxy"),
|
||||
d->m_modelProxy);
|
||||
d->m_profilerState = profilerState;
|
||||
@@ -130,6 +131,33 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
|
||||
setMinimumHeight(170);
|
||||
}
|
||||
|
||||
void QmlProfilerTraceView::setModelManager(QmlProfilerModelManager *modelManager)
|
||||
{
|
||||
d->m_modelManager = modelManager;
|
||||
connect(modelManager,SIGNAL(dataAvailable()),
|
||||
d->m_modelProxy,SIGNAL(dataAvailable()));
|
||||
|
||||
// external models pushed on top
|
||||
foreach (QmlProfilerTimelineModel *timelineModel,
|
||||
QmlProfilerPlugin::instance->getModels(modelManager)) {
|
||||
d->m_modelProxy->addModel(timelineModel);
|
||||
}
|
||||
|
||||
d->m_modelProxy->addModel(new QmlProfilerAnimationsModel(modelManager,
|
||||
d->m_modelProxy));
|
||||
|
||||
for (int i = 0; i < QmlDebug::MaximumRangeType; ++i)
|
||||
d->m_modelProxy->addModel(new QmlProfilerRangeModel(modelManager, (QmlDebug::RangeType)i,
|
||||
d->m_modelProxy));
|
||||
|
||||
// Connect this last so that it's executed after the models have updated their data.
|
||||
connect(modelManager->qmlModel(), SIGNAL(changed()),
|
||||
d->m_modelProxy, SIGNAL(stateChanged()));
|
||||
connect(d->m_modelManager, SIGNAL(stateChanged()),
|
||||
this, SLOT(profilerDataModelStateChanged()));
|
||||
}
|
||||
|
||||
|
||||
QmlProfilerTraceView::~QmlProfilerTraceView()
|
||||
{
|
||||
delete d;
|
||||
|
||||
@@ -88,6 +88,7 @@ private:
|
||||
private:
|
||||
class QmlProfilerTraceViewPrivate;
|
||||
QmlProfilerTraceViewPrivate *d;
|
||||
void setModelManager(QmlProfilerModelManager *modelManager);
|
||||
};
|
||||
|
||||
class QmlProfilerQuickView : public QQuickView {
|
||||
|
||||
@@ -49,15 +49,18 @@ public:
|
||||
|
||||
TimelineModelAggregator *q;
|
||||
|
||||
QList <QmlProfilerTimelineModel *> modelList;
|
||||
QmlProfilerModelManager *modelManager;
|
||||
QList <TimelineModel *> modelList;
|
||||
QmlProfilerNotesModel *notesModel;
|
||||
};
|
||||
|
||||
TimelineModelAggregator::TimelineModelAggregator(QObject *parent)
|
||||
TimelineModelAggregator::TimelineModelAggregator(QmlProfilerNotesModel *notes, QObject *parent)
|
||||
: QObject(parent), d(new TimelineModelAggregatorPrivate(this))
|
||||
{
|
||||
d->notesModel = notes;
|
||||
connect(this,SIGNAL(modelsChanged()),this,SIGNAL(heightChanged()));
|
||||
connect(this,SIGNAL(stateChanged()),this,SIGNAL(heightChanged()));
|
||||
connect(notes, SIGNAL(changed(int,int,int)), this, SIGNAL(notesChanged(int,int,int)));
|
||||
|
||||
}
|
||||
|
||||
TimelineModelAggregator::~TimelineModelAggregator()
|
||||
@@ -70,37 +73,15 @@ int TimelineModelAggregator::height() const
|
||||
return modelOffset(d->modelList.length());
|
||||
}
|
||||
|
||||
void TimelineModelAggregator::setModelManager(QmlProfilerModelManager *modelManager)
|
||||
{
|
||||
d->modelManager = modelManager;
|
||||
connect(modelManager,SIGNAL(dataAvailable()),this,SIGNAL(dataAvailable()));
|
||||
|
||||
// external models pushed on top
|
||||
foreach (QmlProfilerTimelineModel *timelineModel,
|
||||
QmlProfilerPlugin::instance->getModels(modelManager)) {
|
||||
addModel(timelineModel);
|
||||
}
|
||||
|
||||
addModel(new QmlProfilerAnimationsModel(modelManager, this));
|
||||
|
||||
for (int i = 0; i < QmlDebug::MaximumRangeType; ++i)
|
||||
addModel(new QmlProfilerRangeModel(modelManager, (QmlDebug::RangeType)i, this));
|
||||
|
||||
// Connect this last so that it's executed after the models have updated their data.
|
||||
connect(modelManager->qmlModel(),SIGNAL(changed()),this,SIGNAL(stateChanged()));
|
||||
connect(modelManager->notesModel(), SIGNAL(changed(int,int,int)),
|
||||
this, SIGNAL(notesChanged(int,int,int)));
|
||||
}
|
||||
|
||||
void TimelineModelAggregator::addModel(QmlProfilerTimelineModel *m)
|
||||
void TimelineModelAggregator::addModel(TimelineModel *m)
|
||||
{
|
||||
d->modelList << m;
|
||||
connect(m,SIGNAL(heightChanged()),this,SIGNAL(heightChanged()));
|
||||
d->modelManager->notesModel()->addTimelineModel(m);
|
||||
d->notesModel->addTimelineModel(m);
|
||||
emit modelsChanged();
|
||||
}
|
||||
|
||||
const QmlProfilerTimelineModel *TimelineModelAggregator::model(int modelIndex) const
|
||||
const TimelineModel *TimelineModelAggregator::model(int modelIndex) const
|
||||
{
|
||||
return d->modelList[modelIndex];
|
||||
}
|
||||
@@ -108,14 +89,14 @@ const QmlProfilerTimelineModel *TimelineModelAggregator::model(int modelIndex) c
|
||||
QVariantList TimelineModelAggregator::models() const
|
||||
{
|
||||
QVariantList ret;
|
||||
foreach (QmlProfilerTimelineModel *model, d->modelList)
|
||||
foreach (TimelineModel *model, d->modelList)
|
||||
ret << QVariant::fromValue(model);
|
||||
return ret;
|
||||
}
|
||||
|
||||
QmlProfilerNotesModel *TimelineModelAggregator::notes() const
|
||||
{
|
||||
return d->modelManager->notesModel();
|
||||
return d->notesModel;
|
||||
}
|
||||
|
||||
int TimelineModelAggregator::modelOffset(int modelIndex) const
|
||||
@@ -139,7 +120,7 @@ QVariantMap TimelineModelAggregator::nextItem(int selectedModel, int selectedIte
|
||||
|
||||
QVarLengthArray<int> itemIndexes(modelCount());
|
||||
for (int i = 0; i < modelCount(); i++) {
|
||||
const QmlProfilerTimelineModel *currentModel = model(i);
|
||||
const TimelineModel *currentModel = model(i);
|
||||
if (currentModel->count() > 0) {
|
||||
if (selectedModel == i) {
|
||||
itemIndexes[i] = (selectedItem + 1) % currentModel->count();
|
||||
@@ -173,7 +154,7 @@ QVariantMap TimelineModelAggregator::nextItem(int selectedModel, int selectedIte
|
||||
itemIndex = -1;
|
||||
candidateStartTime = std::numeric_limits<qint64>::max();
|
||||
for (int i = 0; i < modelCount(); i++) {
|
||||
const QmlProfilerTimelineModel *currentModel = model(i);
|
||||
const TimelineModel *currentModel = model(i);
|
||||
if (currentModel->count() > 0 && currentModel->startTime(0) < candidateStartTime) {
|
||||
candidateModelIndex = i;
|
||||
itemIndex = 0;
|
||||
@@ -208,7 +189,7 @@ QVariantMap TimelineModelAggregator::prevItem(int selectedModel, int selectedIte
|
||||
int candidateModelIndex = -1;
|
||||
qint64 candidateStartTime = std::numeric_limits<qint64>::min();
|
||||
for (int i = 0; i < modelCount(); i++) {
|
||||
const QmlProfilerTimelineModel *currentModel = model(i);
|
||||
const TimelineModel *currentModel = model(i);
|
||||
if (itemIndexes[i] == -1 || itemIndexes[i] >= currentModel->count())
|
||||
continue;
|
||||
qint64 newStartTime = currentModel->startTime(itemIndexes[i]);
|
||||
@@ -224,7 +205,7 @@ QVariantMap TimelineModelAggregator::prevItem(int selectedModel, int selectedIte
|
||||
} else {
|
||||
candidateStartTime = std::numeric_limits<qint64>::min();
|
||||
for (int i = 0; i < modelCount(); i++) {
|
||||
const QmlProfilerTimelineModel *currentModel = model(i);
|
||||
const TimelineModel *currentModel = model(i);
|
||||
if (currentModel->count() > 0 &&
|
||||
currentModel->startTime(currentModel->count() - 1) > candidateStartTime) {
|
||||
candidateModelIndex = i;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "qmlprofilertimelinemodel.h"
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "timelinerenderer.h"
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
@@ -44,13 +45,13 @@ class TimelineModelAggregator : public QObject
|
||||
Q_PROPERTY(QVariantList models READ models NOTIFY modelsChanged)
|
||||
Q_PROPERTY(QmlProfiler::QmlProfilerNotesModel *notes READ notes CONSTANT)
|
||||
public:
|
||||
TimelineModelAggregator(QObject *parent = 0);
|
||||
TimelineModelAggregator(QmlProfilerNotesModel *notes, QObject *parent = 0);
|
||||
~TimelineModelAggregator();
|
||||
|
||||
int height() const;
|
||||
void setModelManager(QmlProfilerModelManager *modelManager);
|
||||
void addModel(QmlProfilerTimelineModel *m);
|
||||
const QmlProfilerTimelineModel *model(int modelIndex) const;
|
||||
|
||||
void addModel(TimelineModel *m);
|
||||
const TimelineModel *model(int modelIndex) const;
|
||||
QVariantList models() const;
|
||||
|
||||
QmlProfilerNotesModel *notes() const;
|
||||
|
||||
Reference in New Issue
Block a user