QmlProfiler: Centralize timeline rowCount calculation

Change-Id: I0db3641c0d6e750459d815e25909babf8534a4f6
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-09-11 10:57:34 +02:00
parent 69743fef93
commit 2e11197bca
7 changed files with 22 additions and 42 deletions

View File

@@ -45,6 +45,8 @@ AbstractTimelineModel::AbstractTimelineModel(AbstractTimelineModelPrivate *dd,
d->displayName = displayName;
d->message = message;
d->rangeType = rangeType;
d->expandedRowCount = 1;
d->collapsedRowCount = 1;
}
AbstractTimelineModel::~AbstractTimelineModel()
@@ -229,9 +231,18 @@ QString AbstractTimelineModel::displayName() const
return d->displayName;
}
int AbstractTimelineModel::rowCount() const
{
Q_D(const AbstractTimelineModel);
if (isEmpty())
return d->modelManager->isEmpty() ? 1 : 0;
return d->expanded ? d->expandedRowCount : d->collapsedRowCount;
}
void AbstractTimelineModel::clear()
{
Q_D(AbstractTimelineModel);
d->collapsedRowCount = d->expandedRowCount = 1;
bool wasExpanded = d->expanded;
bool hadRowHeights = !d->rowOffsets.empty();
d->rowOffsets.clear();