From 0464c87773cb0a23bd2a917fe481aec5b611aafe Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 11 Nov 2014 16:27:25 +0100 Subject: [PATCH] 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 --- src/plugins/qmlprofiler/qml/CategoryLabel.qml | 3 ++- src/plugins/qmlprofiler/qml/TimeMarks.qml | 2 ++ src/plugins/qmlprofiler/timelinemodel.cpp | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmlprofiler/qml/CategoryLabel.qml b/src/plugins/qmlprofiler/qml/CategoryLabel.qml index da26964af9f..75e3d2b02d9 100644 --- a/src/plugins/qmlprofiler/qml/CategoryLabel.qml +++ b/src/plugins/qmlprofiler/qml/CategoryLabel.qml @@ -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 diff --git a/src/plugins/qmlprofiler/qml/TimeMarks.qml b/src/plugins/qmlprofiler/qml/TimeMarks.qml index c3b6082fd7f..085bec2179d 100644 --- a/src/plugins/qmlprofiler/qml/TimeMarks.qml +++ b/src/plugins/qmlprofiler/qml/TimeMarks.qml @@ -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) diff --git a/src/plugins/qmlprofiler/timelinemodel.cpp b/src/plugins/qmlprofiler/timelinemodel.cpp index c00f56c7509..5d936de52e5 100644 --- a/src/plugins/qmlprofiler/timelinemodel.cpp +++ b/src/plugins/qmlprofiler/timelinemodel.cpp @@ -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; }