Commit b2487e16 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlProfiler: Introduce properties for timeline category heights



Like this we can easily refer to them from QML and it makes it simpler
to see if we mean the overall height or the height of a single category.

Change-Id: Ia2b79d99b5c46c3d9563cfc2ed0715bc352ce9b4
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 2919dc61
......@@ -38,6 +38,10 @@ AbstractTimelineModel::AbstractTimelineModel(AbstractTimelineModelPrivate *dd,
SortedTimelineModel(parent), d_ptr(dd)
{
Q_D(AbstractTimelineModel);
connect(this,SIGNAL(rowHeightChanged()),this,SIGNAL(heightChanged()));
connect(this,SIGNAL(expandedChanged()),this,SIGNAL(heightChanged()));
connect(this,SIGNAL(hiddenChanged()),this,SIGNAL(heightChanged()));
d->q_ptr = this;
d->modelId = 0;
d->modelManager = 0;
......
......@@ -46,6 +46,7 @@ class QMLPROFILER_EXPORT AbstractTimelineModel : public SortedTimelineModel
Q_PROPERTY(QString displayName READ displayName CONSTANT)
Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
Q_PROPERTY(bool hidden READ hidden WRITE setHidden NOTIFY hiddenChanged)
Q_PROPERTY(int height READ height NOTIFY heightChanged)
public:
class AbstractTimelineModelPrivate;
......@@ -96,6 +97,7 @@ signals:
void hiddenChanged();
void rowHeightChanged();
void emptyChanged();
void heightChanged();
protected:
static const int DefaultRowHeight = 30;
......
......@@ -56,7 +56,7 @@ Item {
visible: trigger(qmlProfilerModelProxy.rowCount(modelIndex)) > 0
height: trigger(qmlProfilerModelProxy.height(modelIndex))
height: trigger(qmlProfilerModelProxy.models[modelIndex].height)
width: 150
function updateDescriptions() {
......
......@@ -123,7 +123,7 @@ Canvas {
// separators
var cumulatedHeight = y < 0 ? -y : 0;
for (var modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); ++modelIndex) {
var modelHeight = qmlProfilerModelProxy.height(modelIndex);
var modelHeight = qmlProfilerModelProxy.models[modelIndex].height;
if (cumulatedHeight + modelHeight < y) {
cumulatedHeight += modelHeight;
if (qmlProfilerModelProxy.rowCount(modelIndex) % 2 !== 0)
......
......@@ -54,6 +54,8 @@ public:
TimelineModelAggregator::TimelineModelAggregator(QObject *parent)
: QObject(parent), d(new TimelineModelAggregatorPrivate(this))
{
connect(this,SIGNAL(modelsChanged(int,int)),this,SIGNAL(heightChanged()));
connect(this,SIGNAL(stateChanged()),this,SIGNAL(heightChanged()));
}
TimelineModelAggregator::~TimelineModelAggregator()
......@@ -61,6 +63,14 @@ TimelineModelAggregator::~TimelineModelAggregator()
delete d;
}
int TimelineModelAggregator::height() const
{
int ret = 0;
for (int i = 0; i < d->modelList.length(); ++i)
ret += d->modelList[i]->height();
return ret;
}
void TimelineModelAggregator::setModelManager(QmlProfilerModelManager *modelManager)
{
d->modelManager = modelManager;
......@@ -93,9 +103,15 @@ void TimelineModelAggregator::addModel(AbstractTimelineModel *m)
connect(m,SIGNAL(expandedChanged()),this,SIGNAL(expandedChanged()));
connect(m,SIGNAL(hiddenChanged()),this,SIGNAL(hiddenChanged()));
connect(m,SIGNAL(rowHeightChanged()),this,SIGNAL(rowHeightChanged()));
connect(m,SIGNAL(heightChanged()),this,SIGNAL(heightChanged()));
emit modelsChanged(d->modelList.length(), d->modelList.length());
}
const AbstractTimelineModel *TimelineModelAggregator::model(int modelIndex) const
{
return d->modelList[modelIndex];
}
QVariantList TimelineModelAggregator::models() const
{
QVariantList ret;
......@@ -125,11 +141,6 @@ bool TimelineModelAggregator::isEmpty() const
return true;
}
int TimelineModelAggregator::height(int modelIndex) const
{
return d->modelList[modelIndex]->height();
}
int TimelineModelAggregator::rowHeight(int modelIndex, int row) const
{
return d->modelList[modelIndex]->rowHeight(row);
......
......@@ -39,13 +39,16 @@ namespace Internal {
class TimelineModelAggregator : public QObject
{
Q_OBJECT
Q_PROPERTY(int height READ height NOTIFY heightChanged)
Q_PROPERTY(QVariantList models READ models NOTIFY modelsChanged)
public:
TimelineModelAggregator(QObject *parent = 0);
~TimelineModelAggregator();
int height() const;
void setModelManager(QmlProfilerModelManager *modelManager);
void addModel(AbstractTimelineModel *m);
const AbstractTimelineModel *model(int modelIndex) const;
QVariantList models() const;
Q_INVOKABLE int count(int modelIndex = -1) const;
......@@ -58,7 +61,6 @@ public:
bool isEmpty() const;
Q_INVOKABLE int height(int modelIndex) const;
Q_INVOKABLE int rowHeight(int modelIndex, int row) const;
Q_INVOKABLE void setRowHeight(int modelIndex, int row, int height);
Q_INVOKABLE int rowOffset(int modelIndex, int row) const;
......@@ -105,6 +107,7 @@ signals:
void hiddenChanged();
void rowHeightChanged();
void modelsChanged(int modelIndex1, int modelIndex2);
void heightChanged();
protected slots:
void dataChanged();
......
......@@ -167,7 +167,7 @@ void TimelineRenderer::drawItemsToPainter(QPainter *p, int modelIndex, int fromI
p->setPen(Qt::transparent);
int modelRowStart = 0;
for (int mi = 0; mi < modelIndex; mi++)
modelRowStart += m_profilerModelProxy->height(mi);
modelRowStart += m_profilerModelProxy->model(mi)->height();
for (int i = fromIndex; i <= toIndex; i++) {
int currentX, currentY, itemWidth, itemHeight;
......@@ -203,7 +203,7 @@ void TimelineRenderer::drawSelectionBoxes(QPainter *p, int modelIndex, int fromI
int modelRowStart = 0;
for (int mi = 0; mi < modelIndex; mi++)
modelRowStart += m_profilerModelProxy->height(mi);
modelRowStart += m_profilerModelProxy->model(mi)->height();
p->save();
......@@ -310,7 +310,7 @@ int TimelineRenderer::rowFromPosition(int y)
{
int ret = 0;
for (int modelIndex = 0; modelIndex < m_profilerModelProxy->modelCount(); modelIndex++) {
int modelHeight = m_profilerModelProxy->height(modelIndex);
int modelHeight = m_profilerModelProxy->model(modelIndex)->height();
if (y < modelHeight) {
for (int row = 0; row < m_profilerModelProxy->rowCount(modelIndex); ++row) {
y -= m_profilerModelProxy->rowHeight(modelIndex, row);
......@@ -328,7 +328,7 @@ int TimelineRenderer::rowFromPosition(int y)
int TimelineRenderer::modelFromPosition(int y)
{
for (int modelIndex = 0; modelIndex < m_profilerModelProxy->modelCount(); modelIndex++) {
y -= m_profilerModelProxy->height(modelIndex);
y -= m_profilerModelProxy->model(modelIndex)->height();
if (y < 0)
return modelIndex;
}
......@@ -469,7 +469,7 @@ int TimelineRenderer::getYPosition(int modelIndex, int index) const
int modelRowStart = 0;
for (int mi = 0; mi < modelIndex; mi++)
modelRowStart += m_profilerModelProxy->height(mi);
modelRowStart += m_profilerModelProxy->model(mi)->height();
return modelRowStart + m_profilerModelProxy->rowOffset(modelIndex,
m_profilerModelProxy->row(modelIndex, index));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment