QmlProfiler: Remove references to QmlProfilerDataModel

We keep it private to QmlProfilerModelManager and proxy the last few
methods that were directly called on the model. This enables us to
remove the QmlProfilerDataModel class by integrating what is left of it
into QmlProfilerModelManagerPrivate in a next step.

Change-Id: Ie9b4e03fb286e5a0040374d00b7b26f810426278
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Ulf Hermann
2016-12-29 14:26:29 +01:00
parent 2b75df2139
commit 78daf47a25
24 changed files with 62 additions and 54 deletions

View File

@@ -76,7 +76,7 @@ QVariantList DebugMessagesModel::labels() const
QVariantMap DebugMessagesModel::details(int index) const
{
const QmlProfilerModelManager *manager = modelManager();
const QmlEventType &type = manager->qmlModel()->eventTypes()[m_data[index].typeId];
const QmlEventType &type = manager->eventTypes()[m_data[index].typeId];
QVariantMap result;
result.insert(QLatin1String("displayName"), messageType(type.detailType()));

View File

@@ -26,7 +26,6 @@
#include "flamegraphmodel.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilerdatamodel.h"
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
@@ -186,7 +185,7 @@ QVariant FlameGraphModel::lookup(const FlameGraphData &stats, int role) const
}
if (stats.typeIndex != -1) {
const QVector<QmlEventType> &typeList = m_modelManager->qmlModel()->eventTypes();
const QVector<QmlEventType> &typeList = m_modelManager->eventTypes();
const QmlEventType &type = typeList[stats.typeIndex];
switch (role) {

View File

@@ -25,7 +25,6 @@
#pragma once
#include "qmlprofilerdatamodel.h"
#include "qmlprofilernotesmodel.h"
#include "qmlprofilereventtypes.h"
#include "qmleventlocation.h"

View File

@@ -121,8 +121,7 @@ QVariantMap MemoryUsageModel::details(int index) const
}
result.insert(tr("Type"), memoryTypeName);
result.insert(tr("Location"),
modelManager()->qmlModel()->eventTypes().at(ev->typeId).displayName());
result.insert(tr("Location"), modelManager()->eventTypes().at(ev->typeId).displayName());
return result;
}

View File

@@ -26,7 +26,6 @@
#pragma once
#include "qmlprofilertimelinemodel.h"
#include "qmlprofilerdatamodel.h"
#include <QStringList>
#include <QColor>

View File

@@ -26,7 +26,6 @@
#pragma once
#include "qmlprofilertimelinemodel.h"
#include "qmlprofilerdatamodel.h"
#include <QStringList>
#include <QColor>

View File

@@ -25,7 +25,6 @@
#include "qmlprofileranimationsmodel.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilerdatamodel.h"
#include <utils/qtcassert.h>
#include <timeline/timelineformattime.h>

View File

@@ -28,7 +28,6 @@
#include "qmlprofilertimelinemodel.h"
#include "qmlprofilereventtypes.h"
#include "qmleventlocation.h"
#include "qmlprofilerdatamodel.h"
#include <QVariantList>
#include <QColor>

View File

