diff --git a/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp b/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp index 12d5174181abac17a61ae4e5090509783a9d4087..5f1b87f7bb0de3d10fdcee2497ca4fb481a93a37 100644 --- a/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp @@ -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 diff --git a/src/plugins/qmlprofiler/qmlprofilernotesmodel.h b/src/plugins/qmlprofiler/qmlprofilernotesmodel.h index a9bf442268dcb3708169dc3c802f873f72897a5e..9f6f77d89a51b1283b11bc82705af1d1591eb8dd 100644 --- a/src/plugins/qmlprofiler/qmlprofilernotesmodel.h +++ b/src/plugins/qmlprofiler/qmlprofilernotesmodel.h @@ -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); diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp index 6b18f9ae6bc059516ddb972e1b42a9f74de61406..33a85eaaafd479582570a65737e0146015287611 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp @@ -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; diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.h b/src/plugins/qmlprofiler/qmlprofilertraceview.h index 940da86b645814072eb5cbb32cbcc120cc159a8b..8c609ceda50ed61cc2928bc7d20eb10ab5c457ec 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.h +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.h @@ -88,6 +88,7 @@ private: private: class QmlProfilerTraceViewPrivate; QmlProfilerTraceViewPrivate *d; + void setModelManager(QmlProfilerModelManager *modelManager); }; class QmlProfilerQuickView : public QQuickView { diff --git a/src/plugins/qmlprofiler/timelinemodelaggregator.cpp b/src/plugins/qmlprofiler/timelinemodelaggregator.cpp index c224f9aedb837bc1fdf78ddbe47f7c0d8c53d1cd..99b5fd3aed173d68e1c2b1abcd14c09441c91523 100644 --- a/src/plugins/qmlprofiler/timelinemodelaggregator.cpp +++ b/src/plugins/qmlprofiler/timelinemodelaggregator.cpp @@ -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; diff --git a/src/plugins/qmlprofiler/timelinemodelaggregator.h b/src/plugins/qmlprofiler/timelinemodelaggregator.h index b8eee81a2bc8fb6eb84b6a30bec1f356b4cfda34..0be00ed2726aa169c88c9461bfee673b0c37c5fe 100644 --- a/src/plugins/qmlprofiler/timelinemodelaggregator.h +++ b/src/plugins/qmlprofiler/timelinemodelaggregator.h @@ -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;