Commit 0f3f3df3 authored by Ulf Hermann's avatar Ulf Hermann

QmlProfiler: Center trace view vertically around newly selected items

It's rather unintuitive if it only centers horizontally.

Change-Id: I9245da0b26fccc14a100804715d09aaa82059413
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 95a13d57
......@@ -141,6 +141,13 @@ Rectangle {
recenter((qmlProfilerModelProxy.startTime(modelIndex, itemIndex) +
qmlProfilerModelProxy.endTime(modelIndex, itemIndex)) / 2);
}
var row = qmlProfilerModelProxy.row(modelIndex, itemIndex);
var totalRowOffset = qmlProfilerModelProxy.modelOffset(modelIndex) +
qmlProfilerModelProxy.rowOffset(modelIndex, row);
if (totalRowOffset > flick.contentY + flick.height ||
totalRowOffset + qmlProfilerModelProxy.rowHeight(modelIndex, row) < flick.contentY)
flick.contentY = Math.min(flick.contentHeight - flick.height,
Math.max(0, totalRowOffset - flick.height / 2));
}
function hideRangeDetails() {
......
......@@ -65,10 +65,7 @@ TimelineModelAggregator::~TimelineModelAggregator()
int TimelineModelAggregator::height() const
{
int ret = 0;
for (int i = 0; i < d->modelList.length(); ++i)
ret += d->modelList[i]->height();
return ret;
return modelOffset(d->modelList.length());
}
void TimelineModelAggregator::setModelManager(QmlProfilerModelManager *modelManager)
......@@ -133,6 +130,14 @@ bool TimelineModelAggregator::isEmpty() const
return true;
}
int TimelineModelAggregator::modelOffset(int modelIndex) const
{
int ret = 0;
for (int i = 0; i < modelIndex; ++i)
ret += d->modelList[i]->height();
return ret;
}
int TimelineModelAggregator::rowHeight(int modelIndex, int row) const
{
return d->modelList[modelIndex]->rowHeight(row);
......
......@@ -61,6 +61,7 @@ public:
Q_INVOKABLE bool isEmpty() const;
Q_INVOKABLE int modelOffset(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;
......
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