QmlProfiler: Don't needlessly use AbstractTimelineModelPrivate

We can easily implement all specialized models with only the public
interface.

Change-Id: I2fc75ad4a4270d9dd40068e78f9364f3963805e0
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2014-10-28 10:57:32 +01:00
committed by Ulf Hermann
parent b2c8e70117
commit 936480316f
4 changed files with 96 additions and 147 deletions

View File

@@ -46,25 +46,11 @@
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
class QmlProfilerAnimationsModel::QmlProfilerAnimationsModelPrivate : public AbstractTimelineModelPrivate
{
public:
QVector<QmlProfilerAnimationsModel::QmlPaintEventData> data;
int maxGuiThreadAnimations;
int maxRenderThreadAnimations;
int rowFromThreadId(QmlDebug::AnimationThread threadId) const;
private:
Q_DECLARE_PUBLIC(QmlProfilerAnimationsModel)
};
QmlProfilerAnimationsModel::QmlProfilerAnimationsModel(QObject *parent) QmlProfilerAnimationsModel::QmlProfilerAnimationsModel(QObject *parent)
: AbstractTimelineModel(new QmlProfilerAnimationsModelPrivate, : AbstractTimelineModel(tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileAnimations)),
tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileAnimations)),
QmlDebug::Event, QmlDebug::MaximumRangeType, parent) QmlDebug::Event, QmlDebug::MaximumRangeType, parent)
{ {
Q_D(QmlProfilerAnimationsModel); m_maxGuiThreadAnimations = m_maxRenderThreadAnimations = 0;
d->maxGuiThreadAnimations = d->maxRenderThreadAnimations = 0;
} }
quint64 QmlProfilerAnimationsModel::features() const quint64 QmlProfilerAnimationsModel::features() const
@@ -74,9 +60,8 @@ quint64 QmlProfilerAnimationsModel::features() const
void QmlProfilerAnimationsModel::clear() void QmlProfilerAnimationsModel::clear()
{ {
Q_D(QmlProfilerAnimationsModel); m_maxGuiThreadAnimations = m_maxRenderThreadAnimations = 0;
d->maxGuiThreadAnimations = d->maxRenderThreadAnimations = 0; m_data.clear();
d->data.clear();
AbstractTimelineModel::clear(); AbstractTimelineModel::clear();
} }
@@ -88,9 +73,8 @@ bool QmlProfilerAnimationsModel::accepted(const QmlProfilerDataModel::QmlEventTy
void QmlProfilerAnimationsModel::loadData() void QmlProfilerAnimationsModel::loadData()
{ {
Q_D(QmlProfilerAnimationsModel);
clear(); clear();
QmlProfilerDataModel *simpleModel = d->modelManager->qmlModel(); QmlProfilerDataModel *simpleModel = modelManager()->qmlModel();
if (simpleModel->isEmpty()) if (simpleModel->isEmpty())
return; return;
@@ -127,49 +111,43 @@ void QmlProfilerAnimationsModel::loadData()
lastEvent.animationcount = (int)event.numericData2; lastEvent.animationcount = (int)event.numericData2;
QTC_ASSERT(lastEvent.animationcount > 0, continue); QTC_ASSERT(lastEvent.animationcount > 0, continue);
d->data.insert(insert(realStartTime, realEndTime - realStartTime, event.typeIndex), m_data.insert(insert(realStartTime, realEndTime - realStartTime, event.typeIndex), lastEvent);
lastEvent);
if (lastEvent.threadId == QmlDebug::GuiThread) if (lastEvent.threadId == QmlDebug::GuiThread)
d->maxGuiThreadAnimations = qMax(lastEvent.animationcount, d->maxGuiThreadAnimations); m_maxGuiThreadAnimations = qMax(lastEvent.animationcount, m_maxGuiThreadAnimations);
else else
d->maxRenderThreadAnimations = m_maxRenderThreadAnimations = qMax(lastEvent.animationcount, m_maxRenderThreadAnimations);
qMax(lastEvent.animationcount, d->maxRenderThreadAnimations);
minNextStartTimes[lastEvent.threadId] = event.startTime + 1; minNextStartTimes[lastEvent.threadId] = event.startTime + 1;
d->modelManager->modelProxyCountUpdated(d->modelId, count(), referenceList.count()); updateProgress(count(), referenceList.count());
} }
computeNesting(); computeNesting();
d->expandedRowCount = d->collapsedRowCount = setExpandedRowCount((m_maxGuiThreadAnimations == 0 || m_maxRenderThreadAnimations == 0) ? 2 : 3);
(d->maxGuiThreadAnimations == 0 || d->maxRenderThreadAnimations == 0) ? 2 : 3; setCollapsedRowCount(expandedRowCount());
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1); updateProgress(1, 1);
} }
/////////////////// QML interface /////////////////// QML interface
int QmlProfilerAnimationsModel::QmlProfilerAnimationsModelPrivate::rowFromThreadId( int QmlProfilerAnimationsModel::rowFromThreadId(QmlDebug::AnimationThread threadId) const
QmlDebug::AnimationThread threadId) const
{ {
return (threadId == QmlDebug::GuiThread || maxGuiThreadAnimations == 0) ? 1 : 2; return (threadId == QmlDebug::GuiThread || m_maxGuiThreadAnimations == 0) ? 1 : 2;
} }
int QmlProfilerAnimationsModel::row(int index) const int QmlProfilerAnimationsModel::row(int index) const
{ {
Q_D(const QmlProfilerAnimationsModel); return rowFromThreadId(m_data[index].threadId);
return d->rowFromThreadId(d->data[index].threadId);
} }
int QmlProfilerAnimationsModel::rowMaxValue(int rowNumber) const int QmlProfilerAnimationsModel::rowMaxValue(int rowNumber) const
{ {
Q_D(const QmlProfilerAnimationsModel);
switch (rowNumber) { switch (rowNumber) {
case 1: case 1:
return d->maxGuiThreadAnimations > 0 ? d->maxGuiThreadAnimations : return m_maxGuiThreadAnimations > 0 ? m_maxGuiThreadAnimations : m_maxRenderThreadAnimations;
d->maxRenderThreadAnimations;
case 2: case 2:
return d->maxRenderThreadAnimations; return m_maxRenderThreadAnimations;
default: default:
return AbstractTimelineModel::rowMaxValue(rowNumber); return AbstractTimelineModel::rowMaxValue(rowNumber);
} }
@@ -177,14 +155,12 @@ int QmlProfilerAnimationsModel::rowMaxValue(int rowNumber) const
int QmlProfilerAnimationsModel::selectionId(int index) const int QmlProfilerAnimationsModel::selectionId(int index) const
{ {
Q_D(const QmlProfilerAnimationsModel); return m_data[index].threadId;
return d->data[index].threadId;
} }
QColor QmlProfilerAnimationsModel::color(int index) const QColor QmlProfilerAnimationsModel::color(int index) const
{ {
Q_D(const QmlProfilerAnimationsModel); double fpsFraction = m_data[index].framerate / 60.0;
double fpsFraction = d->data[index].framerate / 60.0;
if (fpsFraction > 1.0) if (fpsFraction > 1.0)
fpsFraction = 1.0; fpsFraction = 1.0;
if (fpsFraction < 0.0) if (fpsFraction < 0.0)
@@ -194,25 +170,23 @@ QColor QmlProfilerAnimationsModel::color(int index) const
float QmlProfilerAnimationsModel::relativeHeight(int index) const float QmlProfilerAnimationsModel::relativeHeight(int index) const
{ {
Q_D(const QmlProfilerAnimationsModel); const QmlPaintEventData &data = m_data[index];
const QmlPaintEventData &data = d->data[index];
// Add some height to the events if we're far from the scale threshold of 2 * DefaultRowHeight. // Add some height to the events if we're far from the scale threshold of 2 * DefaultRowHeight.
// Like that you can see the smaller events more easily. // Like that you can see the smaller events more easily.
int scaleThreshold = 2 * defaultRowHeight() - rowHeight(d->rowFromThreadId(data.threadId)); int scaleThreshold = 2 * defaultRowHeight() - rowHeight(rowFromThreadId(data.threadId));
float boost = scaleThreshold > 0 ? (0.15 * scaleThreshold / defaultRowHeight()) : 0; float boost = scaleThreshold > 0 ? (0.15 * scaleThreshold / defaultRowHeight()) : 0;
return boost + (1.0 - boost) * (float)data.animationcount / return boost + (1.0 - boost) * (float)data.animationcount /
(float)(data.threadId == QmlDebug::GuiThread ? d->maxGuiThreadAnimations : (float)(data.threadId == QmlDebug::GuiThread ? m_maxGuiThreadAnimations :
d->maxRenderThreadAnimations); m_maxRenderThreadAnimations);
} }
QVariantList QmlProfilerAnimationsModel::labels() const QVariantList QmlProfilerAnimationsModel::labels() const
{ {
Q_D(const QmlProfilerAnimationsModel);
QVariantList result; QVariantList result;
if (!d->hidden && d->maxGuiThreadAnimations > 0) { if (!hidden() && m_maxGuiThreadAnimations > 0) {
QVariantMap element; QVariantMap element;
element.insert(QLatin1String("displayName"), QVariant(tr("Animations"))); element.insert(QLatin1String("displayName"), QVariant(tr("Animations")));
element.insert(QLatin1String("description"), QVariant(tr("GUI Thread"))); element.insert(QLatin1String("description"), QVariant(tr("GUI Thread")));
@@ -220,7 +194,7 @@ QVariantList QmlProfilerAnimationsModel::labels() const
result << element; result << element;
} }
if (!d->hidden && d->maxRenderThreadAnimations > 0) { if (!hidden() && m_maxRenderThreadAnimations > 0) {
QVariantMap element; QVariantMap element;
element.insert(QLatin1String("displayName"), QVariant(tr("Animations"))); element.insert(QLatin1String("displayName"), QVariant(tr("Animations")));
element.insert(QLatin1String("description"), QVariant(tr("Render Thread"))); element.insert(QLatin1String("description"), QVariant(tr("Render Thread")));
@@ -233,14 +207,13 @@ QVariantList QmlProfilerAnimationsModel::labels() const
QVariantMap QmlProfilerAnimationsModel::details(int index) const QVariantMap QmlProfilerAnimationsModel::details(int index) const
{ {
Q_D(const QmlProfilerAnimationsModel);
QVariantMap result; QVariantMap result;
result.insert(QStringLiteral("displayName"), displayName()); result.insert(QStringLiteral("displayName"), displayName());
result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(duration(index))); result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(duration(index)));
result.insert(tr("Framerate"), QString::fromLatin1("%1 FPS").arg(d->data[index].framerate)); result.insert(tr("Framerate"), QString::fromLatin1("%1 FPS").arg(m_data[index].framerate));
result.insert(tr("Animations"), QString::fromLatin1("%1").arg(d->data[index].animationcount)); result.insert(tr("Animations"), QString::fromLatin1("%1").arg(m_data[index].animationcount));
result.insert(tr("Context"), tr(d->data[index].threadId == QmlDebug::GuiThread ? result.insert(tr("Context"), tr(m_data[index].threadId == QmlDebug::GuiThread ?
"GUI Thread" : "Render Thread")); "GUI Thread" : "Render Thread"));
return result; return result;
} }

View File

@@ -81,8 +81,10 @@ protected:
void clear(); void clear();
private: private:
class QmlProfilerAnimationsModelPrivate; QVector<QmlProfilerAnimationsModel::QmlPaintEventData> m_data;
Q_DECLARE_PRIVATE(QmlProfilerAnimationsModel) int m_maxGuiThreadAnimations;
int m_maxRenderThreadAnimations;
int rowFromThreadId(QmlDebug::AnimationThread threadId) const;
}; };
} }

View File

@@ -31,7 +31,6 @@
#include "qmlprofilerrangemodel.h" #include "qmlprofilerrangemodel.h"
#include "qmlprofilermodelmanager.h" #include "qmlprofilermodelmanager.h"
#include "qmlprofilerdatamodel.h" #include "qmlprofilerdatamodel.h"
#include "abstracttimelinemodel_p.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QVector> #include <QVector>
@@ -45,48 +44,30 @@
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
class QmlProfilerRangeModel::QmlProfilerRangeModelPrivate : public AbstractTimelineModelPrivate
{
public:
// convenience functions
void computeNestingContracted();
void computeExpandedLevels();
void findBindingLoops();
QVector<QmlRangeEventStartInstance> data;
QVector<int> expandedRowTypes;
private:
Q_DECLARE_PUBLIC(QmlProfilerRangeModel)
};
QmlProfilerRangeModel::QmlProfilerRangeModel(QmlDebug::RangeType rangeType, QObject *parent) QmlProfilerRangeModel::QmlProfilerRangeModel(QmlDebug::RangeType rangeType, QObject *parent)
: AbstractTimelineModel(new QmlProfilerRangeModelPrivate, categoryLabel(rangeType), : AbstractTimelineModel(categoryLabel(rangeType), QmlDebug::MaximumMessage, rangeType, parent)
QmlDebug::MaximumMessage, rangeType, parent)
{ {
Q_D(QmlProfilerRangeModel); m_expandedRowTypes << -1;
d->expandedRowTypes << -1;
} }
quint64 QmlProfilerRangeModel::features() const quint64 QmlProfilerRangeModel::features() const
{ {
Q_D(const QmlProfilerRangeModel); return 1ULL << QmlDebug::featureFromRangeType(rangeType());
return 1ULL << QmlDebug::featureFromRangeType(d->rangeType);
} }
void QmlProfilerRangeModel::clear() void QmlProfilerRangeModel::clear()
{ {
Q_D(QmlProfilerRangeModel); m_expandedRowTypes.clear();
d->expandedRowTypes.clear(); m_expandedRowTypes << -1;
d->expandedRowTypes << -1; m_data.clear();
d->data.clear();
AbstractTimelineModel::clear(); AbstractTimelineModel::clear();
} }
void QmlProfilerRangeModel::loadData() void QmlProfilerRangeModel::loadData()
{ {
Q_D(QmlProfilerRangeModel);
clear(); clear();
QmlProfilerDataModel *simpleModel = d->modelManager->qmlModel(); QmlProfilerDataModel *simpleModel = modelManager()->qmlModel();
if (simpleModel->isEmpty()) if (simpleModel->isEmpty())
return; return;
@@ -99,46 +80,45 @@ void QmlProfilerRangeModel::loadData()
continue; continue;
// store starttime-based instance // store starttime-based instance
d->data.insert(insert(event.startTime, event.duration, event.typeIndex), m_data.insert(insert(event.startTime, event.duration, event.typeIndex),
QmlRangeEventStartInstance()); QmlRangeEventStartInstance());
d->modelManager->modelProxyCountUpdated(d->modelId, count(), eventList.count() * 6); updateProgress(count(), eventList.count() * 6);
} }
d->modelManager->modelProxyCountUpdated(d->modelId, 2, 6); updateProgress(2, 6);
// compute range nesting // compute range nesting
computeNesting(); computeNesting();
// compute nestingLevel - nonexpanded // compute nestingLevel - nonexpanded
d->computeNestingContracted(); computeNestingContracted();
d->modelManager->modelProxyCountUpdated(d->modelId, 3, 6); updateProgress(3, 6);
// compute nestingLevel - expanded // compute nestingLevel - expanded
d->computeExpandedLevels(); computeExpandedLevels();
d->modelManager->modelProxyCountUpdated(d->modelId, 4, 6); updateProgress(4, 6);
d->findBindingLoops(); findBindingLoops();
d->modelManager->modelProxyCountUpdated(d->modelId, 5, 6); updateProgress(5, 6);
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1); updateProgress(1, 1);
} }
void QmlProfilerRangeModel::QmlProfilerRangeModelPrivate::computeNestingContracted() void QmlProfilerRangeModel::computeNestingContracted()
{ {
Q_Q(QmlProfilerRangeModel);
int i; int i;
int eventCount = q->count(); int eventCount = count();
int nestingLevels = QmlDebug::Constants::QML_MIN_LEVEL; int nestingLevels = QmlDebug::Constants::QML_MIN_LEVEL;
collapsedRowCount = nestingLevels + 1; int collapsedRowCount = nestingLevels + 1;
QVector<qint64> nestingEndTimes; QVector<qint64> nestingEndTimes;
nestingEndTimes.fill(0, nestingLevels + 1); nestingEndTimes.fill(0, nestingLevels + 1);
for (i = 0; i < eventCount; i++) { for (i = 0; i < eventCount; i++) {
qint64 st = ranges[i].start; qint64 st = startTime(i);
// per type // per type
if (nestingEndTimes[nestingLevels] > st) { if (nestingEndTimes[nestingLevels] > st) {
@@ -151,56 +131,53 @@ void QmlProfilerRangeModel::QmlProfilerRangeModelPrivate::computeNestingContract
nestingEndTimes[nestingLevels-1] <= st) nestingEndTimes[nestingLevels-1] <= st)
nestingLevels--; nestingLevels--;
} }
nestingEndTimes[nestingLevels] = st + ranges[i].duration; nestingEndTimes[nestingLevels] = st + duration(i);
data[i].displayRowCollapsed = nestingLevels; m_data[i].displayRowCollapsed = nestingLevels;
} }
setCollapsedRowCount(collapsedRowCount);
} }
void QmlProfilerRangeModel::QmlProfilerRangeModelPrivate::computeExpandedLevels() void QmlProfilerRangeModel::computeExpandedLevels()
{ {
Q_Q(QmlProfilerRangeModel);
QHash<int, int> eventRow; QHash<int, int> eventRow;
int eventCount = q->count(); int eventCount = count();
for (int i = 0; i < eventCount; i++) { for (int i = 0; i < eventCount; i++) {
int typeId = ranges[i].typeId; int eventTypeId = typeId(i);
if (!eventRow.contains(typeId)) { if (!eventRow.contains(eventTypeId)) {
eventRow[typeId] = expandedRowTypes.size(); eventRow[eventTypeId] = m_expandedRowTypes.size();
expandedRowTypes << typeId; m_expandedRowTypes << eventTypeId;
} }
data[i].displayRowExpanded = eventRow[typeId]; m_data[i].displayRowExpanded = eventRow[eventTypeId];
} }
expandedRowCount = expandedRowTypes.size(); setExpandedRowCount(m_expandedRowTypes.size());
} }
void QmlProfilerRangeModel::QmlProfilerRangeModelPrivate::findBindingLoops() void QmlProfilerRangeModel::findBindingLoops()
{ {
Q_Q(QmlProfilerRangeModel); if (rangeType() != QmlDebug::Binding && rangeType() != QmlDebug::HandlingSignal)
if (rangeType != QmlDebug::Binding && rangeType != QmlDebug::HandlingSignal)
return; return;
typedef QPair<int, int> CallStackEntry; typedef QPair<int, int> CallStackEntry;
QStack<CallStackEntry> callStack; QStack<CallStackEntry> callStack;
for (int i = 0; i < q->count(); ++i) { for (int i = 0; i < count(); ++i) {
const Range *potentialParent = callStack.isEmpty() int potentialParent = callStack.isEmpty() ? -1 : callStack.top().second;
? 0 : &ranges[callStack.top().second];
while (potentialParent while (potentialParent != -1 && !(endTime(potentialParent) > startTime(i))) {
&& !(potentialParent->start + potentialParent->duration > ranges[i].start)) {
callStack.pop(); callStack.pop();
potentialParent = callStack.isEmpty() ? 0 : &ranges[callStack.top().second]; potentialParent = callStack.isEmpty() ? -1 : callStack.top().second;
} }
// check whether event is already in stack // check whether event is already in stack
for (int ii = 0; ii < callStack.size(); ++ii) { for (int ii = 0; ii < callStack.size(); ++ii) {
if (callStack.at(ii).first == ranges[i].typeId) { if (callStack.at(ii).first == typeId(i)) {
data[i].bindingLoopHead = callStack.at(ii).second; m_data[i].bindingLoopHead = callStack.at(ii).second;
break; break;
} }
} }
CallStackEntry newEntry(ranges[i].typeId, i); CallStackEntry newEntry(typeId(i), i);
callStack.push(newEntry); callStack.push(newEntry);
} }
@@ -216,17 +193,15 @@ QString QmlProfilerRangeModel::categoryLabel(QmlDebug::RangeType rangeType)
int QmlProfilerRangeModel::row(int index) const int QmlProfilerRangeModel::row(int index) const
{ {
Q_D(const QmlProfilerRangeModel); if (expanded())
if (d->expanded) return m_data[index].displayRowExpanded;
return d->data[index].displayRowExpanded;
else else
return d->data[index].displayRowCollapsed; return m_data[index].displayRowCollapsed;
} }
int QmlProfilerRangeModel::bindingLoopDest(int index) const int QmlProfilerRangeModel::bindingLoopDest(int index) const
{ {
Q_D(const QmlProfilerRangeModel); return m_data[index].bindingLoopHead;
return d->data[index].bindingLoopHead;
} }
QColor QmlProfilerRangeModel::color(int index) const QColor QmlProfilerRangeModel::color(int index) const
@@ -236,15 +211,14 @@ QColor QmlProfilerRangeModel::color(int index) const
QVariantList QmlProfilerRangeModel::labels() const QVariantList QmlProfilerRangeModel::labels() const
{ {
Q_D(const QmlProfilerRangeModel);
QVariantList result; QVariantList result;
if (d->expanded && !d->hidden) { if (expanded() && !hidden()) {
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
d->modelManager->qmlModel()->getEventTypes(); modelManager()->qmlModel()->getEventTypes();
for (int i = 1; i < d->expandedRowCount; i++) { // Ignore the -1 for the first row for (int i = 1; i < expandedRowCount(); i++) { // Ignore the -1 for the first row
QVariantMap element; QVariantMap element;
int typeId = d->expandedRowTypes[i]; int typeId = m_expandedRowTypes[i];
element.insert(QLatin1String("displayName"), QVariant(types[typeId].displayName)); element.insert(QLatin1String("displayName"), QVariant(types[typeId].displayName));
element.insert(QLatin1String("description"), QVariant(types[typeId].data)); element.insert(QLatin1String("description"), QVariant(types[typeId].data));
element.insert(QLatin1String("id"), QVariant(typeId)); element.insert(QLatin1String("id"), QVariant(typeId));
@@ -257,13 +231,12 @@ QVariantList QmlProfilerRangeModel::labels() const
QVariantMap QmlProfilerRangeModel::details(int index) const QVariantMap QmlProfilerRangeModel::details(int index) const
{ {
Q_D(const QmlProfilerRangeModel);
QVariantMap result; QVariantMap result;
int id = selectionId(index); int id = selectionId(index);
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
d->modelManager->qmlModel()->getEventTypes(); modelManager()->qmlModel()->getEventTypes();
result.insert(QStringLiteral("displayName"), categoryLabel(d->rangeType)); result.insert(QStringLiteral("displayName"), categoryLabel(rangeType()));
result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(duration(index))); result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(duration(index)));
result.insert(tr("Details"), types[id].data); result.insert(tr("Details"), types[id].data);
@@ -273,12 +246,11 @@ QVariantMap QmlProfilerRangeModel::details(int index) const
QVariantMap QmlProfilerRangeModel::location(int index) const QVariantMap QmlProfilerRangeModel::location(int index) const
{ {
Q_D(const QmlProfilerRangeModel);
QVariantMap result; QVariantMap result;
int id = selectionId(index); int id = selectionId(index);
const QmlDebug::QmlEventLocation &location const QmlDebug::QmlEventLocation &location
= d->modelManager->qmlModel()->getEventTypes().at(id).location; = modelManager()->qmlModel()->getEventTypes().at(id).location;
result.insert(QStringLiteral("file"), location.filename); result.insert(QStringLiteral("file"), location.filename);
result.insert(QStringLiteral("line"), location.line); result.insert(QStringLiteral("line"), location.line);
@@ -289,24 +261,22 @@ QVariantMap QmlProfilerRangeModel::location(int index) const
bool QmlProfilerRangeModel::isSelectionIdValid(int typeId) const bool QmlProfilerRangeModel::isSelectionIdValid(int typeId) const
{ {
Q_D(const QmlProfilerRangeModel);
if (typeId < 0) if (typeId < 0)
return false; return false;
const QmlProfilerDataModel::QmlEventTypeData &type = const QmlProfilerDataModel::QmlEventTypeData &type =
d->modelManager->qmlModel()->getEventTypes().at(typeId); modelManager()->qmlModel()->getEventTypes().at(typeId);
if (type.message != d->message || type.rangeType != d->rangeType) if (type.message != message() || type.rangeType != rangeType())
return false; return false;
return true; return true;
} }
int QmlProfilerRangeModel::selectionIdForLocation(const QString &filename, int line, int column) const int QmlProfilerRangeModel::selectionIdForLocation(const QString &filename, int line, int column) const
{ {
Q_D(const QmlProfilerRangeModel);
// if this is called from v8 view, we don't have the column number, it will be -1 // if this is called from v8 view, we don't have the column number, it will be -1
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
d->modelManager->qmlModel()->getEventTypes(); modelManager()->qmlModel()->getEventTypes();
for (int i = 1; i < d->expandedRowCount; ++i) { for (int i = 1; i < expandedRowCount(); ++i) {
int typeId = d->expandedRowTypes[i]; int typeId = m_expandedRowTypes[i];
const QmlProfilerDataModel::QmlEventTypeData &eventData = types[typeId]; const QmlProfilerDataModel::QmlEventTypeData &eventData = types[typeId];
if (eventData.location.filename == filename && if (eventData.location.filename == filename &&
eventData.location.line == line && eventData.location.line == line &&

View File

@@ -82,8 +82,12 @@ protected:
void clear(); void clear();
private: private:
class QmlProfilerRangeModelPrivate; void computeNestingContracted();
Q_DECLARE_PRIVATE(QmlProfilerRangeModel) void computeExpandedLevels();
void findBindingLoops();
QVector<QmlRangeEventStartInstance> m_data;
QVector<int> m_expandedRowTypes;
}; };
} }