forked from qt-creator/qt-creator
Timeline: Use the same type for setting and getting a model list
We want to use QVariantList here because that is the only list type we can pass to QML without special registration. Change-Id: Ia57f8f0c578388da7603ddb6d62288e9cf61e381 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -28,6 +28,8 @@
|
|||||||
#include "timelinemodel.h"
|
#include "timelinemodel.h"
|
||||||
#include "timelinenotesmodel.h"
|
#include "timelinenotesmodel.h"
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
@@ -70,10 +72,15 @@ void TimelineModelAggregator::addModel(TimelineModel *m)
|
|||||||
emit heightChanged();
|
emit heightChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineModelAggregator::setModels(const QList<TimelineModel *> &models)
|
void TimelineModelAggregator::setModels(const QVariantList &models)
|
||||||
{
|
{
|
||||||
Q_D(TimelineModelAggregator);
|
Q_D(TimelineModelAggregator);
|
||||||
if (d->modelList == models)
|
|
||||||
|
QList<TimelineModel *> timelineModels = Utils::transform(models, [](const QVariant &model) {
|
||||||
|
return qvariant_cast<TimelineModel *>(model);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (d->modelList == timelineModels)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int prevHeight = height();
|
int prevHeight = height();
|
||||||
@@ -83,8 +90,8 @@ void TimelineModelAggregator::setModels(const QList<TimelineModel *> &models)
|
|||||||
d->notesModel->removeTimelineModel(m);
|
d->notesModel->removeTimelineModel(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->modelList = models;
|
d->modelList = timelineModels;
|
||||||
foreach (TimelineModel *m, models) {
|
foreach (TimelineModel *m, timelineModels) {
|
||||||
connect(m, &TimelineModel::heightChanged, this, &TimelineModelAggregator::heightChanged);
|
connect(m, &TimelineModel::heightChanged, this, &TimelineModelAggregator::heightChanged);
|
||||||
if (d->notesModel)
|
if (d->notesModel)
|
||||||
d->notesModel->addTimelineModel(m);
|
d->notesModel->addTimelineModel(m);
|
||||||
|
@@ -34,7 +34,7 @@ class TIMELINE_EXPORT TimelineModelAggregator : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int height READ height NOTIFY heightChanged)
|
Q_PROPERTY(int height READ height NOTIFY heightChanged)
|
||||||
Q_PROPERTY(QVariantList models READ models NOTIFY modelsChanged)
|
Q_PROPERTY(QVariantList models READ models WRITE setModels NOTIFY modelsChanged)
|
||||||
Q_PROPERTY(Timeline::TimelineNotesModel *notes READ notes CONSTANT)
|
Q_PROPERTY(Timeline::TimelineNotesModel *notes READ notes CONSTANT)
|
||||||
public:
|
public:
|
||||||
TimelineModelAggregator(TimelineNotesModel *notes, QObject *parent = 0);
|
TimelineModelAggregator(TimelineNotesModel *notes, QObject *parent = 0);
|
||||||
@@ -43,9 +43,10 @@ public:
|
|||||||
int height() const;
|
int height() const;
|
||||||
|
|
||||||
void addModel(TimelineModel *m);
|
void addModel(TimelineModel *m);
|
||||||
void setModels(const QList<TimelineModel *> &models);
|
|
||||||
const TimelineModel *model(int modelIndex) const;
|
const TimelineModel *model(int modelIndex) const;
|
||||||
|
|
||||||
QVariantList models() const;
|
QVariantList models() const;
|
||||||
|
void setModels(const QVariantList &models);
|
||||||
|
|
||||||
TimelineNotesModel *notes() const;
|
TimelineNotesModel *notes() const;
|
||||||
void clear();
|
void clear();
|
||||||
|
@@ -130,15 +130,18 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag
|
|||||||
d->m_modelProxy = new Timeline::TimelineModelAggregator(modelManager->notesModel(), this);
|
d->m_modelProxy = new Timeline::TimelineModelAggregator(modelManager->notesModel(), this);
|
||||||
d->m_modelManager = modelManager;
|
d->m_modelManager = modelManager;
|
||||||
|
|
||||||
QList<Timeline::TimelineModel *> models;
|
QVariantList models;
|
||||||
models.append(new PixmapCacheModel(modelManager, d->m_modelProxy));
|
models.append(QVariant::fromValue(new PixmapCacheModel(modelManager, d->m_modelProxy)));
|
||||||
models.append(new SceneGraphTimelineModel(modelManager, d->m_modelProxy));
|
models.append(QVariant::fromValue(new SceneGraphTimelineModel(modelManager, d->m_modelProxy)));
|
||||||
models.append(new MemoryUsageModel(modelManager, d->m_modelProxy));
|
models.append(QVariant::fromValue(new MemoryUsageModel(modelManager, d->m_modelProxy)));
|
||||||
models.append(new InputEventsModel(modelManager, d->m_modelProxy));
|
models.append(QVariant::fromValue(new InputEventsModel(modelManager, d->m_modelProxy)));
|
||||||
models.append(new DebugMessagesModel(modelManager, d->m_modelProxy));
|
models.append(QVariant::fromValue(new DebugMessagesModel(modelManager, d->m_modelProxy)));
|
||||||
models.append(new QmlProfilerAnimationsModel(modelManager, d->m_modelProxy));
|
models.append(QVariant::fromValue(new QmlProfilerAnimationsModel(modelManager,
|
||||||
for (int i = 0; i < MaximumRangeType; ++i)
|
d->m_modelProxy)));
|
||||||
models.append(new QmlProfilerRangeModel(modelManager, (RangeType)i, d->m_modelProxy));
|
for (int i = 0; i < MaximumRangeType; ++i) {
|
||||||
|
models.append(QVariant::fromValue(new QmlProfilerRangeModel(modelManager, (RangeType)i,
|
||||||
|
d->m_modelProxy)));
|
||||||
|
}
|
||||||
d->m_modelProxy->setModels(models);
|
d->m_modelProxy->setModels(models);
|
||||||
|
|
||||||
// Minimum height: 5 rows of 20 pixels + scrollbar of 50 pixels + 20 pixels margin
|
// Minimum height: 5 rows of 20 pixels + scrollbar of 50 pixels + 20 pixels margin
|
||||||
|
Reference in New Issue
Block a user