forked from qt-creator/qt-creator
QmlProfiler: overview using model aggregator
Change-Id: Iaffb44d97e6641f2e34df6fb5ac839f5b6ebc545 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
committed by
Kai Koehne
parent
1b06a7646d
commit
35d9037732
@@ -75,6 +75,7 @@ public:
|
||||
virtual int findLastIndex(qint64 endTime) const = 0;
|
||||
|
||||
virtual int getEventType(int index) const = 0;
|
||||
virtual int getEventCategory(int index) const = 0;
|
||||
virtual int getEventRow(int index) const = 0;
|
||||
Q_INVOKABLE virtual qint64 getDuration(int index) const = 0;
|
||||
Q_INVOKABLE virtual qint64 getStartTime(int index) const = 0;
|
||||
|
||||
@@ -44,24 +44,25 @@ function drawData(canvas, ctxt, region)
|
||||
if ((!qmlProfilerModelProxy) || qmlProfilerModelProxy.count() == 0)
|
||||
return;
|
||||
|
||||
var typeCount = 5;
|
||||
var width = canvas.width;
|
||||
var bump = 10;
|
||||
var height = canvas.height - bump;
|
||||
|
||||
var typeCount = qmlProfilerModelProxy.visibleCategories();
|
||||
var blockHeight = height / typeCount;
|
||||
|
||||
var spacing = width / qmlProfilerModelProxy.traceDuration();
|
||||
|
||||
var highest = [0,0,0,0,0]; // note: change if typeCount changes
|
||||
var modelRowStart = 0;
|
||||
for (var modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); modelIndex++) {
|
||||
for (var ii = 0; ii < qmlProfilerModelProxy.count(modelIndex); ++ii) {
|
||||
|
||||
for (var ii = 0; ii < qmlProfilerModelProxy.count(); ++ii) {
|
||||
|
||||
var xx = (qmlProfilerModelProxy.getStartTime(ii) -
|
||||
var xx = (qmlProfilerModelProxy.getStartTime(modelIndex,ii) -
|
||||
qmlProfilerModelProxy.traceStartTime()) * spacing;
|
||||
if (xx > region.x + region.width)
|
||||
continue;
|
||||
|
||||
var eventWidth = qmlProfilerModelProxy.getDuration(ii) * spacing;
|
||||
var eventWidth = qmlProfilerModelProxy.getDuration(modelIndex,ii) * spacing;
|
||||
if (xx + eventWidth < region.x)
|
||||
continue;
|
||||
|
||||
@@ -69,50 +70,40 @@ function drawData(canvas, ctxt, region)
|
||||
eventWidth = 1;
|
||||
|
||||
xx = Math.round(xx);
|
||||
var ty = qmlProfilerModelProxy.getType(ii);
|
||||
|
||||
if (xx + eventWidth > highest[ty]) {
|
||||
/*
|
||||
// special: animations
|
||||
if (ty === 0 && qmlProfilerModelProxy.getAnimationCount(ii) >= 0) {
|
||||
var vertScale = qmlProfilerModelProxy.getMaximumAnimationCount() -
|
||||
qmlProfilerModelProxy.getMinimumAnimationCount();
|
||||
if (vertScale < 1)
|
||||
vertScale = 1;
|
||||
var fraction = (qmlProfilerModelProxy.getAnimationCount(ii) -
|
||||
qmlProfilerModelProxy.getMinimumAnimationCount()) / vertScale;
|
||||
var eventHeight = blockHeight * (fraction * 0.85 + 0.15);
|
||||
var yy = bump + ty*blockHeight + blockHeight - eventHeight;
|
||||
var rowNumber = modelRowStart + qmlProfilerModelProxy.getEventCategoryInModel(modelIndex, ii);
|
||||
|
||||
var fpsFraction = qmlProfilerModelProxy.getFramerate(ii) / 60.0;
|
||||
if (fpsFraction > 1.0)
|
||||
fpsFraction = 1.0;
|
||||
ctxt.fillStyle = "hsl("+(fpsFraction*0.27+0.028)+",0.3,0.65)";
|
||||
ctxt.fillRect(xx, yy, eventWidth, eventHeight);
|
||||
} else { */
|
||||
var hue = ( qmlProfilerModelProxy.getEventId(ii) * 25 ) % 360;
|
||||
ctxt.fillStyle = "hsl("+(hue/360.0+0.001)+",0.3,0.65)";
|
||||
ctxt.fillRect(xx, bump + ty*blockHeight, eventWidth, blockHeight);
|
||||
/*}*/
|
||||
highest[ty] = xx+eventWidth;
|
||||
var itemHeight = qmlProfilerModelProxy.getHeight(modelIndex,ii) * blockHeight;
|
||||
var yy = (rowNumber + 1) * blockHeight - itemHeight ;
|
||||
|
||||
var itemColor = qmlProfilerModelProxy.getColorRGB(modelIndex, ii);
|
||||
ctxt.fillStyle = "rgb("+itemColor[0]+","+itemColor[1]+","+itemColor[2]+")";
|
||||
ctxt.fillRect(xx, bump + yy, eventWidth, itemHeight);
|
||||
}
|
||||
modelRowStart += qmlProfilerModelProxy.categoryCount(modelIndex);
|
||||
}
|
||||
|
||||
// binding loops
|
||||
ctxt.strokeStyle = "orange";
|
||||
ctxt.lineWidth = 2;
|
||||
var radius = 1;
|
||||
for (var ii = 0; ii < qmlProfilerModelProxy.count(); ++ii) {
|
||||
if (qmlProfilerModelProxy.getBindingLoopDest(ii) >= 0) {
|
||||
var xcenter = Math.round(qmlProfilerModelProxy.getStartTime(ii) +
|
||||
qmlProfilerModelProxy.getDuration(ii) -
|
||||
modelRowStart = 0;
|
||||
for (modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); modelIndex++) {
|
||||
for (ii = 0; ii < qmlProfilerModelProxy.count(modelIndex); ++ii) {
|
||||
if (qmlProfilerModelProxy.getBindingLoopDest(modelIndex,ii) >= 0) {
|
||||
var xcenter = Math.round(qmlProfilerModelProxy.getStartTime(modelIndex,ii) +
|
||||
qmlProfilerModelProxy.getDuration(modelIndex,ii) -
|
||||
qmlProfilerModelProxy.traceStartTime()) * spacing;
|
||||
var ycenter = Math.round(bump + qmlProfilerModelProxy.getType(ii) *
|
||||
var ycenter = Math.round(bump + (modelRowStart +
|
||||
qmlProfilerModelProxy.getEventCategoryInModel(modelIndex, ii)) *
|
||||
blockHeight + blockHeight/2);
|
||||
ctxt.arc(xcenter, ycenter, radius, 0, 2*Math.PI, true);
|
||||
ctxt.stroke();
|
||||
}
|
||||
}
|
||||
modelRowStart += qmlProfilerModelProxy.categoryCount(modelIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function drawTimeBar(canvas, ctxt, region)
|
||||
|
||||
@@ -26,7 +26,6 @@ SOURCES += \
|
||||
qmlprofilerprocessedmodel.cpp \
|
||||
qmlprofilereventsmodelproxy.cpp \
|
||||
qmlprofilertimelinemodelproxy.cpp \
|
||||
qmlprofileroverviewmodelproxy.cpp \
|
||||
qmlprofilertreeview.cpp \
|
||||
qmlprofilertracefile.cpp \
|
||||
abstracttimelinemodel.cpp \
|
||||
@@ -57,7 +56,6 @@ HEADERS += \
|
||||
qmlprofilerprocessedmodel.h \
|
||||
qmlprofilereventsmodelproxy.h \
|
||||
qmlprofilertimelinemodelproxy.h \
|
||||
qmlprofileroverviewmodelproxy.h \
|
||||
qmlprofilertreeview.h \
|
||||
qmlprofilertracefile.h \
|
||||
abstracttimelinemodel.h \
|
||||
|
||||
@@ -44,8 +44,6 @@ QtcPlugin {
|
||||
"qmlprofilereventview.h",
|
||||
"qmlprofilermodelmanager.cpp",
|
||||
"qmlprofilermodelmanager.h",
|
||||
"qmlprofileroverviewmodelproxy.cpp",
|
||||
"qmlprofileroverviewmodelproxy.h",
|
||||
"qmlprofilerplugin.cpp",
|
||||
"qmlprofilerplugin.h",
|
||||
"qmlprofilerprocessedmodel.cpp",
|
||||
|
||||
@@ -1,227 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmlprofileroverviewmodelproxy.h"
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmlprofilersimplemodel.h"
|
||||
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
|
||||
#include <QVector>
|
||||
#include <QHash>
|
||||
#include <QUrl>
|
||||
#include <QStack>
|
||||
#include <QString>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
class QmlProfilerOverviewModelProxy::QmlProfilerOverviewModelProxyPrivate
|
||||
{
|
||||
public:
|
||||
QmlProfilerOverviewModelProxyPrivate(QmlProfilerOverviewModelProxy *qq) : q(qq) {}
|
||||
~QmlProfilerOverviewModelProxyPrivate() {}
|
||||
|
||||
QVector <QmlProfilerOverviewModelProxy::QmlOverviewEvent> data;
|
||||
int rowCount;
|
||||
|
||||
QmlProfilerModelManager *modelManager;
|
||||
QmlProfilerOverviewModelProxy *q;
|
||||
};
|
||||
|
||||
QmlProfilerOverviewModelProxy::QmlProfilerOverviewModelProxy(QmlProfilerModelManager *modelManager, QObject *parent)
|
||||
: QObject(parent), d(new QmlProfilerOverviewModelProxyPrivate(this))
|
||||
{
|
||||
d->modelManager = modelManager;
|
||||
connect(modelManager->simpleModel(),SIGNAL(changed()),this,SLOT(dataChanged()));
|
||||
connect(modelManager,SIGNAL(countChanged()),this,SIGNAL(countChanged()));
|
||||
}
|
||||
|
||||
QmlProfilerOverviewModelProxy::~QmlProfilerOverviewModelProxy()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
const QVector<QmlProfilerOverviewModelProxy::QmlOverviewEvent> QmlProfilerOverviewModelProxy::getData() const
|
||||
{
|
||||
return d->data;
|
||||
}
|
||||
void QmlProfilerOverviewModelProxy::clear()
|
||||
{
|
||||
d->data.clear();
|
||||
d->rowCount = 0;
|
||||
}
|
||||
|
||||
void QmlProfilerOverviewModelProxy::dataChanged()
|
||||
{
|
||||
loadData();
|
||||
|
||||
emit dataAvailable();
|
||||
emit emptyChanged();
|
||||
}
|
||||
|
||||
void QmlProfilerOverviewModelProxy::detectBindingLoops()
|
||||
{
|
||||
QStack<int> callStack;
|
||||
|
||||
static QVector<int> acceptedTypes =
|
||||
QVector<int>() << QmlDebug::Compiling << QmlDebug::Creating
|
||||
<< QmlDebug::Binding << QmlDebug::HandlingSignal;
|
||||
|
||||
|
||||
for (int i = 0; i < d->data.size(); ++i) {
|
||||
QmlOverviewEvent *event = &d->data[i];
|
||||
|
||||
if (!acceptedTypes.contains(event->eventType))
|
||||
continue;
|
||||
|
||||
QmlOverviewEvent *potentialParent = callStack.isEmpty() ? 0 : &d->data[callStack.top()];
|
||||
|
||||
while (potentialParent
|
||||
&& !(potentialParent->startTime + potentialParent->duration > event->startTime)) {
|
||||
callStack.pop();
|
||||
potentialParent = callStack.isEmpty() ? 0 : &d->data[callStack.top()];
|
||||
}
|
||||
|
||||
// check whether event is already in stack
|
||||
for (int ii = 0; ii < callStack.size(); ++ii) {
|
||||
if (d->data[callStack.at(ii)].eventId == event->eventId) {
|
||||
event->bindingLoopHead = callStack.at(ii);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
callStack.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
bool compareEvents(const QmlProfilerOverviewModelProxy::QmlOverviewEvent &t1, const QmlProfilerOverviewModelProxy::QmlOverviewEvent &t2)
|
||||
{
|
||||
return t1.startTime < t2.startTime;
|
||||
}
|
||||
|
||||
|
||||
void QmlProfilerOverviewModelProxy::loadData()
|
||||
{
|
||||
clear();
|
||||
QmlProfilerSimpleModel *simpleModel = d->modelManager->simpleModel();
|
||||
if (simpleModel->isEmpty())
|
||||
return;
|
||||
|
||||
QHash <QString, int> eventIdDict;
|
||||
|
||||
const QVector<QmlProfilerSimpleModel::QmlEventData> eventList = simpleModel->getEvents();
|
||||
foreach (const QmlProfilerSimpleModel::QmlEventData &event, eventList) {
|
||||
|
||||
// find event id
|
||||
QString eventHash = QmlProfilerSimpleModel::getHashString(event);
|
||||
int eventId;
|
||||
if (eventIdDict.contains(eventHash)) {
|
||||
eventId = eventIdDict[eventHash];
|
||||
} else {
|
||||
eventId = eventIdDict.count();
|
||||
eventIdDict.insert(eventHash, eventId);
|
||||
}
|
||||
|
||||
QmlOverviewEvent newEvent = {
|
||||
event.eventType,
|
||||
event.startTime,
|
||||
event.duration,
|
||||
1.0, // height
|
||||
eventId, // eventId
|
||||
event.eventType, // eventType
|
||||
-1 // bindingLoopHead
|
||||
};
|
||||
d->data.append(newEvent);
|
||||
|
||||
if (event.eventType > d->rowCount)
|
||||
d->rowCount = event.eventType;
|
||||
}
|
||||
|
||||
qSort(d->data.begin(), d->data.end(), compareEvents);
|
||||
|
||||
detectBindingLoops();
|
||||
}
|
||||
|
||||
/////////////////// QML interface
|
||||
|
||||
bool QmlProfilerOverviewModelProxy::isEmpty() const
|
||||
{
|
||||
return count() == 0;
|
||||
}
|
||||
|
||||
int QmlProfilerOverviewModelProxy::count() const
|
||||
{
|
||||
return d->data.count();
|
||||
}
|
||||
|
||||
qint64 QmlProfilerOverviewModelProxy::traceStartTime() const
|
||||
{
|
||||
return d->modelManager->traceTime()->startTime();
|
||||
}
|
||||
|
||||
qint64 QmlProfilerOverviewModelProxy::traceDuration() const
|
||||
{
|
||||
return d->modelManager->traceTime()->duration();
|
||||
}
|
||||
|
||||
qint64 QmlProfilerOverviewModelProxy::traceEndTime() const
|
||||
{
|
||||
return d->modelManager->traceTime()->endTime();
|
||||
}
|
||||
|
||||
qint64 QmlProfilerOverviewModelProxy::getStartTime(int index) const
|
||||
{
|
||||
return d->data[index].startTime;
|
||||
}
|
||||
|
||||
qint64 QmlProfilerOverviewModelProxy::getDuration(int index) const
|
||||
{
|
||||
return d->data[index].duration;
|
||||
}
|
||||
|
||||
int QmlProfilerOverviewModelProxy::getType(int index) const
|
||||
{
|
||||
return d->data[index].row;
|
||||
}
|
||||
|
||||
int QmlProfilerOverviewModelProxy::getEventId(int index) const
|
||||
{
|
||||
return d->data[index].eventId;
|
||||
}
|
||||
|
||||
int QmlProfilerOverviewModelProxy::getBindingLoopDest(int index) const
|
||||
{
|
||||
return d->data[index].bindingLoopHead;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#ifndef QMLPROFILEROVERVIEWMODELPROXY_H
|
||||
#define QMLPROFILEROVERVIEWMODELPROXY_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
class QmlProfilerModelManager;
|
||||
|
||||
class QmlProfilerOverviewModelProxy : public QObject
|
||||
{
|
||||
Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct QmlOverviewEvent {
|
||||
int row;
|
||||
qint64 startTime;
|
||||
qint64 duration;
|
||||
double height;
|
||||
int eventId;
|
||||
int eventType;
|
||||
int bindingLoopHead;
|
||||
};
|
||||
|
||||
QmlProfilerOverviewModelProxy(QmlProfilerModelManager *modelManager, QObject *parent = 0);
|
||||
~QmlProfilerOverviewModelProxy();
|
||||
|
||||
const QVector<QmlOverviewEvent> getData() const;
|
||||
|
||||
void loadData();
|
||||
Q_INVOKABLE int count() const;
|
||||
Q_INVOKABLE qint64 traceStartTime() const;
|
||||
Q_INVOKABLE qint64 traceDuration() const;
|
||||
Q_INVOKABLE qint64 traceEndTime() const;
|
||||
Q_INVOKABLE qint64 getStartTime(int index) const;
|
||||
Q_INVOKABLE qint64 getDuration(int index) const;
|
||||
Q_INVOKABLE int getType(int index) const;
|
||||
Q_INVOKABLE int getEventId(int index) const;
|
||||
Q_INVOKABLE int getBindingLoopDest(int i) const;
|
||||
|
||||
void clear();
|
||||
|
||||
int rowCount() const;
|
||||
|
||||
|
||||
// QML interface
|
||||
bool isEmpty() const;
|
||||
|
||||
|
||||
signals:
|
||||
void countChanged();
|
||||
void dataAvailable();
|
||||
// void stateChanged();
|
||||
void emptyChanged();
|
||||
// void expandedChanged();
|
||||
|
||||
private slots:
|
||||
void dataChanged();
|
||||
|
||||
private:
|
||||
void detectBindingLoops();
|
||||
|
||||
private:
|
||||
class QmlProfilerOverviewModelProxyPrivate;
|
||||
QmlProfilerOverviewModelProxyPrivate *d;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -283,6 +283,13 @@ int PaintEventsModelProxy::getEventType(int index) const
|
||||
return (int)QmlDebug::Painting;
|
||||
}
|
||||
|
||||
int PaintEventsModelProxy::getEventCategory(int index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
// there is only one category, all events belong to it
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PaintEventsModelProxy::getEventRow(int index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
|
||||
@@ -90,6 +90,7 @@ public:
|
||||
int findLastIndex(qint64 endTime) const;
|
||||
|
||||
int getEventType(int index) const;
|
||||
Q_INVOKABLE int getEventCategory(int index) const;
|
||||
int getEventRow(int index) const;
|
||||
Q_INVOKABLE qint64 getDuration(int index) const;
|
||||
Q_INVOKABLE qint64 getStartTime(int index) const;
|
||||
|
||||
@@ -541,6 +541,15 @@ int BasicTimelineModel::getEventType(int index) const
|
||||
return d->eventDict[d->startTimeData[index].eventId].eventType;
|
||||
}
|
||||
|
||||
int BasicTimelineModel::getEventCategory(int index) const
|
||||
{
|
||||
int evTy = getEventType(index);
|
||||
// special: paint events shown?
|
||||
if (d->categorySpan[0].empty && !isEmpty())
|
||||
return evTy - 1;
|
||||
return evTy;
|
||||
}
|
||||
|
||||
int BasicTimelineModel::getEventRow(int index) const
|
||||
{
|
||||
if (d->categorySpan[getEventType(index)].expanded)
|
||||
|
||||
@@ -134,6 +134,7 @@ public:
|
||||
int findLastIndex(qint64 endTime) const;
|
||||
|
||||
int getEventType(int index) const;
|
||||
int getEventCategory(int index) const;
|
||||
int getEventRow(int index) const;
|
||||
Q_INVOKABLE qint64 getDuration(int index) const;
|
||||
Q_INVOKABLE qint64 getStartTime(int index) const;
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmlprofilertimelinemodelproxy.h"
|
||||
#include "timelinemodelaggregator.h"
|
||||
#include "qmlprofileroverviewmodelproxy.h"
|
||||
|
||||
// Needed for the load&save actions in the context menu
|
||||
#include <analyzerbase/ianalyzertool.h>
|
||||
@@ -123,9 +122,8 @@ public:
|
||||
QDeclarativeView *m_timebar;
|
||||
QDeclarativeView *m_overview;
|
||||
QmlProfilerModelManager *m_modelManager;
|
||||
// BasicTimelineModel *m_modelProxy;
|
||||
TimelineModelAggregator *m_modelProxy;
|
||||
QmlProfilerOverviewModelProxy *m_overviewProxy;
|
||||
|
||||
|
||||
ZoomControl *m_zoomControl;
|
||||
|
||||
@@ -189,14 +187,12 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
|
||||
d->m_modelManager = modelManager;
|
||||
d->m_modelProxy = new TimelineModelAggregator(this);
|
||||
d->m_modelProxy->setModelManager(modelManager);
|
||||
// d->m_modelProxy = new BasicTimelineModel(modelManager, this);
|
||||
d->m_overviewProxy = new QmlProfilerOverviewModelProxy(modelManager, this);
|
||||
connect(d->m_modelManager, SIGNAL(stateChanged()),
|
||||
this, SLOT(profilerDataModelStateChanged()));
|
||||
d->m_mainView->rootContext()->setContextProperty(QLatin1String("qmlProfilerModelProxy"),
|
||||
d->m_modelProxy);
|
||||
d->m_overview->rootContext()->setContextProperty(QLatin1String("qmlProfilerModelProxy"),
|
||||
d->m_overviewProxy);
|
||||
d->m_modelProxy);
|
||||
|
||||
d->m_profilerState = profilerState;
|
||||
connect(d->m_profilerState, SIGNAL(stateChanged()),
|
||||
|
||||
@@ -107,6 +107,17 @@ int TimelineModelAggregator::categories() const
|
||||
return categoryCount;
|
||||
}
|
||||
|
||||
int TimelineModelAggregator::visibleCategories() const
|
||||
{
|
||||
int categoryCount = 0;
|
||||
foreach (const AbstractTimelineModel *modelProxy, d->modelList) {
|
||||
for (int i = 0; i < modelProxy->categories(); i++)
|
||||
if (modelProxy->categoryDepth(i) > 0)
|
||||
categoryCount ++;
|
||||
}
|
||||
return categoryCount;
|
||||
}
|
||||
|
||||
QStringList TimelineModelAggregator::categoryTitles() const
|
||||
{
|
||||
QStringList retString;
|
||||
@@ -235,6 +246,11 @@ int TimelineModelAggregator::getEventType(int modelIndex, int index) const
|
||||
return d->modelList[modelIndex]->getEventType(index);
|
||||
}
|
||||
|
||||
int TimelineModelAggregator::getEventCategoryInModel(int modelIndex, int index) const
|
||||
{
|
||||
return d->modelList[modelIndex]->getEventCategory(index);
|
||||
}
|
||||
|
||||
int TimelineModelAggregator::getEventRow(int modelIndex, int index) const
|
||||
{
|
||||
return d->modelList[modelIndex]->getEventRow(index);
|
||||
@@ -270,6 +286,17 @@ QColor TimelineModelAggregator::getColor(int modelIndex, int index) const
|
||||
return d->modelList[modelIndex]->getColor(index);
|
||||
}
|
||||
|
||||
QVariantList TimelineModelAggregator::getColorRGB(int modelIndex, int itemIndex) const
|
||||
{
|
||||
// return color as RGB list, for use in Qml
|
||||
QColor c = getColor(modelIndex, itemIndex);
|
||||
QVariantList res;
|
||||
res.append(QVariant(c.red()));
|
||||
res.append(QVariant(c.green()));
|
||||
res.append(QVariant(c.blue()));
|
||||
return res;
|
||||
}
|
||||
|
||||
float TimelineModelAggregator::getHeight(int modelIndex, int index) const
|
||||
{
|
||||
return d->modelList[modelIndex]->getHeight(index);
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
|
||||
|
||||
Q_INVOKABLE int categories() const;
|
||||
Q_INVOKABLE int visibleCategories() const;
|
||||
Q_INVOKABLE QStringList categoryTitles() const;
|
||||
QString name() const;
|
||||
Q_INVOKABLE int count(int modelIndex = -1) const;
|
||||
@@ -78,6 +79,7 @@ public:
|
||||
int findLastIndex(int modelIndex, qint64 endTime) const;
|
||||
|
||||
int getEventType(int modelIndex, int index) const;
|
||||
Q_INVOKABLE int getEventCategoryInModel(int modelIndex, int index) const;
|
||||
int getEventRow(int modelIndex, int index) const;
|
||||
Q_INVOKABLE qint64 getDuration(int modelIndex, int index) const;
|
||||
Q_INVOKABLE qint64 getStartTime(int modelIndex, int index) const;
|
||||
@@ -85,6 +87,7 @@ public:
|
||||
Q_INVOKABLE int getEventId(int modelIndex, int index) const;
|
||||
Q_INVOKABLE int getBindingLoopDest(int modelIndex, int index) const;
|
||||
Q_INVOKABLE QColor getColor(int modelIndex, int index) const;
|
||||
Q_INVOKABLE QVariantList getColorRGB(int modelIndex, int itemIndex) const;
|
||||
Q_INVOKABLE float getHeight(int modelIndex, int index) const;
|
||||
|
||||
Q_INVOKABLE const QVariantList getLabelsForCategory(int modelIndex, int category) const;
|
||||
|
||||
@@ -203,6 +203,12 @@ int SceneGraphTimelineModel::getEventType(int index) const
|
||||
// return 0;
|
||||
}
|
||||
|
||||
int SceneGraphTimelineModel::getEventCategory(int index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SceneGraphTimelineModel::getEventRow(int index) const
|
||||
{
|
||||
return d->eventList[index].sgEventType + 1;
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
int findLastIndex(qint64 endTime) const;
|
||||
|
||||
int getEventType(int index) const;
|
||||
int getEventCategory(int index) const;
|
||||
int getEventRow(int index) const;
|
||||
Q_INVOKABLE qint64 getDuration(int index) const;
|
||||
Q_INVOKABLE qint64 getStartTime(int index) const;
|
||||
|
||||
Reference in New Issue
Block a user