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;
|
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);
|
this, &QmlProfilerNotesModel::removeTimelineModel);
|
||||||
m_timelineModels.insert(timelineModel->modelId(), timelineModel);
|
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)
|
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);
|
int typeId = model->typeId(timelineIndex);
|
||||||
Note note = { text, timelineModel, timelineIndex };
|
Note note = { text, timelineModel, timelineIndex };
|
||||||
m_data << note;
|
m_data << note;
|
||||||
@@ -160,10 +160,8 @@ int QmlProfilerNotesModel::add(int typeId, qint64 start, qint64 duration, const
|
|||||||
{
|
{
|
||||||
int timelineModel = -1;
|
int timelineModel = -1;
|
||||||
int timelineIndex = -1;
|
int timelineIndex = -1;
|
||||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
|
foreach (const TimelineModel *model, m_timelineModels) {
|
||||||
m_modelManager->qmlModel()->getEventTypes();
|
if (model->handlesTypeId(typeId)) {
|
||||||
foreach (const QmlProfilerTimelineModel *model, m_timelineModels) {
|
|
||||||
if (model->accepted(types[typeId])) {
|
|
||||||
for (int i = model->firstIndex(start); i <= model->lastIndex(start + duration); ++i) {
|
for (int i = model->firstIndex(start); i <= model->lastIndex(start + duration); ++i) {
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
continue;
|
continue;
|
||||||
@@ -237,7 +235,7 @@ void QmlProfilerNotesModel::saveData()
|
|||||||
if (it == m_timelineModels.end())
|
if (it == m_timelineModels.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const QmlProfilerTimelineModel *model = it.value();
|
const TimelineModel *model = it.value();
|
||||||
QmlProfilerDataModel::QmlEventNoteData save = {
|
QmlProfilerDataModel::QmlEventNoteData save = {
|
||||||
model->typeId(note.timelineIndex), model->startTime(note.timelineIndex),
|
model->typeId(note.timelineIndex), model->startTime(note.timelineIndex),
|
||||||
model->duration(note.timelineIndex), note.text
|
model->duration(note.timelineIndex), note.text
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
int count() const;
|
int count() const;
|
||||||
|
|
||||||
void setModelManager(QmlProfilerModelManager *modelManager);
|
void setModelManager(QmlProfilerModelManager *modelManager);
|
||||||
void addTimelineModel(const QmlProfilerTimelineModel *timelineModel);
|
void addTimelineModel(const TimelineModel *timelineModel);
|
||||||
|
|
||||||
Q_INVOKABLE int typeId(int index) const;
|
Q_INVOKABLE int typeId(int index) const;
|
||||||
Q_INVOKABLE QString text(int index) const;
|
Q_INVOKABLE QString text(int index) const;
|
||||||
@@ -86,7 +86,7 @@ private slots:
|
|||||||
protected:
|
protected:
|
||||||
QmlProfilerModelManager *m_modelManager;
|
QmlProfilerModelManager *m_modelManager;
|
||||||
QList<Note> m_data;
|
QList<Note> m_data;
|
||||||
QHash<int, const QmlProfilerTimelineModel *> m_timelineModels;
|
QHash<int, const TimelineModel *> m_timelineModels;
|
||||||
bool m_modified;
|
bool m_modified;
|
||||||
|
|
||||||
int add(int typeId, qint64 startTime, qint64 duration, const QString &text);
|
int add(int typeId, qint64 startTime, qint64 duration, const QString &text);
|
||||||
|
|||||||
@@ -34,6 +34,9 @@
|
|||||||
#include "qmlprofilermodelmanager.h"
|
#include "qmlprofilermodelmanager.h"
|
||||||
#include "timelinemodelaggregator.h"
|
#include "timelinemodelaggregator.h"
|
||||||
#include "qmlprofilernotesmodel.h"
|
#include "qmlprofilernotesmodel.h"
|
||||||
|
#include "qmlprofileranimationsmodel.h"
|
||||||
|
#include "qmlprofilerrangemodel.h"
|
||||||
|
#include "qmlprofilerplugin.h"
|
||||||
|
|
||||||
// Needed for the load&save actions in the context menu
|
// Needed for the load&save actions in the context menu
|
||||||
#include <analyzerbase/ianalyzertool.h>
|
#include <analyzerbase/ianalyzertool.h>
|
||||||
@@ -117,11 +120,9 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
|
|||||||
|
|
||||||
d->m_profilerTool = profilerTool;
|
d->m_profilerTool = profilerTool;
|
||||||
d->m_viewContainer = container;
|
d->m_viewContainer = container;
|
||||||
d->m_modelManager = modelManager;
|
|
||||||
d->m_modelProxy = new TimelineModelAggregator(this);
|
d->m_modelProxy = new TimelineModelAggregator(modelManager->notesModel(), this);
|
||||||
d->m_modelProxy->setModelManager(modelManager);
|
setModelManager(modelManager);
|
||||||
connect(d->m_modelManager, SIGNAL(stateChanged()),
|
|
||||||
this, SLOT(profilerDataModelStateChanged()));
|
|
||||||
d->m_mainView->rootContext()->setContextProperty(QLatin1String("qmlProfilerModelProxy"),
|
d->m_mainView->rootContext()->setContextProperty(QLatin1String("qmlProfilerModelProxy"),
|
||||||
d->m_modelProxy);
|
d->m_modelProxy);
|
||||||
d->m_profilerState = profilerState;
|
d->m_profilerState = profilerState;
|
||||||
@@ -130,6 +131,33 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
|
|||||||
setMinimumHeight(170);
|
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()
|
QmlProfilerTraceView::~QmlProfilerTraceView()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
class QmlProfilerTraceViewPrivate;
|
class QmlProfilerTraceViewPrivate;
|
||||||
QmlProfilerTraceViewPrivate *d;
|
QmlProfilerTraceViewPrivate *d;
|
||||||
|
void setModelManager(QmlProfilerModelManager *modelManager);
|
||||||
};
|
};
|
||||||
|
|
||||||
class QmlProfilerQuickView : public QQuickView {
|
class QmlProfilerQuickView : public QQuickView {
|
||||||
|
|||||||
@@ -49,15 +49,18 @@ public:
|
|||||||
|
|
||||||
TimelineModelAggregator *q;
|
TimelineModelAggregator *q;
|
||||||
|
|
||||||
QList <QmlProfilerTimelineModel *> modelList;
|
QList <TimelineModel *> modelList;
|
||||||
QmlProfilerModelManager *modelManager;
|
QmlProfilerNotesModel *notesModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
TimelineModelAggregator::TimelineModelAggregator(QObject *parent)
|
TimelineModelAggregator::TimelineModelAggregator(QmlProfilerNotesModel *notes, QObject *parent)
|
||||||
: QObject(parent), d(new TimelineModelAggregatorPrivate(this))
|
: QObject(parent), d(new TimelineModelAggregatorPrivate(this))
|
||||||
{
|
{
|
||||||
|
d->notesModel = notes;
|
||||||
connect(this,SIGNAL(modelsChanged()),this,SIGNAL(heightChanged()));
|
connect(this,SIGNAL(modelsChanged()),this,SIGNAL(heightChanged()));
|
||||||
connect(this,SIGNAL(stateChanged()),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()
|
TimelineModelAggregator::~TimelineModelAggregator()
|
||||||
@@ -70,37 +73,15 @@ int TimelineModelAggregator::height() const
|
|||||||
return modelOffset(d->modelList.length());
|
return modelOffset(d->modelList.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineModelAggregator::setModelManager(QmlProfilerModelManager *modelManager)
|
void TimelineModelAggregator::addModel(TimelineModel *m)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
d->modelList << m;
|
d->modelList << m;
|
||||||
connect(m,SIGNAL(heightChanged()),this,SIGNAL(heightChanged()));
|
connect(m,SIGNAL(heightChanged()),this,SIGNAL(heightChanged()));
|
||||||
d->modelManager->notesModel()->addTimelineModel(m);
|
d->notesModel->addTimelineModel(m);
|
||||||
emit modelsChanged();
|
emit modelsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QmlProfilerTimelineModel *TimelineModelAggregator::model(int modelIndex) const
|
const TimelineModel *TimelineModelAggregator::model(int modelIndex) const
|
||||||
{
|
{
|
||||||
return d->modelList[modelIndex];
|
return d->modelList[modelIndex];
|
||||||
}
|
}
|
||||||
@@ -108,14 +89,14 @@ const QmlProfilerTimelineModel *TimelineModelAggregator::model(int modelIndex) c
|
|||||||
QVariantList TimelineModelAggregator::models() const
|
QVariantList TimelineModelAggregator::models() const
|
||||||
{
|
{
|
||||||
QVariantList ret;
|
QVariantList ret;
|
||||||
foreach (QmlProfilerTimelineModel *model, d->modelList)
|
foreach (TimelineModel *model, d->modelList)
|
||||||
ret << QVariant::fromValue(model);
|
ret << QVariant::fromValue(model);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerNotesModel *TimelineModelAggregator::notes() const
|
QmlProfilerNotesModel *TimelineModelAggregator::notes() const
|
||||||
{
|
{
|
||||||
return d->modelManager->notesModel();
|
return d->notesModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TimelineModelAggregator::modelOffset(int modelIndex) const
|
int TimelineModelAggregator::modelOffset(int modelIndex) const
|
||||||
@@ -139,7 +120,7 @@ QVariantMap TimelineModelAggregator::nextItem(int selectedModel, int selectedIte
|
|||||||
|
|
||||||
QVarLengthArray<int> itemIndexes(modelCount());
|
QVarLengthArray<int> itemIndexes(modelCount());
|
||||||
for (int i = 0; i < modelCount(); i++) {
|
for (int i = 0; i < modelCount(); i++) {
|
||||||
const QmlProfilerTimelineModel *currentModel = model(i);
|
const TimelineModel *currentModel = model(i);
|
||||||
if (currentModel->count() > 0) {
|
if (currentModel->count() > 0) {
|
||||||
if (selectedModel == i) {
|
if (selectedModel == i) {
|
||||||
itemIndexes[i] = (selectedItem + 1) % currentModel->count();
|
itemIndexes[i] = (selectedItem + 1) % currentModel->count();
|
||||||
@@ -173,7 +154,7 @@ QVariantMap TimelineModelAggregator::nextItem(int selectedModel, int selectedIte
|
|||||||
itemIndex = -1;
|
itemIndex = -1;
|
||||||
candidateStartTime = std::numeric_limits<qint64>::max();
|
candidateStartTime = std::numeric_limits<qint64>::max();
|
||||||
for (int i = 0; i < modelCount(); i++) {
|
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) {
|
if (currentModel->count() > 0 && currentModel->startTime(0) < candidateStartTime) {
|
||||||
candidateModelIndex = i;
|
candidateModelIndex = i;
|
||||||
itemIndex = 0;
|
itemIndex = 0;
|
||||||
@@ -208,7 +189,7 @@ QVariantMap TimelineModelAggregator::prevItem(int selectedModel, int selectedIte
|
|||||||
int candidateModelIndex = -1;
|
int candidateModelIndex = -1;
|
||||||
qint64 candidateStartTime = std::numeric_limits<qint64>::min();
|
qint64 candidateStartTime = std::numeric_limits<qint64>::min();
|
||||||
for (int i = 0; i < modelCount(); i++) {
|
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())
|
if (itemIndexes[i] == -1 || itemIndexes[i] >= currentModel->count())
|
||||||
continue;
|
continue;
|
||||||
qint64 newStartTime = currentModel->startTime(itemIndexes[i]);
|
qint64 newStartTime = currentModel->startTime(itemIndexes[i]);
|
||||||
@@ -224,7 +205,7 @@ QVariantMap TimelineModelAggregator::prevItem(int selectedModel, int selectedIte
|
|||||||
} else {
|
} else {
|
||||||
candidateStartTime = std::numeric_limits<qint64>::min();
|
candidateStartTime = std::numeric_limits<qint64>::min();
|
||||||
for (int i = 0; i < modelCount(); i++) {
|
for (int i = 0; i < modelCount(); i++) {
|
||||||
const QmlProfilerTimelineModel *currentModel = model(i);
|
const TimelineModel *currentModel = model(i);
|
||||||
if (currentModel->count() > 0 &&
|
if (currentModel->count() > 0 &&
|
||||||
currentModel->startTime(currentModel->count() - 1) > candidateStartTime) {
|
currentModel->startTime(currentModel->count() - 1) > candidateStartTime) {
|
||||||
candidateModelIndex = i;
|
candidateModelIndex = i;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include "qmlprofilertimelinemodel.h"
|
#include "qmlprofilertimelinemodel.h"
|
||||||
#include "qmlprofilermodelmanager.h"
|
#include "qmlprofilermodelmanager.h"
|
||||||
|
#include "timelinerenderer.h"
|
||||||
|
|
||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -44,13 +45,13 @@ class TimelineModelAggregator : public QObject
|
|||||||
Q_PROPERTY(QVariantList models READ models NOTIFY modelsChanged)
|
Q_PROPERTY(QVariantList models READ models NOTIFY modelsChanged)
|
||||||
Q_PROPERTY(QmlProfiler::QmlProfilerNotesModel *notes READ notes CONSTANT)
|
Q_PROPERTY(QmlProfiler::QmlProfilerNotesModel *notes READ notes CONSTANT)
|
||||||
public:
|
public:
|
||||||
TimelineModelAggregator(QObject *parent = 0);
|
TimelineModelAggregator(QmlProfilerNotesModel *notes, QObject *parent = 0);
|
||||||
~TimelineModelAggregator();
|
~TimelineModelAggregator();
|
||||||
|
|
||||||
int height() const;
|
int height() const;
|
||||||
void setModelManager(QmlProfilerModelManager *modelManager);
|
|
||||||
void addModel(QmlProfilerTimelineModel *m);
|
void addModel(TimelineModel *m);
|
||||||
const QmlProfilerTimelineModel *model(int modelIndex) const;
|
const TimelineModel *model(int modelIndex) const;
|
||||||
QVariantList models() const;
|
QVariantList models() const;
|
||||||
|
|
||||||
QmlProfilerNotesModel *notes() const;
|
QmlProfilerNotesModel *notes() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user