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:
Ulf Hermann
2014-11-11 16:27:25 +01:00
parent 7f7ebadae1
commit 0464c87773
3 changed files with 7 additions and 3 deletions

View File

@@ -55,7 +55,8 @@ Item {
property bool reverseSelect: false 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) height: trigger(qmlProfilerModelProxy.models[modelIndex].height)
width: 150 width: 150

View File

@@ -125,6 +125,8 @@ Canvas {
var cumulatedHeight = y < 0 ? -y : 0; var cumulatedHeight = y < 0 ? -y : 0;
for (var modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); ++modelIndex) { for (var modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); ++modelIndex) {
var modelHeight = qmlProfilerModelProxy.models[modelIndex].height; var modelHeight = qmlProfilerModelProxy.models[modelIndex].height;
if (modelHeight === 0)
continue;
if (cumulatedHeight + modelHeight < y) { if (cumulatedHeight + modelHeight < y) {
cumulatedHeight += modelHeight; cumulatedHeight += modelHeight;
if (qmlProfilerModelProxy.rowCount(modelIndex) % 2 !== 0) if (qmlProfilerModelProxy.rowCount(modelIndex) % 2 !== 0)

View File

@@ -218,6 +218,9 @@ void TimelineModel::setRowHeight(int rowNumber, int height)
int TimelineModel::height() const int TimelineModel::height() const
{ {
Q_D(const TimelineModel); Q_D(const TimelineModel);
if (d->hidden || isEmpty())
return 0;
int depth = rowCount(); int depth = rowCount();
if (d->hidden || !d->expanded || d->rowOffsets.empty()) if (d->hidden || !d->expanded || d->rowOffsets.empty())
return depth * TimelineModelPrivate::DefaultRowHeight; return depth * TimelineModelPrivate::DefaultRowHeight;
@@ -466,8 +469,6 @@ QString TimelineModel::displayName() const
int TimelineModel::rowCount() const int TimelineModel::rowCount() const
{ {
Q_D(const TimelineModel); Q_D(const TimelineModel);
if (d->hidden || isEmpty())
return 0;
return d->expanded ? d->expandedRowCount : d->collapsedRowCount; return d->expanded ? d->expandedRowCount : d->collapsedRowCount;
} }