forked from qt-creator/qt-creator
QmlProfiler: Center trace view vertically around newly selected items
It's rather unintuitive if it only centers horizontally. Change-Id: I9245da0b26fccc14a100804715d09aaa82059413 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -141,6 +141,13 @@ Rectangle {
|
|||||||
recenter((qmlProfilerModelProxy.startTime(modelIndex, itemIndex) +
|
recenter((qmlProfilerModelProxy.startTime(modelIndex, itemIndex) +
|
||||||
qmlProfilerModelProxy.endTime(modelIndex, itemIndex)) / 2);
|
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() {
|
function hideRangeDetails() {
|
||||||
|
|||||||
@@ -65,10 +65,7 @@ TimelineModelAggregator::~TimelineModelAggregator()
|
|||||||
|
|
||||||
int TimelineModelAggregator::height() const
|
int TimelineModelAggregator::height() const
|
||||||
{
|
{
|
||||||
int ret = 0;
|
return modelOffset(d->modelList.length());
|
||||||
for (int i = 0; i < d->modelList.length(); ++i)
|
|
||||||
ret += d->modelList[i]->height();
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineModelAggregator::setModelManager(QmlProfilerModelManager *modelManager)
|
void TimelineModelAggregator::setModelManager(QmlProfilerModelManager *modelManager)
|
||||||
@@ -133,6 +130,14 @@ bool TimelineModelAggregator::isEmpty() const
|
|||||||
return true;
|
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
|
int TimelineModelAggregator::rowHeight(int modelIndex, int row) const
|
||||||
{
|
{
|
||||||
return d->modelList[modelIndex]->rowHeight(row);
|
return d->modelList[modelIndex]->rowHeight(row);
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE bool isEmpty() const;
|
Q_INVOKABLE bool isEmpty() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE int modelOffset(int modelIndex) const;
|
||||||
Q_INVOKABLE int rowHeight(int modelIndex, int row) const;
|
Q_INVOKABLE int rowHeight(int modelIndex, int row) const;
|
||||||
Q_INVOKABLE void setRowHeight(int modelIndex, int row, int height);
|
Q_INVOKABLE void setRowHeight(int modelIndex, int row, int height);
|
||||||
Q_INVOKABLE int rowOffset(int modelIndex, int row) const;
|
Q_INVOKABLE int rowOffset(int modelIndex, int row) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user