diff options
Diffstat (limited to 'plugins/qmlprofilerextended/pixmapcachemodel.cpp')
-rw-r--r-- | plugins/qmlprofilerextended/pixmapcachemodel.cpp | 93 |
1 files changed, 42 insertions, 51 deletions
diff --git a/plugins/qmlprofilerextended/pixmapcachemodel.cpp b/plugins/qmlprofilerextended/pixmapcachemodel.cpp index 1212089099..7ececbcb2c 100644 --- a/plugins/qmlprofilerextended/pixmapcachemodel.cpp +++ b/plugins/qmlprofilerextended/pixmapcachemodel.cpp @@ -103,6 +103,7 @@ qint64 PixmapCacheModel::lastTimeMark() const void PixmapCacheModel::setExpanded(int category, bool expanded) { + Q_UNUSED(category); d->isExpanded = expanded; } @@ -129,70 +130,59 @@ const QString PixmapCacheModel::categoryLabel(int categoryIndex) const int PixmapCacheModel::findFirstIndex(qint64 startTime) const { - // TODO properly - int candidate = -2; - for (int i=0; i < d->eventList.count(); i++) - if (d->eventList[i].startTime + d->eventList[i].duration > startTime) { - candidate = i; - break; - } - - if (candidate == -1) - return 0; - if (candidate == -2) - return d->eventList.count() - 1; - + int candidate = findFirstIndexNoParents(startTime); return candidate; } int PixmapCacheModel::findFirstIndexNoParents(qint64 startTime) const { - // TODO properly - return findFirstIndex(startTime); - -// int candidate = -1; -// // in the "endtime" list, find the first event that ends after startTime -// if (d->endTimeData.isEmpty()) -// return 0; // -1 -// if (d->endTimeData.count() == 1 || d->endTimeData.first().endTime >= startTime) -// candidate = 0; -// else -// if (d->endTimeData.last().endTime <= startTime) -// return 0; // -1 - -// if (candidate == -1) { -// int fromIndex = 0; -// int toIndex = d->endTimeData.count()-1; -// while (toIndex - fromIndex > 1) { -// int midIndex = (fromIndex + toIndex)/2; -// if (d->endTimeData[midIndex].endTime < startTime) -// fromIndex = midIndex; -// else -// toIndex = midIndex; -// } - -// candidate = toIndex; -// } - -// int ndx = d->endTimeData[candidate].startTimeIndex; - -// return ndx; + if (d->eventList.isEmpty()) + return -1; + if (d->eventList.count() == 1 || d->eventList.first().startTime+d->eventList.first().duration >= startTime) + return 0; + else + if (d->eventList.last().startTime+d->eventList.last().duration <= startTime) + return -1; + + int fromIndex = 0; + int toIndex = d->eventList.count()-1; + while (toIndex - fromIndex > 1) { + int midIndex = (fromIndex + toIndex)/2; + if (d->eventList[midIndex].startTime + d->eventList[midIndex].duration < startTime) + fromIndex = midIndex; + else + toIndex = midIndex; + } + return toIndex; } int PixmapCacheModel::findLastIndex(qint64 endTime) const { - // TODO properly - int candidate = 0; - for (int i = d->eventList.count()-1; i >= 0; i--) - if (d->eventList[i].startTime < endTime) { - candidate = i; - break; - } - return candidate; + if (d->eventList.isEmpty()) + return -1; + if (d->eventList.first().startTime >= endTime) + return -1; + if (d->eventList.count() == 1) + return 0; + if (d->eventList.last().startTime <= endTime) + return d->eventList.count()-1; + + int fromIndex = 0; + int toIndex = d->eventList.count()-1; + while (toIndex - fromIndex > 1) { + int midIndex = (fromIndex + toIndex)/2; + if (d->eventList[midIndex].startTime < endTime) + fromIndex = midIndex; + else + toIndex = midIndex; + } + + return fromIndex; } int PixmapCacheModel::getEventType(int index) const { + Q_UNUSED(index); return QmlDebug::PixmapCacheEvent; } @@ -263,6 +253,7 @@ QString getFilenameOnly(QString absUrl) const QVariantList PixmapCacheModel::getLabelsForCategory(int category) const { + Q_UNUSED(category); QVariantList result; if (d->isExpanded && !isEmpty()) { |