QmlProfiler: Remove template/virtual magic from SortedTimelineModel

We actually don't have to save the actual data in the
SortedTimelineModel if we keep the data synchronized to the ranges. This
is easy to do by just keeping track of the indices when new ranges are
inserted. Like that we can eliminate the virtual function calls from
AbstractTimelineModelPrivate and simplify the type hierarchy.

Change-Id: Ia7aa02df57380932b689ddfe9a50ff2031198a7d
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-07-08 17:18:51 +02:00
parent e91c79cb11
commit 18bf7113e0
7 changed files with 142 additions and 194 deletions

View File

@@ -35,7 +35,7 @@ namespace QmlProfiler {
AbstractTimelineModel::AbstractTimelineModel(AbstractTimelineModelPrivate *dd,
const QString &displayName, QmlDebug::Message message, QmlDebug::RangeType rangeType,
QObject *parent) :
QObject(parent), d_ptr(dd)
SortedTimelineModel(parent), d_ptr(dd)
{
Q_D(AbstractTimelineModel);
d->q_ptr = this;
@@ -61,48 +61,6 @@ void AbstractTimelineModel::setModelManager(QmlProfilerModelManager *modelManage
d->modelId = d->modelManager->registerModelProxy();
}
int AbstractTimelineModel::count() const
{
Q_D(const AbstractTimelineModel);
return d->count();
}
int AbstractTimelineModel::firstIndex(qint64 startTime) const
{
Q_D(const AbstractTimelineModel);
return d->firstIndex(startTime);
}
int AbstractTimelineModel::firstIndexNoParents(qint64 startTime) const
{
Q_D(const AbstractTimelineModel);
return d->firstIndexNoParents(startTime);
}
int AbstractTimelineModel::lastIndex(qint64 endTime) const
{
Q_D(const AbstractTimelineModel);
return d->lastIndex(endTime);
}
qint64 AbstractTimelineModel::duration(int index) const
{
Q_D(const AbstractTimelineModel);
return d->duration(index);
}
qint64 AbstractTimelineModel::startTime(int index) const
{
Q_D(const AbstractTimelineModel);
return d->startTime(index);
}
qint64 AbstractTimelineModel::endTime(int index) const
{
Q_D(const AbstractTimelineModel);
return d->startTime(index) + d->duration(index);
}
bool AbstractTimelineModel::isEmpty() const
{
return count() == 0;
@@ -241,8 +199,6 @@ void AbstractTimelineModel::dataChanged()
default:
break;
}
d->rowOffsets.clear();
}
bool AbstractTimelineModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const
@@ -272,4 +228,19 @@ QString AbstractTimelineModel::displayName() const
return d->displayName;
}
void AbstractTimelineModel::clear()
{
Q_D(AbstractTimelineModel);
bool wasExpanded = d->expanded;
bool hadRowHeights = !d->rowOffsets.empty();
d->rowOffsets.clear();
d->expanded = false;
SortedTimelineModel::clear();
if (hadRowHeights)
emit rowHeightChanged();
if (wasExpanded)
emit expandedChanged();
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
}
}