@@ -57,7 +57,7 @@ public:
QString getDisplayName(const QmlEventType &event)
{
if (event.location().filename().isEmpty()) {
return QmlProfilerDataModel::tr("<bytecode>");
return QmlProfilerModelManager::tr("<bytecode>");
} else {
const QString filePath = QUrl(event.location().filename()).path();
return filePath.mid(filePath.lastIndexOf(QLatin1Char('/')) + 1) + QLatin1Char(':') +

View File

@@ -192,11 +192,6 @@ QmlProfilerTraceTime *QmlProfilerModelManager::traceTime() const
return d->traceTime;
}
QmlProfilerDataModel *QmlProfilerModelManager::qmlModel() const
{
return d->model;
}
QmlProfilerNotesModel *QmlProfilerModelManager::notesModel() const
{
return d->notesModel;
@@ -278,6 +273,17 @@ void QmlProfilerModelManager::addEventType(const QmlEventType &type)
}
}
const QVector<QmlEventType> &QmlProfilerModelManager::eventTypes() const
{
return d->model->eventTypes();
}
bool QmlProfilerModelManager::replayEvents(qint64 startTime, qint64 endTime,
EventLoader loader) const
{
return d->model->replayEvents(startTime, endTime, loader);
}
void QmlProfilerModelManager::QmlProfilerModelManagerPrivate::dispatch(const QmlEvent &event,
const QmlEventType &type)
{
@@ -375,6 +381,16 @@ void QmlProfilerModelManager::processingDone()
setState(Done);
}
void QmlProfilerModelManager::populateFileFinder(const ProjectExplorer::RunConfiguration *runConfiguration)
{
d->model->populateFileFinder(runConfiguration);
}
QString QmlProfilerModelManager::findLocalFile(const QString &remoteFile)
{
return d->model->findLocalFile(remoteFile);
}
void QmlProfilerModelManager::save(const QString &filename)
{
QFile *file = new QFile(filename);
@@ -390,7 +406,7 @@ void QmlProfilerModelManager::save(const QString &filename)
QmlProfilerFileWriter *writer = new QmlProfilerFileWriter(this);
writer->setTraceTime(traceTime()->startTime(), traceTime()->endTime(),
traceTime()->duration());
writer->setData(d->model);
writer->setData(this);
writer->setNotes(d->notesModel->notes());
connect(writer, &QObject::destroyed, this, &QmlProfilerModelManager::saveFinished,

View File

@@ -39,7 +39,6 @@
namespace QmlProfiler {
class QmlProfilerModelManager;
class QmlProfilerDataModel;
class QmlProfilerNotesModel;
namespace Internal {
@@ -96,7 +95,6 @@ public:
State state() const;
QmlProfilerTraceTime *traceTime() const;
QmlProfilerDataModel *qmlModel() const;
QmlProfilerNotesModel *notesModel() const;
QmlProfilerTextMarkModel *textMarkModel() const;
@@ -115,6 +113,9 @@ public:
void addEventTypes(const QVector<QmlEventType> &types);
void addEventType(const QmlEventType &type);
const QVector<QmlEventType> &eventTypes() const;
bool replayEvents(qint64 startTime, qint64 endTime, EventLoader loader) const;
quint64 availableFeatures() const;
quint64 visibleFeatures() const;
@@ -127,6 +128,9 @@ public:
void acquiringDone();
void processingDone();
void populateFileFinder(const ProjectExplorer::RunConfiguration *runConfiguration = nullptr);
QString findLocalFile(const QString &remoteFile);
static const char *featureName(ProfileFeature feature);
signals:

View File

@@ -24,7 +24,6 @@
****************************************************************************/
#include "qmlprofilernotesmodel.h"
#include "qmlprofilerdatamodel.h"
#include <utils/algorithm.h>

View File

@@ -25,7 +25,6 @@
#include "qmlprofilerrangemodel.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilerdatamodel.h"
#include "qmlprofilerbindingloopsrenderpass.h"
#include "timeline/timelinenotesrenderpass.h"
@@ -203,7 +202,7 @@ QVariantList QmlProfilerRangeModel::labels() const
{
QVariantList result;
const QVector<QmlEventType> &types = modelManager()->qmlModel()->eventTypes();
const QVector<QmlEventType> &types = modelManager()->eventTypes();
for (int i = 1; i < expandedRowCount(); i++) { // Ignore the -1 for the first row
QVariantMap element;
int typeId = m_expandedRowTypes[i];
@@ -220,7 +219,7 @@ QVariantMap QmlProfilerRangeModel::details(int index) const
{
QVariantMap result;
int id = selectionId(index);
const QVector<QmlEventType> &types = modelManager()->qmlModel()->eventTypes();
const QVector<QmlEventType> &types = modelManager()->eventTypes();
result.insert(QStringLiteral("displayName"),
tr(QmlProfilerModelManager::featureName(mainFeature())));

View File

@@ -26,7 +26,6 @@
#pragma once
#include "qmlprofilertimelinemodel.h"
#include "qmlprofilerdatamodel.h"
#include "qmlprofilereventtypes.h"
#include "qmleventlocation.h"
#include "qmlprofilerconstants.h"

View File

@@ -25,7 +25,6 @@
#include "qmlprofilerstatisticsmodel.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilerdatamodel.h"
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
@@ -120,7 +119,7 @@ void QmlProfilerStatisticsModel::restrictToFeatures(qint64 features)
return;
clear();
if (!d->modelManager->qmlModel()->replayEvents(d->modelManager->traceTime()->startTime(),
if (!d->modelManager->replayEvents(d->modelManager->traceTime()->startTime(),
d->modelManager->traceTime()->endTime(),
std::bind(&QmlProfilerStatisticsModel::loadEvent,
this, std::placeholders::_1,
@@ -140,7 +139,7 @@ const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &QmlProfilerStatisti
const QVector<QmlEventType> &QmlProfilerStatisticsModel::getTypes() const
{
return d->modelManager->qmlModel()->eventTypes();
return d->modelManager->eventTypes();
}
const QHash<int, QString> &QmlProfilerStatisticsModel::getNotes() const
@@ -322,7 +321,7 @@ QmlProfilerStatisticsRelativesModel::getData(int typeId) const
const QVector<QmlEventType> &QmlProfilerStatisticsRelativesModel::getTypes() const
{
return m_modelManager->qmlModel()->eventTypes();
return m_modelManager->eventTypes();
}
void QmlProfilerStatisticsRelativesModel::loadEvent(RangeType type, const QmlEvent &event,

View File

@@ -25,7 +25,6 @@
#pragma once
#include "qmlprofilerdatamodel.h"
#include "qmlprofilernotesmodel.h"
#include "qmlprofilereventtypes.h"
#include "qmleventlocation.h"

View File

@@ -67,7 +67,7 @@ bool QmlProfilerTimelineModel::handlesTypeId(int typeIndex) const
if (typeIndex < 0)
return false;
return accepted(modelManager()->qmlModel()->eventTypes().at(typeIndex));
return accepted(modelManager()->eventTypes().at(typeIndex));
}
QmlProfilerModelManager *QmlProfilerTimelineModel::modelManager() const
@@ -112,7 +112,7 @@ QVariantMap QmlProfilerTimelineModel::locationFromTypeId(int index) const
if (id < 0)
return result;
auto types = modelManager()->qmlModel()->eventTypes();
auto types = modelManager()->eventTypes();
if (id >= types.length())
return result;

View File

@@ -27,7 +27,6 @@
#include "qmlprofiler_global.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilerdatamodel.h"
#include "timeline/timelinemodel.h"
namespace QmlProfiler {

View File

@@ -242,7 +242,7 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
// When the widgets are requested we assume that the session data
// is available, then we can populate the file finder
d->m_profilerModelManager->qmlModel()->populateFileFinder();
d->m_profilerModelManager->populateFileFinder();
auto runControlCreator = [this](RunConfiguration *runConfiguration, Core::Id) {
return createRunControl(runConfiguration);
@@ -368,7 +368,7 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunControl *runControl)
RunConfiguration *runConfiguration = runControl->runConfiguration();
if (runConfiguration) {
d->m_profilerModelManager->qmlModel()->populateFileFinder(runConfiguration);
d->m_profilerModelManager->populateFileFinder(runConfiguration);
}
if (connection.analyzerSocket.isEmpty()) {
@@ -460,7 +460,7 @@ void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber,
if (lineNumber < 0 || fileUrl.isEmpty())
return;
const QString projectFileName = d->m_profilerModelManager->qmlModel()->findLocalFile(fileUrl);
const QString projectFileName = d->m_profilerModelManager->findLocalFile(fileUrl);
QFileInfo fileInfo(projectFileName);
if (!fileInfo.exists() || !fileInfo.isReadable())
@@ -688,7 +688,7 @@ void QmlProfilerTool::showLoadDialog()
Debugger::enableMainWindow(false);
connect(d->m_profilerModelManager, &QmlProfilerModelManager::recordedFeaturesChanged,
this, &QmlProfilerTool::setRecordedFeatures);
d->m_profilerModelManager->qmlModel()->populateFileFinder();
d->m_profilerModelManager->populateFileFinder();
d->m_profilerModelManager->load(filename);
}
}

View File

@@ -25,7 +25,7 @@
#include "qmlprofilertraceclient.h"
#include "qmltypedevent.h"
#include "qmlprofilerdatamodel.h"
#include "qmlprofilermodelmanager.h"
#include <qmldebug/qmlenginecontrolclient.h>
#include <qmldebug/qdebugmessageclient.h>

View File

@@ -576,9 +576,9 @@ void QmlProfilerFileWriter::setTraceTime(qint64 startTime, qint64 endTime, qint6
m_measuredTime = measuredTime;
}
void QmlProfilerFileWriter::setData(const QmlProfilerDataModel *model)
void QmlProfilerFileWriter::setData(const QmlProfilerModelManager *model)
{
m_model = model;
m_modelManager = model;
}
void QmlProfilerFileWriter::setNotes(const QVector<QmlNote> &notes)
@@ -610,7 +610,7 @@ void QmlProfilerFileWriter::saveQtd(QIODevice *device)
stream.writeStartElement(_("eventData"));
stream.writeAttribute(_("totalTime"), QString::number(m_measuredTime));
const QVector<QmlEventType> &eventTypes = m_model->eventTypes();
const QVector<QmlEventType> &eventTypes = m_modelManager->eventTypes();
for (int typeIndex = 0, end = eventTypes.length(); typeIndex < end && !isCanceled();
++typeIndex) {
@@ -664,7 +664,7 @@ void QmlProfilerFileWriter::saveQtd(QIODevice *device)
stream.writeStartElement(_("profilerDataModel"));
QStack<QmlEvent> stack;
const bool success = m_model->replayEvents(
const bool success = m_modelManager->replayEvents(
-1, -1, [this, &stack, &stream](const QmlEvent &event,
const QmlEventType &type) {
if (isCanceled())
@@ -790,7 +790,7 @@ void QmlProfilerFileWriter::saveQzt(QFile *file)
buffer.open(QIODevice::WriteOnly);
if (!isCanceled()) {
bufferStream << m_model->eventTypes();
bufferStream << m_modelManager->eventTypes();
stream << qCompress(buffer.data());
buffer.close();
buffer.buffer().clear();
@@ -808,7 +808,7 @@ void QmlProfilerFileWriter::saveQzt(QFile *file)
if (!isCanceled()) {
buffer.open(QIODevice::WriteOnly);
const bool success = m_model->replayEvents(
const bool success = m_modelManager->replayEvents(
-1, -1, [this, &stream, &buffer, &bufferStream](const QmlEvent &event,
const QmlEventType &type) {
Q_UNUSED(type);

View File

@@ -27,8 +27,10 @@
#include "qmleventlocation.h"
#include "qmlprofilereventtypes.h"
#include "qmlprofilerdatamodel.h"
#include "qmlnote.h"
#include "qmleventtype.h"
#include "qmlevent.h"
#include "qmlprofilermodelmanager.h"
#include <QFutureInterface>
#include <QObject>
@@ -90,7 +92,7 @@ public:
explicit QmlProfilerFileWriter(QObject *parent = 0);
void setTraceTime(qint64 startTime, qint64 endTime, qint64 measturedTime);
void setData(const QmlProfilerDataModel *model);
void setData(const QmlProfilerModelManager *model);
void setNotes(const QVector<QmlNote> &notes);
void setFuture(QFutureInterface<void> *future);
@@ -115,7 +117,7 @@ private:
qint64 m_startTime, m_endTime, m_measuredTime;
QFutureInterface<void> *m_future;
const QmlProfilerDataModel *m_model;
const QmlProfilerModelManager *m_modelManager;
QVector<QmlNote> m_notes;
};

View File

@@ -27,7 +27,6 @@
#include "qmlprofilertimelinemodel.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilerdatamodel.h"
#include <QStringList>
#include <QColor>

View File

@@ -154,7 +154,7 @@ void MemoryUsageModelTest::testDetails()
QCOMPARE(allocated[model.tr("Allocated")].toString(), model.tr("%1 bytes").arg(4096));
QCOMPARE(allocated[model.tr("Allocations")].toString(), QString::number(2));
QCOMPARE(allocated[model.tr("Type")].toString(), model.tr("Heap Allocation"));
QCOMPARE(allocated[model.tr("Location")].toString(), QmlProfilerDataModel::tr("<bytecode>"));
QCOMPARE(allocated[model.tr("Location")].toString(), QmlProfilerModelManager::tr("<bytecode>"));
QVERIFY(!allocated.contains(model.tr("Deallocated")));
QVERIFY(!allocated.contains(model.tr("Deallocations")));
@@ -165,7 +165,7 @@ void MemoryUsageModelTest::testDetails()
QCOMPARE(large[model.tr("Allocated")].toString(), model.tr("%1 bytes").arg(1024));
QCOMPARE(large[model.tr("Allocations")].toString(), QString::number(1));
QCOMPARE(large[model.tr("Type")].toString(), model.tr("Large Item Allocation"));
QCOMPARE(large[model.tr("Location")].toString(), QmlProfilerDataModel::tr("<bytecode>"));
QCOMPARE(large[model.tr("Location")].toString(), QmlProfilerModelManager::tr("<bytecode>"));
QVERIFY(!large.contains(model.tr("Deallocated")));
QVERIFY(!large.contains(model.tr("Deallocations")));
@@ -176,7 +176,7 @@ void MemoryUsageModelTest::testDetails()
QCOMPARE(freed[model.tr("Deallocated")].toString(), model.tr("%1 bytes").arg(1024));
QCOMPARE(freed[model.tr("Deallocations")].toString(), QString::number(1));
QCOMPARE(freed[model.tr("Type")].toString(), model.tr("Heap Usage"));
QCOMPARE(freed[model.tr("Location")].toString(), QmlProfilerDataModel::tr("<bytecode>"));
QCOMPARE(freed[model.tr("Location")].toString(), QmlProfilerModelManager::tr("<bytecode>"));
QVERIFY(!freed.contains(model.tr("Allocated")));
QVERIFY(!freed.contains(model.tr("Allocations")));