Reduce code duplication

Change-Id: Icc072982427dc3874262fcaaf9885931e1588e80
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-02-14 16:34:22 +01:00
parent 86b3da7cd2
commit b1bc443f5c
4 changed files with 64 additions and 309 deletions

View File

@@ -20,6 +20,7 @@
#include "qmldebug/qmlprofilereventtypes.h" #include "qmldebug/qmlprofilereventtypes.h"
#include "qmlprofiler/qmlprofilermodelmanager.h" #include "qmlprofiler/qmlprofilermodelmanager.h"
#include "qmlprofiler/sortedtimelinemodel.h" #include "qmlprofiler/sortedtimelinemodel.h"
#include "qmlprofiler/singlecategorytimelinemodel_p.h"
#include <QDebug> #include <QDebug>
@@ -28,14 +29,11 @@ namespace Internal {
using namespace QmlProfiler; using namespace QmlProfiler;
class PixmapCacheModel::PixmapCacheModelPrivate : public SortedTimelineModel<PixmapCacheEvent> { class PixmapCacheModel::PixmapCacheModelPrivate :
public SortedTimelineModel<PixmapCacheEvent,
SingleCategoryTimelineModel::SingleCategoryTimelineModelPrivate>
{
public: public:
PixmapCacheModelPrivate(PixmapCacheModel *qq):q(qq) {}
~PixmapCacheModelPrivate();
PixmapCacheModel *q;
void computeCacheSizes(); void computeCacheSizes();
void resizeUnfinishedLoads(); void resizeUnfinishedLoads();
void flattenLoads(); void flattenLoads();
@@ -43,133 +41,54 @@ public:
QVector < QString > pixmapUrls; QVector < QString > pixmapUrls;
QVector < QPair<int, int> > pixmapSizes; QVector < QPair<int, int> > pixmapSizes;
bool isExpanded;
int expandedRowCount; int expandedRowCount;
int collapsedRowCount; int collapsedRowCount;
void addVP(QVariantList &l, QString label, qint64 time); void addVP(QVariantList &l, QString label, qint64 time) const;
qint64 minCacheSize; qint64 minCacheSize;
qint64 maxCacheSize; qint64 maxCacheSize;
private:
Q_DECLARE_PUBLIC(PixmapCacheModel)
}; };
PixmapCacheModel::PixmapCacheModel(QObject *parent) PixmapCacheModel::PixmapCacheModel(QObject *parent)
: AbstractTimelineModel(QLatin1String("PixmapCacheTimeLineModel"), parent), : SingleCategoryTimelineModel(new PixmapCacheModelPrivate(),
d(new PixmapCacheModelPrivate(this)) QLatin1String("PixmapCacheTimeLineModel"),
QLatin1String("Pixmap Cache"), QmlDebug::PixmapCacheEvent, parent)
{ {
Q_D(PixmapCacheModel);
d->collapsedRowCount = 1; d->collapsedRowCount = 1;
d->expandedRowCount = 1; d->expandedRowCount = 1;
} }
PixmapCacheModel::~PixmapCacheModel()
{
}
int PixmapCacheModel::count() const
{
return d->count();
}
bool PixmapCacheModel::eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const
{
return (event.eventType == QmlDebug::PixmapCacheEvent);
}
qint64 PixmapCacheModel::lastTimeMark() const
{
return d->lastEndTime();
}
bool PixmapCacheModel::expanded(int ) const
{
return d->isExpanded;
}
void PixmapCacheModel::setExpanded(int category, bool expanded)
{
Q_UNUSED(category);
bool prev_expanded = d->isExpanded;
d->isExpanded = expanded;
if (prev_expanded != expanded)
emit expandedChanged();
}
int PixmapCacheModel::categoryDepth(int categoryIndex) const int PixmapCacheModel::categoryDepth(int categoryIndex) const
{ {
Q_D(const PixmapCacheModel);
Q_UNUSED(categoryIndex); Q_UNUSED(categoryIndex);
if (isEmpty()) if (isEmpty())
return 1; return 1;
if (d->isExpanded) if (d->expanded)
return d->expandedRowCount; return d->expandedRowCount;
return d->collapsedRowCount; return d->collapsedRowCount;
} }
int PixmapCacheModel::categoryCount() const
{
return 1;
}
const QString PixmapCacheModel::categoryLabel(int categoryIndex) const
{
Q_UNUSED(categoryIndex);
return QLatin1String("Pixmap Cache");
}
int PixmapCacheModel::findFirstIndex(qint64 startTime) const
{
return d->findFirstIndex(startTime);
}
int PixmapCacheModel::findFirstIndexNoParents(qint64 startTime) const
{
return d->findFirstIndexNoParents(startTime);
}
int PixmapCacheModel::findLastIndex(qint64 endTime) const
{
return d->findLastIndex(endTime);
}
int PixmapCacheModel::getEventType(int index) const
{
Q_UNUSED(index);
return QmlDebug::PixmapCacheEvent;
}
int PixmapCacheModel::getEventCategory(int index) const
{
Q_UNUSED(index);
return 0;
}
int PixmapCacheModel::getEventRow(int index) const int PixmapCacheModel::getEventRow(int index) const
{ {
if (d->isExpanded) Q_D(const PixmapCacheModel);
if (d->expanded)
return d->range(index).rowNumberExpanded; return d->range(index).rowNumberExpanded;
return d->range(index).rowNumberCollapsed; return d->range(index).rowNumberCollapsed;
} }
qint64 PixmapCacheModel::getDuration(int index) const
{
return d->range(index).duration;
}
qint64 PixmapCacheModel::getStartTime(int index) const
{
return d->range(index).start;
}
qint64 PixmapCacheModel::getEndTime(int index) const
{
return getStartTime(index)+getDuration(index);
}
int PixmapCacheModel::getEventId(int index) const int PixmapCacheModel::getEventId(int index) const
{ {
Q_D(const PixmapCacheModel);
return d->range(index).eventId; return d->range(index).eventId;
} }
QColor PixmapCacheModel::getColor(int index) const QColor PixmapCacheModel::getColor(int index) const
{ {
Q_D(const PixmapCacheModel);
if (d->range(index).pixmapEventType == PixmapCacheCountChanged) if (d->range(index).pixmapEventType == PixmapCacheCountChanged)
return QColor::fromHsl(240, 76, 166); return QColor::fromHsl(240, 76, 166);
@@ -179,6 +98,7 @@ QColor PixmapCacheModel::getColor(int index) const
float PixmapCacheModel::getHeight(int index) const float PixmapCacheModel::getHeight(int index) const
{ {
Q_D(const PixmapCacheModel);
if (d->range(index).pixmapEventType == PixmapCacheCountChanged) { if (d->range(index).pixmapEventType == PixmapCacheCountChanged) {
float scale = d->maxCacheSize - d->minCacheSize; float scale = d->maxCacheSize - d->minCacheSize;
float fraction = 1.0f; float fraction = 1.0f;
@@ -202,10 +122,11 @@ QString getFilenameOnly(QString absUrl)
const QVariantList PixmapCacheModel::getLabelsForCategory(int category) const const QVariantList PixmapCacheModel::getLabelsForCategory(int category) const
{ {
Q_D(const PixmapCacheModel);
Q_UNUSED(category); Q_UNUSED(category);
QVariantList result; QVariantList result;
if (d->isExpanded && !isEmpty()) { if (d->expanded && !isEmpty()) {
{ {
// Cache Size // Cache Size
QVariantMap element; QVariantMap element;
@@ -230,7 +151,7 @@ const QVariantList PixmapCacheModel::getLabelsForCategory(int category) const
return result; return result;
} }
void PixmapCacheModel::PixmapCacheModelPrivate::addVP(QVariantList &l, QString label, qint64 time) void PixmapCacheModel::PixmapCacheModelPrivate::addVP(QVariantList &l, QString label, qint64 time) const
{ {
if (time > 0) { if (time > 0) {
QVariantMap res; QVariantMap res;
@@ -241,6 +162,7 @@ void PixmapCacheModel::PixmapCacheModelPrivate::addVP(QVariantList &l, QString l
const QVariantList PixmapCacheModel::getEventDetails(int index) const const QVariantList PixmapCacheModel::getEventDetails(int index) const
{ {
Q_D(const PixmapCacheModel);
QVariantList result; QVariantList result;
const PixmapCacheModelPrivate::Range *ev = &d->range(index); const PixmapCacheModelPrivate::Range *ev = &d->range(index);
@@ -281,26 +203,11 @@ const QVariantList PixmapCacheModel::getEventDetails(int index) const
return result; return result;
} }
const QVariantMap PixmapCacheModel::getEventLocation(int /*index*/) const
{
QVariantMap map;
return map;
}
int PixmapCacheModel::getEventIdForHash(const QString &/*eventHash*/) const
{
return -1;
}
int PixmapCacheModel::getEventIdForLocation(const QString &/*filename*/, int /*line*/, int /*column*/) const
{
return -1;
}
void PixmapCacheModel::loadData() void PixmapCacheModel::loadData()
{ {
Q_D(PixmapCacheModel);
clear(); clear();
QmlProfilerSimpleModel *simpleModel = m_modelManager->simpleModel(); QmlProfilerSimpleModel *simpleModel = d->modelManager->simpleModel();
if (simpleModel->isEmpty()) if (simpleModel->isEmpty())
return; return;
@@ -386,7 +293,7 @@ void PixmapCacheModel::loadData()
break; break;
} }
m_modelManager->modelProxyCountUpdated(m_modelId, d->count(), 2*simpleModel->getEvents().count()); d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), 2*simpleModel->getEvents().count());
} }
if (lastCacheSizeEvent != -1) { if (lastCacheSizeEvent != -1) {
@@ -400,19 +307,20 @@ void PixmapCacheModel::loadData()
d->computeRowCounts(); d->computeRowCounts();
d->computeNesting(); d->computeNesting();
m_modelManager->modelProxyCountUpdated(m_modelId, 1, 1); d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1);
} }
void PixmapCacheModel::clear() void PixmapCacheModel::clear()
{ {
Q_D(PixmapCacheModel);
d->SortedTimelineModel::clear(); d->SortedTimelineModel::clear();
d->pixmapUrls.clear(); d->pixmapUrls.clear();
d->pixmapSizes.clear(); d->pixmapSizes.clear();
d->collapsedRowCount = 1; d->collapsedRowCount = 1;
d->expandedRowCount = 1; d->expandedRowCount = 1;
d->isExpanded = false; d->expanded = false;
m_modelManager->modelProxyCountUpdated(m_modelId, 0, 1); d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
} }
void PixmapCacheModel::PixmapCacheModelPrivate::computeCacheSizes() void PixmapCacheModel::PixmapCacheModelPrivate::computeCacheSizes()
@@ -431,6 +339,7 @@ void PixmapCacheModel::PixmapCacheModelPrivate::computeCacheSizes()
void PixmapCacheModel::PixmapCacheModelPrivate::resizeUnfinishedLoads() void PixmapCacheModel::PixmapCacheModelPrivate::resizeUnfinishedLoads()
{ {
Q_Q(PixmapCacheModel);
// all the "load start" events with duration 0 continue till the end of the trace // all the "load start" events with duration 0 continue till the end of the trace
for (int i = 0; i < count(); i++) { for (int i = 0; i < count(); i++) {
if (range(i).pixmapEventType == PixmapCacheModel::PixmapLoadingStarted && if (range(i).pixmapEventType == PixmapCacheModel::PixmapLoadingStarted &&

View File

@@ -20,7 +20,7 @@
#define PIXMAPCACHEMODEL_H #define PIXMAPCACHEMODEL_H
#include "qmlprofiler/qmlprofilertimelinemodelproxy.h" #include "qmlprofiler/qmlprofilertimelinemodelproxy.h"
#include "qmlprofiler/qmlprofilermodelmanager.h" #include "qmlprofiler/singlecategorytimelinemodel.h"
#include "qmlprofiler/qmlprofilersimplemodel.h" #include "qmlprofiler/qmlprofilersimplemodel.h"
#include <QStringList> #include <QStringList>
@@ -29,7 +29,7 @@
namespace QmlProfilerExtension { namespace QmlProfilerExtension {
namespace Internal { namespace Internal {
class PixmapCacheModel : public QmlProfiler::AbstractTimelineModel class PixmapCacheModel : public QmlProfiler::SingleCategoryTimelineModel
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -55,33 +55,10 @@ public:
}; };
PixmapCacheModel(QObject *parent = 0); PixmapCacheModel(QObject *parent = 0);
~PixmapCacheModel();
// void setModelManager(QmlProfiler::Internal::QmlProfilerModelManager *modelManager);
int count() const;
bool eventAccepted(const QmlProfiler::QmlProfilerSimpleModel::QmlEventData &event) const;
Q_INVOKABLE qint64 lastTimeMark() const;
Q_INVOKABLE bool expanded(int category) const;
Q_INVOKABLE void setExpanded(int category, bool expanded);
Q_INVOKABLE int categoryDepth(int categoryIndex) const; Q_INVOKABLE int categoryDepth(int categoryIndex) const;
Q_INVOKABLE int categoryCount() const;
Q_INVOKABLE const QString categoryLabel(int categoryIndex) const;
int findFirstIndex(qint64 startTime) const;
int findFirstIndexNoParents(qint64 startTime) const;
int findLastIndex(qint64 endTime) const;
int getEventType(int index) const;
int getEventCategory(int index) const;
int getEventRow(int index) const; int getEventRow(int index) const;
Q_INVOKABLE qint64 getDuration(int index) const;
Q_INVOKABLE qint64 getStartTime(int index) const;
Q_INVOKABLE qint64 getEndTime(int index) const;
Q_INVOKABLE int getEventId(int index) const; Q_INVOKABLE int getEventId(int index) const;
Q_INVOKABLE QColor getColor(int index) const; Q_INVOKABLE QColor getColor(int index) const;
Q_INVOKABLE float getHeight(int index) const; Q_INVOKABLE float getHeight(int index) const;
@@ -89,18 +66,13 @@ public:
Q_INVOKABLE const QVariantList getLabelsForCategory(int category) const; Q_INVOKABLE const QVariantList getLabelsForCategory(int category) const;
Q_INVOKABLE const QVariantList getEventDetails(int index) const; Q_INVOKABLE const QVariantList getEventDetails(int index) const;
Q_INVOKABLE const QVariantMap getEventLocation(int index) const;
Q_INVOKABLE int getEventIdForHash(const QString &eventHash) const;
Q_INVOKABLE int getEventIdForLocation(const QString &filename, int line, int column) const;
void loadData(); void loadData();
void clear(); void clear();
private: private:
class PixmapCacheModelPrivate; class PixmapCacheModelPrivate;
PixmapCacheModelPrivate *d; Q_DECLARE_PRIVATE(PixmapCacheModel)
}; };
} // namespace Internal } // namespace Internal

View File

@@ -20,6 +20,7 @@
#include "qmldebug/qmlprofilereventtypes.h" #include "qmldebug/qmlprofilereventtypes.h"
#include "qmlprofiler/qmlprofilermodelmanager.h" #include "qmlprofiler/qmlprofilermodelmanager.h"
#include "qmlprofiler/sortedtimelinemodel.h" #include "qmlprofiler/sortedtimelinemodel.h"
#include "qmlprofiler/singlecategorytimelinemodel_p.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QDebug> #include <QDebug>
@@ -51,53 +52,23 @@ enum SceneGraphCategoryType {
MaximumSceneGraphCategoryType MaximumSceneGraphCategoryType
}; };
class SceneGraphTimelineModel::SceneGraphTimelineModelPrivate : public SortedTimelineModel<SceneGraphTimelineModel::SceneGraphEvent> { class SceneGraphTimelineModel::SceneGraphTimelineModelPrivate :
public SortedTimelineModel<SceneGraphTimelineModel::SceneGraphEvent,
SingleCategoryTimelineModel::SingleCategoryTimelineModelPrivate>
{
public: public:
SceneGraphTimelineModelPrivate(SceneGraphTimelineModel *qq):q(qq) {} void addVP(QVariantList &l, QString label, qint64 time) const;
~SceneGraphTimelineModelPrivate(); private:
Q_DECLARE_PUBLIC(SceneGraphTimelineModel)
SceneGraphTimelineModel *q;
bool isExpanded;
void addVP(QVariantList &l, QString label, qint64 time);
}; };
SceneGraphTimelineModel::SceneGraphTimelineModel(QObject *parent) SceneGraphTimelineModel::SceneGraphTimelineModel(QObject *parent)
: AbstractTimelineModel(QLatin1String("SceneGraphTimeLineModel"), parent), : SingleCategoryTimelineModel(new SceneGraphTimelineModelPrivate,
d(new SceneGraphTimelineModelPrivate(this)) QLatin1String("SceneGraphTimeLineModel"), tr("Scene Graph"),
QmlDebug::SceneGraphFrameEvent, parent)
{ {
} }
SceneGraphTimelineModel::~SceneGraphTimelineModel()
{
}
int SceneGraphTimelineModel::count() const
{
return d->count();
}
bool SceneGraphTimelineModel::eventAccepted(const QmlProfiler::QmlProfilerSimpleModel::QmlEventData &event) const
{
return (event.eventType == QmlDebug::SceneGraphFrameEvent);
}
qint64 SceneGraphTimelineModel::lastTimeMark() const
{
return d->lastEndTime();
}
bool SceneGraphTimelineModel::expanded(int ) const
{
return d->isExpanded;
}
void SceneGraphTimelineModel::setExpanded(int category, bool expanded)
{
Q_UNUSED(category);
d->isExpanded = expanded;
}
int SceneGraphTimelineModel::categoryDepth(int categoryIndex) const int SceneGraphTimelineModel::categoryDepth(int categoryIndex) const
{ {
Q_UNUSED(categoryIndex); Q_UNUSED(categoryIndex);
@@ -106,66 +77,15 @@ int SceneGraphTimelineModel::categoryDepth(int categoryIndex) const
return 3; return 3;
} }
int SceneGraphTimelineModel::categoryCount() const
{
return 1;
}
const QString SceneGraphTimelineModel::categoryLabel(int categoryIndex) const
{
Q_UNUSED(categoryIndex);
return tr("Scene Graph");
}
int SceneGraphTimelineModel::findFirstIndex(qint64 startTime) const
{
return d->findFirstIndex(startTime);
}
int SceneGraphTimelineModel::findFirstIndexNoParents(qint64 startTime) const
{
return d->findFirstIndexNoParents(startTime);
}
int SceneGraphTimelineModel::findLastIndex(qint64 endTime) const
{
return d->findLastIndex(endTime);
}
int SceneGraphTimelineModel::getEventType(int index) const
{
Q_UNUSED(index);
return QmlDebug::SceneGraphFrameEvent;
}
int SceneGraphTimelineModel::getEventCategory(int index) const
{
Q_UNUSED(index);
return 0;
}
int SceneGraphTimelineModel::getEventRow(int index) const int SceneGraphTimelineModel::getEventRow(int index) const
{ {
Q_D(const SceneGraphTimelineModel);
return d->range(index).sgEventType + 1; return d->range(index).sgEventType + 1;
} }
qint64 SceneGraphTimelineModel::getDuration(int index) const
{
return d->range(index).duration;
}
qint64 SceneGraphTimelineModel::getStartTime(int index) const
{
return d->range(index).start;
}
qint64 SceneGraphTimelineModel::getEndTime(int index) const
{
return getStartTime(index)+getDuration(index);
}
int SceneGraphTimelineModel::getEventId(int index) const int SceneGraphTimelineModel::getEventId(int index) const
{ {
Q_D(const SceneGraphTimelineModel);
return d->range(index).sgEventType; return d->range(index).sgEventType;
} }
@@ -186,12 +106,6 @@ QColor SceneGraphTimelineModel::getColor(int index) const
return QColor::fromHsl((fpsFraction*96)+10, 76, 166); return QColor::fromHsl((fpsFraction*96)+10, 76, 166);
} }
float SceneGraphTimelineModel::getHeight(int index) const
{
Q_UNUSED(index);
return 1.0f;
}
QString labelForSGType(int t) QString labelForSGType(int t)
{ {
switch ((SceneGraphCategoryType)t) { switch ((SceneGraphCategoryType)t) {
@@ -205,10 +119,11 @@ QString labelForSGType(int t)
const QVariantList SceneGraphTimelineModel::getLabelsForCategory(int category) const const QVariantList SceneGraphTimelineModel::getLabelsForCategory(int category) const
{ {
Q_D(const SceneGraphTimelineModel);
Q_UNUSED(category); Q_UNUSED(category);
QVariantList result; QVariantList result;
if (d->isExpanded && !isEmpty()) { if (d->expanded && !isEmpty()) {
for (int i = 0; i < MaximumSceneGraphCategoryType; i++) { for (int i = 0; i < MaximumSceneGraphCategoryType; i++) {
QVariantMap element; QVariantMap element;
@@ -222,7 +137,7 @@ const QVariantList SceneGraphTimelineModel::getLabelsForCategory(int category) c
return result; return result;
} }
void SceneGraphTimelineModel::SceneGraphTimelineModelPrivate::addVP(QVariantList &l, QString label, qint64 time) void SceneGraphTimelineModel::SceneGraphTimelineModelPrivate::addVP(QVariantList &l, QString label, qint64 time) const
{ {
if (time > 0) { if (time > 0) {
QVariantMap res; QVariantMap res;
@@ -234,8 +149,11 @@ void SceneGraphTimelineModel::SceneGraphTimelineModelPrivate::addVP(QVariantList
const QVariantList SceneGraphTimelineModel::getEventDetails(int index) const const QVariantList SceneGraphTimelineModel::getEventDetails(int index) const
{ {
Q_D(const SceneGraphTimelineModel);
QVariantList result; QVariantList result;
const SortedTimelineModel<SceneGraphEvent>::Range *ev = &d->range(index); const SortedTimelineModel<SceneGraphEvent,
SingleCategoryTimelineModel::SingleCategoryTimelineModelPrivate>::Range *ev =
&d->range(index);
{ {
QVariantMap res; QVariantMap res;
@@ -273,26 +191,11 @@ const QVariantList SceneGraphTimelineModel::getEventDetails(int index) const
return result; return result;
} }
const QVariantMap SceneGraphTimelineModel::getEventLocation(int /*index*/) const
{
QVariantMap map;
return map;
}
int SceneGraphTimelineModel::getEventIdForHash(const QString &) const
{
return -1;
}
int SceneGraphTimelineModel::getEventIdForLocation(const QString &/*filename*/, int /*line*/, int /*column*/) const
{
return -1;
}
void SceneGraphTimelineModel::loadData() void SceneGraphTimelineModel::loadData()
{ {
Q_D(SceneGraphTimelineModel);
clear(); clear();
QmlProfilerSimpleModel *simpleModel = m_modelManager->simpleModel(); QmlProfilerSimpleModel *simpleModel = d->modelManager->simpleModel();
if (simpleModel->isEmpty()) if (simpleModel->isEmpty())
return; return;
@@ -380,18 +283,19 @@ void SceneGraphTimelineModel::loadData()
} }
} }
m_modelManager->modelProxyCountUpdated(m_modelId, d->count(), simpleModel->getEvents().count()); d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), simpleModel->getEvents().count());
} }
d->computeNesting(); d->computeNesting();
m_modelManager->modelProxyCountUpdated(m_modelId, 1, 1); d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1);
} }
void SceneGraphTimelineModel::clear() void SceneGraphTimelineModel::clear()
{ {
Q_D(SceneGraphTimelineModel);
d->clear(); d->clear();
d->isExpanded = false; d->expanded = false;
m_modelManager->modelProxyCountUpdated(m_modelId, 0, 1); d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
} }
} // namespace Internal } // namespace Internal

View File

@@ -19,7 +19,7 @@
#ifndef SCENEGRAPHTIMELINEMODEL_H #ifndef SCENEGRAPHTIMELINEMODEL_H
#define SCENEGRAPHTIMELINEMODEL_H #define SCENEGRAPHTIMELINEMODEL_H
#include "qmlprofiler/abstracttimelinemodel.h" #include "qmlprofiler/singlecategorytimelinemodel.h"
#include "qmlprofiler/qmlprofilermodelmanager.h" #include "qmlprofiler/qmlprofilermodelmanager.h"
#include "qmlprofiler/qmlprofilersimplemodel.h" #include "qmlprofiler/qmlprofilersimplemodel.h"
@@ -31,7 +31,7 @@ namespace Internal {
#define timingFieldCount 16 #define timingFieldCount 16
class SceneGraphTimelineModel : public QmlProfiler::AbstractTimelineModel class SceneGraphTimelineModel : public QmlProfiler::SingleCategoryTimelineModel
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -41,54 +41,24 @@ public:
qint64 timing[timingFieldCount]; qint64 timing[timingFieldCount];
}; };
SceneGraphTimelineModel(QObject *parent = 0); SceneGraphTimelineModel(QObject *parent = 0);
~SceneGraphTimelineModel();
// void setModelManager(QmlProfiler::Internal::QmlProfilerModelManager *modelManager);
int count() const;
bool eventAccepted(const QmlProfiler::QmlProfilerSimpleModel::QmlEventData &event) const;
Q_INVOKABLE qint64 lastTimeMark() const;
Q_INVOKABLE bool expanded(int category) const;
Q_INVOKABLE void setExpanded(int category, bool expanded);
Q_INVOKABLE int categoryDepth(int categoryIndex) const; Q_INVOKABLE int categoryDepth(int categoryIndex) const;
Q_INVOKABLE int categoryCount() const;
Q_INVOKABLE const QString categoryLabel(int categoryIndex) const;
int findFirstIndex(qint64 startTime) const;
int findFirstIndexNoParents(qint64 startTime) const;
int findLastIndex(qint64 endTime) const;
int getEventType(int index) const;
int getEventCategory(int index) const;
int getEventRow(int index) const; int getEventRow(int index) const;
Q_INVOKABLE qint64 getDuration(int index) const;
Q_INVOKABLE qint64 getStartTime(int index) const;
Q_INVOKABLE qint64 getEndTime(int index) const;
Q_INVOKABLE int getEventId(int index) const; Q_INVOKABLE int getEventId(int index) const;
Q_INVOKABLE QColor getColor(int index) const; Q_INVOKABLE QColor getColor(int index) const;
Q_INVOKABLE float getHeight(int index) const;
Q_INVOKABLE const QVariantList getLabelsForCategory(int category) const; Q_INVOKABLE const QVariantList getLabelsForCategory(int category) const;
Q_INVOKABLE const QVariantList getEventDetails(int index) const; Q_INVOKABLE const QVariantList getEventDetails(int index) const;
Q_INVOKABLE const QVariantMap getEventLocation(int index) const;
Q_INVOKABLE int getEventIdForHash(const QString &eventHash) const;
Q_INVOKABLE int getEventIdForLocation(const QString &filename, int line, int column) const;
void loadData(); void loadData();
void clear(); void clear();
private: private:
class SceneGraphTimelineModelPrivate; class SceneGraphTimelineModelPrivate;
SceneGraphTimelineModelPrivate *d; Q_DECLARE_PRIVATE(SceneGraphTimelineModel)
}; };
} // namespace Internal } // namespace Internal