From 3c094eeeb7249c77788cb995fbdc5ffbecc25bc8 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 22 Sep 2014 18:04:28 +0200 Subject: [PATCH] QmlProfiler: Make most of SortedTimelineModel protected We don't want anyone to insert stuff into the ranges without reflecting it in the actual data. Change-Id: Iaa8cc9a962216ba466da2c468826f6fbf6bef11c Reviewed-by: Kai Koehne --- src/plugins/qmlprofiler/sortedtimelinemodel.h | 59 ++++++++++--------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/plugins/qmlprofiler/sortedtimelinemodel.h b/src/plugins/qmlprofiler/sortedtimelinemodel.h index 1eb39f752f2..a5ec6ecbe91 100644 --- a/src/plugins/qmlprofiler/sortedtimelinemodel.h +++ b/src/plugins/qmlprofiler/sortedtimelinemodel.h @@ -61,10 +61,6 @@ public: inline qint64 timestamp() const {return end;} }; - SortedTimelineModel(QObject *parent = 0) : QObject(parent) {} - - void clear(); - inline int count() const { return ranges.count(); } qint64 duration(int index) const { return ranges[index].duration; } @@ -76,31 +72,6 @@ public: inline const Range &range(int index) const { return ranges[index]; } - inline int insert(qint64 startTime, qint64 duration, int typeId) - { - /* Doing insert-sort here is preferable as most of the time the times will actually be - * presorted in the right way. So usually this will just result in appending. */ - int index = insertSorted(ranges, Range(startTime, duration, typeId)); - if (index < ranges.size() - 1) - incrementStartIndices(index); - insertSorted(endTimes, RangeEnd(index, startTime + duration)); - return index; - } - - inline int insertStart(qint64 startTime, int typeId) - { - int index = insertSorted(ranges, Range(startTime, 0, typeId)); - if (index < ranges.size() - 1) - incrementStartIndices(index); - return index; - } - - inline void insertEnd(int index, qint64 duration) - { - ranges[index].duration = duration; - insertSorted(endTimes, RangeEnd(index, ranges[index].start + duration)); - } - inline int firstIndex(qint64 startTime) const { int index = firstIndexNoParents(startTime); @@ -137,6 +108,36 @@ public: } protected: + + SortedTimelineModel(QObject *parent = 0) : QObject(parent) {} + + void clear(); + + inline int insert(qint64 startTime, qint64 duration, int typeId) + { + /* Doing insert-sort here is preferable as most of the time the times will actually be + * presorted in the right way. So usually this will just result in appending. */ + int index = insertSorted(ranges, Range(startTime, duration, typeId)); + if (index < ranges.size() - 1) + incrementStartIndices(index); + insertSorted(endTimes, RangeEnd(index, startTime + duration)); + return index; + } + + inline int insertStart(qint64 startTime, int typeId) + { + int index = insertSorted(ranges, Range(startTime, 0, typeId)); + if (index < ranges.size() - 1) + incrementStartIndices(index); + return index; + } + + inline void insertEnd(int index, qint64 duration) + { + ranges[index].duration = duration; + insertSorted(endTimes, RangeEnd(index, ranges[index].start + duration)); + } + void computeNesting(); void incrementStartIndices(int index)