forked from qt-creator/qt-creator
QmlProfiler: Don't change row count if a model is hidden or empty
This reduces the complexity involved in making the row count a property. Empty models do have rows like this, but don't have a height. It doesn't get much more consistent than that. Before empty models didn't have rows but you could still query the row heights. Having height == 0 is very helpful for assembling the UI, rows == 0 not so much. Change-Id: I38ee9f46751a4beb288578d5cd1f0a17ea08814a Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
@@ -55,7 +55,8 @@ Item {
|
||||
|
||||
property bool reverseSelect: false
|
||||
|
||||
visible: trigger(qmlProfilerModelProxy.rowCount(modelIndex)) > 0
|
||||
visible: trigger(!qmlProfilerModelProxy.models[modelIndex].hidden &&
|
||||
!qmlProfilerModelProxy.models[modelIndex].empty)
|
||||
|
||||
height: trigger(qmlProfilerModelProxy.models[modelIndex].height)
|
||||
width: 150
|
||||
|
||||
@@ -125,6 +125,8 @@ Canvas {
|
||||
var cumulatedHeight = y < 0 ? -y : 0;
|
||||
for (var modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); ++modelIndex) {
|
||||
var modelHeight = qmlProfilerModelProxy.models[modelIndex].height;
|
||||
if (modelHeight === 0)
|
||||
continue;
|
||||
if (cumulatedHeight + modelHeight < y) {
|
||||
cumulatedHeight += modelHeight;
|
||||
if (qmlProfilerModelProxy.rowCount(modelIndex) % 2 !== 0)
|
||||
|
||||
@@ -218,6 +218,9 @@ void TimelineModel::setRowHeight(int rowNumber, int height)
|
||||
int TimelineModel::height() const
|
||||
{
|
||||
Q_D(const TimelineModel);
|
||||
if (d->hidden || isEmpty())
|
||||
return 0;
|
||||
|
||||
int depth = rowCount();
|
||||
if (d->hidden || !d->expanded || d->rowOffsets.empty())
|
||||
return depth * TimelineModelPrivate::DefaultRowHeight;
|
||||
@@ -466,8 +469,6 @@ QString TimelineModel::displayName() const
|
||||
int TimelineModel::rowCount() const
|
||||
{
|
||||
Q_D(const TimelineModel);
|
||||
if (d->hidden || isEmpty())
|
||||
return 0;
|
||||
return d->expanded ? d->expandedRowCount : d->collapsedRowCount;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user