forked from qt-creator/qt-creator
QmlProfiler: Rename QmlProfilerEventsModelProxy
It is only used for the statistics view. Change-Id: I71027dd864715b4a2f95c2b11af0c0d83c514229 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
@@ -13,7 +13,6 @@ SOURCES += \
|
||||
qmlprofilerconfigwidget.cpp \
|
||||
qmlprofilerdatamodel.cpp \
|
||||
qmlprofilerdetailsrewriter.cpp \
|
||||
qmlprofilereventsmodelproxy.cpp \
|
||||
qmlprofilermodelmanager.cpp \
|
||||
qmlprofilernotesmodel.cpp \
|
||||
qmlprofileroptionspage.cpp \
|
||||
@@ -25,6 +24,7 @@ SOURCES += \
|
||||
qmlprofilersettings.cpp \
|
||||
qmlprofilerstatemanager.cpp \
|
||||
qmlprofilerstatewidget.cpp \
|
||||
qmlprofilerstatisticsmodel.cpp \
|
||||
qmlprofilerstatisticsview.cpp \
|
||||
qmlprofilertimelinemodel.cpp \
|
||||
qmlprofilertimelinemodelfactory.cpp \
|
||||
@@ -44,7 +44,6 @@ HEADERS += \
|
||||
qmlprofilerconstants.h \
|
||||
qmlprofilerdatamodel.h \
|
||||
qmlprofilerdetailsrewriter.h \
|
||||
qmlprofilereventsmodelproxy.h \
|
||||
qmlprofilereventsview.h \
|
||||
qmlprofilermodelmanager.h \
|
||||
qmlprofilernotesmodel.h \
|
||||
@@ -57,6 +56,7 @@ HEADERS += \
|
||||
qmlprofilersettings.h \
|
||||
qmlprofilerstatemanager.h \
|
||||
qmlprofilerstatewidget.h \
|
||||
qmlprofilerstatisticsmodel.h \
|
||||
qmlprofilerstatisticsview.h \
|
||||
qmlprofilertimelinemodel.h \
|
||||
qmlprofilertimelinemodelfactory.h \
|
||||
|
||||
@@ -29,7 +29,6 @@ QtcPlugin {
|
||||
"qmlprofilerconfigwidget.ui", "qmlprofilerconstants.h",
|
||||
"qmlprofilerdatamodel.cpp", "qmlprofilerdatamodel.h",
|
||||
"qmlprofilerdetailsrewriter.cpp", "qmlprofilerdetailsrewriter.h",
|
||||
"qmlprofilereventsmodelproxy.cpp", "qmlprofilereventsmodelproxy.h",
|
||||
"qmlprofilereventsview.h",
|
||||
"qmlprofilermodelmanager.cpp", "qmlprofilermodelmanager.h",
|
||||
"qmlprofilernotesmodel.cpp", "qmlprofilernotesmodel.h",
|
||||
@@ -42,6 +41,7 @@ QtcPlugin {
|
||||
"qmlprofilersettings.cpp", "qmlprofilersettings.h",
|
||||
"qmlprofilerstatemanager.cpp", "qmlprofilerstatemanager.h",
|
||||
"qmlprofilerstatewidget.cpp", "qmlprofilerstatewidget.h",
|
||||
"qmlprofilerstatisticsmodel.cpp", "qmlprofilerstatisticsmodel.h",
|
||||
"qmlprofilerstatisticsview.cpp", "qmlprofilerstatisticsview.h",
|
||||
"qmlprofilertimelinemodel.cpp", "qmlprofilertimelinemodel.h",
|
||||
"qmlprofilertimelinemodelfactory.cpp", "qmlprofilertimelinemodelfactory.h",
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmlprofilereventsmodelproxy.h"
|
||||
#include "qmlprofilerstatisticsmodel.h"
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmlprofilerdatamodel.h"
|
||||
|
||||
@@ -45,18 +45,17 @@
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
class QmlProfilerEventsModelProxy::QmlProfilerEventsModelProxyPrivate
|
||||
class QmlProfilerStatisticsModel::QmlProfilerStatisticsModelPrivate
|
||||
{
|
||||
public:
|
||||
QmlProfilerEventsModelProxyPrivate(QmlProfilerEventsModelProxy *qq) : q(qq) {}
|
||||
~QmlProfilerEventsModelProxyPrivate() {}
|
||||
QmlProfilerStatisticsModelPrivate(QmlProfilerStatisticsModel *qq) : q(qq) {}
|
||||
~QmlProfilerStatisticsModelPrivate() {}
|
||||
|
||||
QHash<int, QmlProfilerEventsModelProxy::QmlEventStats> data;
|
||||
QHash<int, QmlProfilerStatisticsModel::QmlEventStats> data;
|
||||
|
||||
QmlProfilerModelManager *modelManager;
|
||||
QmlProfilerEventsModelProxy *q;
|
||||
QmlProfilerStatisticsModel *q;
|
||||
|
||||
int modelId;
|
||||
|
||||
@@ -65,14 +64,15 @@ public:
|
||||
QHash<int, QString> notes;
|
||||
};
|
||||
|
||||
QmlProfilerEventsModelProxy::QmlProfilerEventsModelProxy(QmlProfilerModelManager *modelManager, QObject *parent)
|
||||
: QObject(parent), d(new QmlProfilerEventsModelProxyPrivate(this))
|
||||
QmlProfilerStatisticsModel::QmlProfilerStatisticsModel(QmlProfilerModelManager *modelManager,
|
||||
QObject *parent) :
|
||||
QObject(parent), d(new QmlProfilerStatisticsModelPrivate(this))
|
||||
{
|
||||
d->modelManager = modelManager;
|
||||
connect(modelManager->qmlModel(), &QmlProfilerDataModel::changed,
|
||||
this, &QmlProfilerEventsModelProxy::dataChanged);
|
||||
this, &QmlProfilerStatisticsModel::dataChanged);
|
||||
connect(modelManager->notesModel(), &Timeline::TimelineNotesModel::changed,
|
||||
this, &QmlProfilerEventsModelProxy::notesChanged);
|
||||
this, &QmlProfilerStatisticsModel::notesChanged);
|
||||
d->modelId = modelManager->registerModelProxy();
|
||||
|
||||
// We're iterating twice in loadData.
|
||||
@@ -83,12 +83,12 @@ QmlProfilerEventsModelProxy::QmlProfilerEventsModelProxy(QmlProfilerModelManager
|
||||
modelManager->announceFeatures(d->modelId, QmlDebug::Constants::QML_JS_RANGE_FEATURES);
|
||||
}
|
||||
|
||||
QmlProfilerEventsModelProxy::~QmlProfilerEventsModelProxy()
|
||||
QmlProfilerStatisticsModel::~QmlProfilerStatisticsModel()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QmlProfilerEventsModelProxy::setEventTypeAccepted(QmlDebug::RangeType type, bool accepted)
|
||||
void QmlProfilerStatisticsModel::setEventTypeAccepted(QmlDebug::RangeType type, bool accepted)
|
||||
{
|
||||
if (accepted && !d->acceptedTypes.contains(type))
|
||||
d->acceptedTypes << type;
|
||||
@@ -96,27 +96,27 @@ void QmlProfilerEventsModelProxy::setEventTypeAccepted(QmlDebug::RangeType type,
|
||||
d->acceptedTypes.removeOne(type);
|
||||
}
|
||||
|
||||
bool QmlProfilerEventsModelProxy::eventTypeAccepted(QmlDebug::RangeType type) const
|
||||
bool QmlProfilerStatisticsModel::eventTypeAccepted(QmlDebug::RangeType type) const
|
||||
{
|
||||
return d->acceptedTypes.contains(type);
|
||||
}
|
||||
|
||||
const QHash<int, QmlProfilerEventsModelProxy::QmlEventStats> &QmlProfilerEventsModelProxy::getData() const
|
||||
const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &QmlProfilerStatisticsModel::getData() const
|
||||
{
|
||||
return d->data;
|
||||
}
|
||||
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &QmlProfilerEventsModelProxy::getTypes() const
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &QmlProfilerStatisticsModel::getTypes() const
|
||||
{
|
||||
return d->modelManager->qmlModel()->getEventTypes();
|
||||
}
|
||||
|
||||
const QHash<int, QString> &QmlProfilerEventsModelProxy::getNotes() const
|
||||
const QHash<int, QString> &QmlProfilerStatisticsModel::getNotes() const
|
||||
{
|
||||
return d->notes;
|
||||
}
|
||||
|
||||
void QmlProfilerEventsModelProxy::clear()
|
||||
void QmlProfilerStatisticsModel::clear()
|
||||
{
|
||||
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
|
||||
d->data.clear();
|
||||
@@ -124,13 +124,13 @@ void QmlProfilerEventsModelProxy::clear()
|
||||
d->notes.clear();
|
||||
}
|
||||
|
||||
void QmlProfilerEventsModelProxy::limitToRange(qint64 rangeStart, qint64 rangeEnd)
|
||||
void QmlProfilerStatisticsModel::limitToRange(qint64 rangeStart, qint64 rangeEnd)
|
||||
{
|
||||
if (!d->modelManager->isEmpty())
|
||||
loadData(rangeStart, rangeEnd);
|
||||
}
|
||||
|
||||
void QmlProfilerEventsModelProxy::dataChanged()
|
||||
void QmlProfilerStatisticsModel::dataChanged()
|
||||
{
|
||||
if (d->modelManager->state() == QmlProfilerModelManager::ProcessingData)
|
||||
loadData();
|
||||
@@ -138,7 +138,7 @@ void QmlProfilerEventsModelProxy::dataChanged()
|
||||
clear();
|
||||
}
|
||||
|
||||
void QmlProfilerEventsModelProxy::notesChanged(int typeIndex)
|
||||
void QmlProfilerStatisticsModel::notesChanged(int typeIndex)
|
||||
{
|
||||
const QmlProfilerNotesModel *notesModel = d->modelManager->notesModel();
|
||||
if (typeIndex == -1) {
|
||||
@@ -170,12 +170,12 @@ void QmlProfilerEventsModelProxy::notesChanged(int typeIndex)
|
||||
emit notesAvailable(typeIndex);
|
||||
}
|
||||
|
||||
const QSet<int> &QmlProfilerEventsModelProxy::eventsInBindingLoop() const
|
||||
const QSet<int> &QmlProfilerStatisticsModel::eventsInBindingLoop() const
|
||||
{
|
||||
return d->eventsInBindingLoop;
|
||||
}
|
||||
|
||||
void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
|
||||
void QmlProfilerStatisticsModel::loadData(qint64 rangeStart, qint64 rangeEnd)
|
||||
{
|
||||
clear();
|
||||
|
||||
@@ -291,75 +291,69 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
|
||||
emit dataAvailable();
|
||||
}
|
||||
|
||||
int QmlProfilerEventsModelProxy::count() const
|
||||
int QmlProfilerStatisticsModel::count() const
|
||||
{
|
||||
return d->data.count();
|
||||
}
|
||||
|
||||
QmlProfilerEventRelativesModelProxy::QmlProfilerEventRelativesModelProxy(QmlProfilerModelManager *modelManager,
|
||||
QmlProfilerEventsModelProxy *eventsModel,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
QmlProfilerStatisticsRelativesModel::QmlProfilerStatisticsRelativesModel(
|
||||
QmlProfilerModelManager *modelManager, QmlProfilerStatisticsModel *statisticsModel,
|
||||
QObject *parent) : QObject(parent)
|
||||
{
|
||||
QTC_CHECK(modelManager);
|
||||
m_modelManager = modelManager;
|
||||
|
||||
QTC_CHECK(eventsModel);
|
||||
m_eventsModel = eventsModel;
|
||||
QTC_CHECK(statisticsModel);
|
||||
m_statisticsModel = statisticsModel;
|
||||
|
||||
// Load the child models whenever the parent model is done to get the filtering for JS/QML
|
||||
// right.
|
||||
connect(m_eventsModel, &QmlProfilerEventsModelProxy::dataAvailable,
|
||||
this, &QmlProfilerEventRelativesModelProxy::dataChanged);
|
||||
connect(m_statisticsModel, &QmlProfilerStatisticsModel::dataAvailable,
|
||||
this, &QmlProfilerStatisticsRelativesModel::dataChanged);
|
||||
}
|
||||
|
||||
QmlProfilerEventRelativesModelProxy::~QmlProfilerEventRelativesModelProxy()
|
||||
const QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesMap &
|
||||
QmlProfilerStatisticsRelativesModel::getData(int typeId) const
|
||||
{
|
||||
}
|
||||
|
||||
const QmlProfilerEventRelativesModelProxy::QmlEventRelativesMap &QmlProfilerEventRelativesModelProxy::getData(int typeId) const
|
||||
{
|
||||
QHash <int, QmlEventRelativesMap>::ConstIterator it = m_data.find(typeId);
|
||||
QHash <int, QmlStatisticsRelativesMap>::ConstIterator it = m_data.find(typeId);
|
||||
if (it != m_data.end()) {
|
||||
return it.value();
|
||||
} else {
|
||||
static const QmlEventRelativesMap emptyMap;
|
||||
static const QmlStatisticsRelativesMap emptyMap;
|
||||
return emptyMap;
|
||||
}
|
||||
}
|
||||
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &QmlProfilerEventRelativesModelProxy::getTypes() const
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &
|
||||
QmlProfilerStatisticsRelativesModel::getTypes() const
|
||||
{
|
||||
return m_modelManager->qmlModel()->getEventTypes();
|
||||
}
|
||||
|
||||
int QmlProfilerEventRelativesModelProxy::count() const
|
||||
int QmlProfilerStatisticsRelativesModel::count() const
|
||||
{
|
||||
return m_data.count();
|
||||
}
|
||||
|
||||
void QmlProfilerEventRelativesModelProxy::clear()
|
||||
void QmlProfilerStatisticsRelativesModel::clear()
|
||||
{
|
||||
m_data.clear();
|
||||
}
|
||||
|
||||
void QmlProfilerEventRelativesModelProxy::dataChanged()
|
||||
void QmlProfilerStatisticsRelativesModel::dataChanged()
|
||||
{
|
||||
loadData();
|
||||
|
||||
emit dataAvailable();
|
||||
}
|
||||
|
||||
QmlProfilerEventParentsModelProxy::QmlProfilerEventParentsModelProxy(QmlProfilerModelManager *modelManager,
|
||||
QmlProfilerEventsModelProxy *eventsModel,
|
||||
QObject *parent)
|
||||
: QmlProfilerEventRelativesModelProxy(modelManager, eventsModel, parent)
|
||||
QmlProfilerStatisticsParentsModel::QmlProfilerStatisticsParentsModel(
|
||||
QmlProfilerModelManager *modelManager, QmlProfilerStatisticsModel *statisticsModel,
|
||||
QObject *parent) :
|
||||
QmlProfilerStatisticsRelativesModel(modelManager, statisticsModel, parent)
|
||||
{}
|
||||
|
||||
QmlProfilerEventParentsModelProxy::~QmlProfilerEventParentsModelProxy()
|
||||
{}
|
||||
|
||||
void QmlProfilerEventParentsModelProxy::loadData()
|
||||
void QmlProfilerStatisticsParentsModel::loadData()
|
||||
{
|
||||
clear();
|
||||
QmlProfilerDataModel *simpleModel = m_modelManager->qmlModel();
|
||||
@@ -371,7 +365,7 @@ void QmlProfilerEventParentsModelProxy::loadData()
|
||||
int level = QmlDebug::Constants::QML_MIN_LEVEL;
|
||||
endtimesPerLevel[0] = 0;
|
||||
|
||||
const QSet<int> &eventsInBindingLoop = m_eventsModel->eventsInBindingLoop();
|
||||
const QSet<int> &eventsInBindingLoop = m_statisticsModel->eventsInBindingLoop();
|
||||
|
||||
// compute parent-child relationship and call count
|
||||
QHash<int, int> lastParent;
|
||||
@@ -379,7 +373,7 @@ void QmlProfilerEventParentsModelProxy::loadData()
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> typesList = simpleModel->getEventTypes();
|
||||
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) {
|
||||
// whitelist
|
||||
if (!m_eventsModel->eventTypeAccepted(typesList[event.typeIndex()].rangeType))
|
||||
if (!m_statisticsModel->eventTypeAccepted(typesList[event.typeIndex()].rangeType))
|
||||
continue;
|
||||
|
||||
// level computation
|
||||
@@ -396,13 +390,13 @@ void QmlProfilerEventParentsModelProxy::loadData()
|
||||
if (level > QmlDebug::Constants::QML_MIN_LEVEL && lastParent.contains(level-1))
|
||||
parentTypeIndex = lastParent[level-1];
|
||||
|
||||
QmlEventRelativesMap &relativesMap = m_data[event.typeIndex()];
|
||||
QmlEventRelativesMap::Iterator it = relativesMap.find(parentTypeIndex);
|
||||
QmlStatisticsRelativesMap &relativesMap = m_data[event.typeIndex()];
|
||||
QmlStatisticsRelativesMap::Iterator it = relativesMap.find(parentTypeIndex);
|
||||
if (it != relativesMap.end()) {
|
||||
it.value().calls++;
|
||||
it.value().duration += event.duration();
|
||||
} else {
|
||||
QmlEventRelativesData parent = {
|
||||
QmlStatisticsRelativesData parent = {
|
||||
event.duration(),
|
||||
1,
|
||||
eventsInBindingLoop.contains(parentTypeIndex)
|
||||
@@ -415,16 +409,13 @@ void QmlProfilerEventParentsModelProxy::loadData()
|
||||
}
|
||||
}
|
||||
|
||||
QmlProfilerEventChildrenModelProxy::QmlProfilerEventChildrenModelProxy(QmlProfilerModelManager *modelManager,
|
||||
QmlProfilerEventsModelProxy *eventsModel,
|
||||
QObject *parent)
|
||||
: QmlProfilerEventRelativesModelProxy(modelManager, eventsModel, parent)
|
||||
QmlProfilerStatisticsChildrenModel::QmlProfilerStatisticsChildrenModel(
|
||||
QmlProfilerModelManager *modelManager, QmlProfilerStatisticsModel *statisticsModel,
|
||||
QObject *parent) :
|
||||
QmlProfilerStatisticsRelativesModel(modelManager, statisticsModel, parent)
|
||||
{}
|
||||
|
||||
QmlProfilerEventChildrenModelProxy::~QmlProfilerEventChildrenModelProxy()
|
||||
{}
|
||||
|
||||
void QmlProfilerEventChildrenModelProxy::loadData()
|
||||
void QmlProfilerStatisticsChildrenModel::loadData()
|
||||
{
|
||||
clear();
|
||||
QmlProfilerDataModel *simpleModel = m_modelManager->qmlModel();
|
||||
@@ -436,7 +427,7 @@ void QmlProfilerEventChildrenModelProxy::loadData()
|
||||
int level = QmlDebug::Constants::QML_MIN_LEVEL;
|
||||
endtimesPerLevel[0] = 0;
|
||||
|
||||
const QSet<int> &eventsInBindingLoop = m_eventsModel->eventsInBindingLoop();
|
||||
const QSet<int> &eventsInBindingLoop = m_statisticsModel->eventsInBindingLoop();
|
||||
|
||||
// compute parent-child relationship and call count
|
||||
QHash<int, int> lastParent;
|
||||
@@ -444,7 +435,7 @@ void QmlProfilerEventChildrenModelProxy::loadData()
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typesList = simpleModel->getEventTypes();
|
||||
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) {
|
||||
// whitelist
|
||||
if (!m_eventsModel->eventTypeAccepted(typesList[event.typeIndex()].rangeType))
|
||||
if (!m_statisticsModel->eventTypeAccepted(typesList[event.typeIndex()].rangeType))
|
||||
continue;
|
||||
|
||||
// level computation
|
||||
@@ -462,13 +453,13 @@ void QmlProfilerEventChildrenModelProxy::loadData()
|
||||
if (level > QmlDebug::Constants::QML_MIN_LEVEL && lastParent.contains(level-1))
|
||||
parentId = lastParent[level-1];
|
||||
|
||||
QmlEventRelativesMap &relativesMap = m_data[parentId];
|
||||
QmlEventRelativesMap::Iterator it = relativesMap.find(event.typeIndex());
|
||||
QmlStatisticsRelativesMap &relativesMap = m_data[parentId];
|
||||
QmlStatisticsRelativesMap::Iterator it = relativesMap.find(event.typeIndex());
|
||||
if (it != relativesMap.end()) {
|
||||
it.value().calls++;
|
||||
it.value().duration += event.duration();
|
||||
} else {
|
||||
QmlEventRelativesData child = {
|
||||
QmlStatisticsRelativesData child = {
|
||||
event.duration(),
|
||||
1,
|
||||
eventsInBindingLoop.contains(parentId)
|
||||
@@ -481,7 +472,4 @@ void QmlProfilerEventChildrenModelProxy::loadData()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#ifndef QMLPROFILEREVENTSMODELPROXY_H
|
||||
#define QMLPROFILEREVENTSMODELPROXY_H
|
||||
#ifndef QMLPROFILERSTATISTICSMODEL_H
|
||||
#define QMLPROFILERSTATISTICSMODEL_H
|
||||
|
||||
#include "qmlprofilerdatamodel.h"
|
||||
#include "qmlprofilernotesmodel.h"
|
||||
@@ -40,13 +39,10 @@
|
||||
#include <QHash>
|
||||
#include <QVector>
|
||||
|
||||
|
||||
namespace QmlProfiler {
|
||||
class QmlProfilerModelManager;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class QmlProfilerEventsModelProxy : public QObject
|
||||
class QmlProfilerStatisticsModel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -67,8 +63,8 @@ public:
|
||||
bool isBindingLoop;
|
||||
};
|
||||
|
||||
QmlProfilerEventsModelProxy(QmlProfilerModelManager *modelManager, QObject *parent = 0);
|
||||
~QmlProfilerEventsModelProxy();
|
||||
QmlProfilerStatisticsModel(QmlProfilerModelManager *modelManager, QObject *parent = 0);
|
||||
~QmlProfilerStatisticsModel();
|
||||
|
||||
void setEventTypeAccepted(QmlDebug::RangeType type, bool accepted);
|
||||
bool eventTypeAccepted(QmlDebug::RangeType) const;
|
||||
@@ -88,7 +84,6 @@ signals:
|
||||
|
||||
private:
|
||||
void loadData(qint64 rangeStart = -1, qint64 rangeEnd = -1);
|
||||
|
||||
const QSet<int> &eventsInBindingLoop() const;
|
||||
|
||||
private slots:
|
||||
@@ -96,38 +91,35 @@ private slots:
|
||||
void notesChanged(int typeIndex);
|
||||
|
||||
private:
|
||||
class QmlProfilerEventsModelProxyPrivate;
|
||||
QmlProfilerEventsModelProxyPrivate *d;
|
||||
class QmlProfilerStatisticsModelPrivate;
|
||||
QmlProfilerStatisticsModelPrivate *d;
|
||||
|
||||
friend class QmlProfilerEventParentsModelProxy;
|
||||
friend class QmlProfilerEventChildrenModelProxy;
|
||||
friend class QmlProfilerStatisticsParentsModel;
|
||||
friend class QmlProfilerStatisticsChildrenModel;
|
||||
};
|
||||
|
||||
class QmlProfilerEventRelativesModelProxy : public QObject
|
||||
class QmlProfilerStatisticsRelativesModel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct QmlEventRelativesData {
|
||||
struct QmlStatisticsRelativesData {
|
||||
qint64 duration;
|
||||
qint64 calls;
|
||||
bool isBindingLoop;
|
||||
};
|
||||
typedef QHash <int, QmlEventRelativesData> QmlEventRelativesMap;
|
||||
typedef QHash <int, QmlStatisticsRelativesData> QmlStatisticsRelativesMap;
|
||||
|
||||
QmlProfilerEventRelativesModelProxy(QmlProfilerModelManager *modelManager,
|
||||
QmlProfilerEventsModelProxy *eventsModel,
|
||||
QmlProfilerStatisticsRelativesModel(QmlProfilerModelManager *modelManager,
|
||||
QmlProfilerStatisticsModel *statisticsModel,
|
||||
QObject *parent = 0);
|
||||
~QmlProfilerEventRelativesModelProxy();
|
||||
|
||||
|
||||
int count() const;
|
||||
void clear();
|
||||
|
||||
const QmlEventRelativesMap &getData(int typeId) const;
|
||||
const QmlStatisticsRelativesMap &getData(int typeId) const;
|
||||
QVariantList getNotes(int typeId) const;
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &getTypes() const;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void loadData() = 0;
|
||||
|
||||
@@ -138,38 +130,35 @@ protected slots:
|
||||
void dataChanged();
|
||||
|
||||
protected:
|
||||
QHash <int, QmlEventRelativesMap> m_data;
|
||||
QHash <int, QmlStatisticsRelativesMap> m_data;
|
||||
QmlProfilerModelManager *m_modelManager;
|
||||
QmlProfilerEventsModelProxy *m_eventsModel;
|
||||
QmlProfilerStatisticsModel *m_statisticsModel;
|
||||
};
|
||||
|
||||
class QmlProfilerEventParentsModelProxy : public QmlProfilerEventRelativesModelProxy
|
||||
class QmlProfilerStatisticsParentsModel : public QmlProfilerStatisticsRelativesModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QmlProfilerEventParentsModelProxy(QmlProfilerModelManager *modelManager,
|
||||
QmlProfilerEventsModelProxy *eventsModel,
|
||||
QmlProfilerStatisticsParentsModel(QmlProfilerModelManager *modelManager,
|
||||
QmlProfilerStatisticsModel *statisticsModel,
|
||||
QObject *parent = 0);
|
||||
~QmlProfilerEventParentsModelProxy();
|
||||
|
||||
protected:
|
||||
virtual void loadData();
|
||||
};
|
||||
|
||||
class QmlProfilerEventChildrenModelProxy : public QmlProfilerEventRelativesModelProxy
|
||||
class QmlProfilerStatisticsChildrenModel : public QmlProfilerStatisticsRelativesModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QmlProfilerEventChildrenModelProxy(QmlProfilerModelManager *modelManager,
|
||||
QmlProfilerEventsModelProxy *eventsModel,
|
||||
QmlProfilerStatisticsChildrenModel(QmlProfilerModelManager *modelManager,
|
||||
QmlProfilerStatisticsModel *statisticsModel,
|
||||
QObject *parent = 0);
|
||||
~QmlProfilerEventChildrenModelProxy();
|
||||
|
||||
protected:
|
||||
virtual void loadData();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // QMLPROFILERSTATISTICSMODEL_H
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
QmlProfilerStatisticsRelativesView *m_eventChildren;
|
||||
QmlProfilerStatisticsRelativesView *m_eventParents;
|
||||
|
||||
QmlProfilerEventsModelProxy *modelProxy;
|
||||
QmlProfilerStatisticsModel *model;
|
||||
qint64 rangeStart;
|
||||
qint64 rangeEnd;
|
||||
};
|
||||
@@ -197,19 +197,19 @@ QmlProfilerStatisticsView::QmlProfilerStatisticsView(QWidget *parent, QmlProfile
|
||||
{
|
||||
setObjectName(QLatin1String("QmlProfilerStatisticsView"));
|
||||
|
||||
d->modelProxy = new QmlProfilerEventsModelProxy(profilerModelManager, this);
|
||||
d->model = new QmlProfilerStatisticsModel(profilerModelManager, this);
|
||||
|
||||
d->m_eventTree = new QmlProfilerStatisticsMainView(this, d->modelProxy);
|
||||
d->m_eventTree = new QmlProfilerStatisticsMainView(this, d->model);
|
||||
connect(d->m_eventTree, &QmlProfilerStatisticsMainView::gotoSourceLocation,
|
||||
this, &QmlProfilerStatisticsView::gotoSourceLocation);
|
||||
connect(d->m_eventTree, &QmlProfilerStatisticsMainView::typeSelected,
|
||||
this, &QmlProfilerStatisticsView::typeSelected);
|
||||
|
||||
d->m_eventChildren = new QmlProfilerStatisticsRelativesView(
|
||||
new QmlProfilerEventChildrenModelProxy(profilerModelManager, d->modelProxy, this),
|
||||
new QmlProfilerStatisticsChildrenModel(profilerModelManager, d->model, this),
|
||||
this);
|
||||
d->m_eventParents = new QmlProfilerStatisticsRelativesView(
|
||||
new QmlProfilerEventParentsModelProxy(profilerModelManager, d->modelProxy, this),
|
||||
new QmlProfilerStatisticsParentsModel(profilerModelManager, d->model, this),
|
||||
this);
|
||||
connect(d->m_eventTree, &QmlProfilerStatisticsMainView::typeSelected,
|
||||
d->m_eventChildren, &QmlProfilerStatisticsRelativesView::displayType);
|
||||
@@ -249,7 +249,7 @@ QmlProfilerStatisticsView::QmlProfilerStatisticsView(QWidget *parent, QmlProfile
|
||||
|
||||
QmlProfilerStatisticsView::~QmlProfilerStatisticsView()
|
||||
{
|
||||
delete d->modelProxy;
|
||||
delete d->model;
|
||||
delete d;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ void QmlProfilerStatisticsView::restrictToRange(qint64 rangeStart, qint64 rangeE
|
||||
{
|
||||
d->rangeStart = rangeStart;
|
||||
d->rangeEnd = rangeEnd;
|
||||
d->modelProxy->limitToRange(rangeStart, rangeEnd);
|
||||
d->model->limitToRange(rangeStart, rangeEnd);
|
||||
}
|
||||
|
||||
QModelIndex QmlProfilerStatisticsView::selectedModelIndex() const
|
||||
@@ -358,9 +358,9 @@ void QmlProfilerStatisticsView::onVisibleFeaturesChanged(quint64 features)
|
||||
RangeType range = static_cast<RangeType>(i);
|
||||
quint64 featureFlag = 1ULL << featureFromRangeType(range);
|
||||
if (QmlDebug::Constants::QML_JS_RANGE_FEATURES & featureFlag)
|
||||
d->modelProxy->setEventTypeAccepted(range, features & featureFlag);
|
||||
d->model->setEventTypeAccepted(range, features & featureFlag);
|
||||
}
|
||||
d->modelProxy->limitToRange(d->rangeStart, d->rangeEnd);
|
||||
d->model->limitToRange(d->rangeStart, d->rangeEnd);
|
||||
}
|
||||
|
||||
bool QmlProfilerStatisticsView::isRestrictedToRange() const
|
||||
@@ -390,7 +390,7 @@ public:
|
||||
|
||||
QmlProfilerStatisticsMainView *q;
|
||||
|
||||
QmlProfilerEventsModelProxy *modelProxy;
|
||||
QmlProfilerStatisticsModel *model;
|
||||
QStandardItemModel *m_model;
|
||||
QList<bool> m_fieldShown;
|
||||
QHash<int, int> m_columnIndex; // maps field enum to column index
|
||||
@@ -399,7 +399,7 @@ public:
|
||||
};
|
||||
|
||||
QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainView(
|
||||
QWidget *parent, QmlProfilerEventsModelProxy *modelProxy) :
|
||||
QWidget *parent, QmlProfilerStatisticsModel *model) :
|
||||
Utils::TreeView(parent), d(new QmlProfilerStatisticsMainViewPrivate(this))
|
||||
{
|
||||
setViewDefaults(this);
|
||||
@@ -412,10 +412,10 @@ QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainView(
|
||||
setModel(d->m_model);
|
||||
connect(this, &QAbstractItemView::activated, this, &QmlProfilerStatisticsMainView::jumpToItem);
|
||||
|
||||
d->modelProxy = modelProxy;
|
||||
connect(d->modelProxy, &QmlProfilerEventsModelProxy::dataAvailable,
|
||||
d->model = model;
|
||||
connect(d->model, &QmlProfilerStatisticsModel::dataAvailable,
|
||||
this, &QmlProfilerStatisticsMainView::buildModel);
|
||||
connect(d->modelProxy, &QmlProfilerEventsModelProxy::notesAvailable,
|
||||
connect(d->model, &QmlProfilerStatisticsModel::notesAvailable,
|
||||
this, &QmlProfilerStatisticsMainView::updateNotes);
|
||||
d->m_firstNumericColumn = 0;
|
||||
d->m_showExtendedStatistics = false;
|
||||
@@ -561,7 +561,7 @@ int QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainViewPrivate::getFiel
|
||||
void QmlProfilerStatisticsMainView::buildModel()
|
||||
{
|
||||
clear();
|
||||
parseModelProxy();
|
||||
parseModel();
|
||||
setShowExtendedStatistics(d->m_showExtendedStatistics);
|
||||
|
||||
setRootIsDecorated(false);
|
||||
@@ -579,16 +579,16 @@ void QmlProfilerStatisticsMainView::buildModel()
|
||||
|
||||
void QmlProfilerStatisticsMainView::updateNotes(int typeIndex)
|
||||
{
|
||||
const QHash<int, QmlProfilerEventsModelProxy::QmlEventStats> &eventList =
|
||||
d->modelProxy->getData();
|
||||
const QHash<int, QString> ¬eList = d->modelProxy->getNotes();
|
||||
const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &eventList =
|
||||
d->model->getData();
|
||||
const QHash<int, QString> ¬eList = d->model->getNotes();
|
||||
QStandardItem *parentItem = d->m_model->invisibleRootItem();
|
||||
|
||||
for (int rowIndex = 0; rowIndex < parentItem->rowCount(); ++rowIndex) {
|
||||
int rowType = parentItem->child(rowIndex, 0)->data(TypeIdRole).toInt();
|
||||
if (rowType != typeIndex && typeIndex != -1)
|
||||
continue;
|
||||
const QmlProfilerEventsModelProxy::QmlEventStats &stats = eventList[rowType];
|
||||
const QmlProfilerStatisticsModel::QmlEventStats &stats = eventList[rowType];
|
||||
|
||||
for (int columnIndex = 0; columnIndex < parentItem->columnCount(); ++columnIndex) {
|
||||
QStandardItem *item = parentItem->child(rowIndex, columnIndex);
|
||||
@@ -607,17 +607,17 @@ void QmlProfilerStatisticsMainView::updateNotes(int typeIndex)
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerStatisticsMainView::parseModelProxy()
|
||||
void QmlProfilerStatisticsMainView::parseModel()
|
||||
{
|
||||
const QHash<int, QmlProfilerEventsModelProxy::QmlEventStats> &eventList =
|
||||
d->modelProxy->getData();
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typeList = d->modelProxy->getTypes();
|
||||
const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &eventList =
|
||||
d->model->getData();
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typeList = d->model->getTypes();
|
||||
|
||||
|
||||
QHash<int, QmlProfilerEventsModelProxy::QmlEventStats>::ConstIterator it;
|
||||
QHash<int, QmlProfilerStatisticsModel::QmlEventStats>::ConstIterator it;
|
||||
for (it = eventList.constBegin(); it != eventList.constEnd(); ++it) {
|
||||
int typeIndex = it.key();
|
||||
const QmlProfilerEventsModelProxy::QmlEventStats &stats = it.value();
|
||||
const QmlProfilerStatisticsModel::QmlEventStats &stats = it.value();
|
||||
const QmlProfilerDataModel::QmlEventTypeData &event =
|
||||
(typeIndex != -1 ? typeList[typeIndex] : *rootEventType());
|
||||
QStandardItem *parentItem = d->m_model->invisibleRootItem();
|
||||
@@ -743,7 +743,7 @@ QString QmlProfilerStatisticsMainView::nameForType(RangeType typeNumber)
|
||||
|
||||
void QmlProfilerStatisticsMainView::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd)
|
||||
{
|
||||
d->modelProxy->limitToRange(rangeStart, rangeEnd);
|
||||
d->model->limitToRange(rangeStart, rangeEnd);
|
||||
}
|
||||
|
||||
int QmlProfilerStatisticsMainView::selectedTypeId() const
|
||||
@@ -870,21 +870,21 @@ public:
|
||||
QmlProfilerStatisticsRelativesViewPrivate(QmlProfilerStatisticsRelativesView *qq):q(qq) {}
|
||||
~QmlProfilerStatisticsRelativesViewPrivate() {}
|
||||
|
||||
QmlProfilerEventRelativesModelProxy *modelProxy;
|
||||
QmlProfilerStatisticsRelativesModel *model;
|
||||
|
||||
QmlProfilerStatisticsRelativesView *q;
|
||||
};
|
||||
|
||||
QmlProfilerStatisticsRelativesView::QmlProfilerStatisticsRelativesView(
|
||||
QmlProfilerEventRelativesModelProxy *modelProxy, QWidget *parent) :
|
||||
QmlProfilerStatisticsRelativesModel *model, QWidget *parent) :
|
||||
Utils::TreeView(parent), d(new QmlProfilerStatisticsRelativesViewPrivate(this))
|
||||
{
|
||||
setViewDefaults(this);
|
||||
setSortingEnabled(false);
|
||||
d->modelProxy = modelProxy;
|
||||
QStandardItemModel *model = new QStandardItemModel(this);
|
||||
model->setSortRole(SortRole);
|
||||
setModel(model);
|
||||
d->model = model;
|
||||
QStandardItemModel *itemModel = new QStandardItemModel(this);
|
||||
itemModel->setSortRole(SortRole);
|
||||
setModel(itemModel);
|
||||
setRootIsDecorated(false);
|
||||
updateHeader();
|
||||
|
||||
@@ -892,7 +892,7 @@ QmlProfilerStatisticsRelativesView::QmlProfilerStatisticsRelativesView(
|
||||
this, &QmlProfilerStatisticsRelativesView::jumpToItem);
|
||||
|
||||
// Clear when new data available as the selection may be invalid now.
|
||||
connect(d->modelProxy, &QmlProfilerEventRelativesModelProxy::dataAvailable,
|
||||
connect(d->model, &QmlProfilerStatisticsRelativesModel::dataAvailable,
|
||||
this, &QmlProfilerStatisticsRelativesView::clear);
|
||||
}
|
||||
|
||||
@@ -903,7 +903,7 @@ QmlProfilerStatisticsRelativesView::~QmlProfilerStatisticsRelativesView()
|
||||
|
||||
void QmlProfilerStatisticsRelativesView::displayType(int typeIndex)
|
||||
{
|
||||
rebuildTree(d->modelProxy->getData(typeIndex));
|
||||
rebuildTree(d->model->getData(typeIndex));
|
||||
|
||||
updateHeader();
|
||||
resizeColumnToContents(0);
|
||||
@@ -912,24 +912,24 @@ void QmlProfilerStatisticsRelativesView::displayType(int typeIndex)
|
||||
}
|
||||
|
||||
void QmlProfilerStatisticsRelativesView::rebuildTree(
|
||||
const QmlProfilerEventRelativesModelProxy::QmlEventRelativesMap &eventMap)
|
||||
const QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesMap &map)
|
||||
{
|
||||
Q_ASSERT(treeModel());
|
||||
treeModel()->clear();
|
||||
|
||||
QStandardItem *topLevelItem = treeModel()->invisibleRootItem();
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typeList = d->modelProxy->getTypes();
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typeList = d->model->getTypes();
|
||||
|
||||
QmlProfilerEventRelativesModelProxy::QmlEventRelativesMap::const_iterator it;
|
||||
for (it = eventMap.constBegin(); it != eventMap.constEnd(); ++it) {
|
||||
const QmlProfilerEventRelativesModelProxy::QmlEventRelativesData &event = it.value();
|
||||
QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesMap::const_iterator it;
|
||||
for (it = map.constBegin(); it != map.constEnd(); ++it) {
|
||||
const QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesData &event = it.value();
|
||||
int typeIndex = it.key();
|
||||
const QmlProfilerDataModel::QmlEventTypeData &type =
|
||||
(typeIndex != -1 ? typeList[typeIndex] : *rootEventType());
|
||||
QList<QStandardItem *> newRow;
|
||||
|
||||
// ToDo: here we were going to search for the data in the other modelproxy
|
||||
// maybe we should store the data in this proxy and get it here
|
||||
// ToDo: here we were going to search for the data in the other model
|
||||
// maybe we should store the data in this model and get it here
|
||||
// no indirections at this level of abstraction!
|
||||
newRow << new StatisticsViewItem(type.displayName.isEmpty() ? tr("<bytecode>") :
|
||||
type.displayName);
|
||||
@@ -973,7 +973,7 @@ void QmlProfilerStatisticsRelativesView::clear()
|
||||
|
||||
void QmlProfilerStatisticsRelativesView::updateHeader()
|
||||
{
|
||||
bool calleesView = qobject_cast<QmlProfilerEventChildrenModelProxy *>(d->modelProxy) != 0;
|
||||
bool calleesView = qobject_cast<QmlProfilerStatisticsChildrenModel *>(d->model) != 0;
|
||||
|
||||
if (treeModel()) {
|
||||
treeModel()->setColumnCount(5);
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#define QMLPROFILERSTATISTICSVIEW_H
|
||||
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmlprofilereventsmodelproxy.h"
|
||||
#include "qmlprofilerstatisticsmodel.h"
|
||||
#include "qmlprofilerviewmanager.h"
|
||||
#include "qmlprofilereventsview.h"
|
||||
|
||||
@@ -117,8 +117,7 @@ class QmlProfilerStatisticsMainView : public Utils::TreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlProfilerStatisticsMainView(QWidget *parent,
|
||||
QmlProfilerEventsModelProxy *modelProxy);
|
||||
explicit QmlProfilerStatisticsMainView(QWidget *parent, QmlProfilerStatisticsModel *model);
|
||||
~QmlProfilerStatisticsMainView();
|
||||
|
||||
void setFieldViewable(Fields field, bool show);
|
||||
@@ -151,7 +150,7 @@ public slots:
|
||||
private:
|
||||
void selectItem(const QStandardItem *item);
|
||||
void setHeaderLabels();
|
||||
void parseModelProxy();
|
||||
void parseModel();
|
||||
QStandardItem *itemFromIndex(const QModelIndex &index) const;
|
||||
|
||||
private:
|
||||
@@ -164,8 +163,8 @@ class QmlProfilerStatisticsRelativesView : public Utils::TreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlProfilerStatisticsRelativesView(QmlProfilerEventRelativesModelProxy *modelProxy,
|
||||
QWidget *parent );
|
||||
explicit QmlProfilerStatisticsRelativesView(QmlProfilerStatisticsRelativesModel *model,
|
||||
QWidget *parent);
|
||||
~QmlProfilerStatisticsRelativesView();
|
||||
|
||||
signals:
|
||||
@@ -178,7 +177,7 @@ public slots:
|
||||
void clear();
|
||||
|
||||
private:
|
||||
void rebuildTree(const QmlProfilerEventParentsModelProxy::QmlEventRelativesMap &eventMap);
|
||||
void rebuildTree(const QmlProfilerStatisticsParentsModel::QmlStatisticsRelativesMap &map);
|
||||
void updateHeader();
|
||||
QStandardItemModel *treeModel();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user