Commit 4ff20dfa authored by Ulf Hermann's avatar Ulf Hermann

QmlProfiler: Move location lookup into base model

We will need it in a second derived model.

Change-Id: I5d2459c490034b592f643f248bf5be2e44af44aa
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
parent 185412ce
......@@ -242,17 +242,7 @@ QVariantMap QmlProfilerRangeModel::details(int index) const
QVariantMap QmlProfilerRangeModel::location(int index) const
{
QVariantMap result;
int id = selectionId(index);
const QmlDebug::QmlEventLocation &location
= modelManager()->qmlModel()->getEventTypes().at(id).location;
result.insert(QStringLiteral("file"), location.filename);
result.insert(QStringLiteral("line"), location.line);
result.insert(QStringLiteral("column"), location.column);
return result;
return locationFromTypeId(index);
}
int QmlProfilerRangeModel::typeId(int index) const
......
......@@ -127,4 +127,24 @@ int QmlProfilerTimelineModel::bindingLoopDest(int index) const
return -1;
}
QVariantMap QmlProfilerTimelineModel::locationFromTypeId(int index) const
{
QVariantMap result;
int id = typeId(index);
if (id < 0)
return result;
auto types = modelManager()->qmlModel()->getEventTypes();
if (id >= types.length())
return result;
const QmlDebug::QmlEventLocation &location = types.at(id).location;
result.insert(QStringLiteral("file"), location.filename);
result.insert(QStringLiteral("line"), location.line);
result.insert(QStringLiteral("column"), location.column);
return result;
}
}
......@@ -58,6 +58,7 @@ public:
virtual bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const;
bool handlesTypeId(int typeId) const;
Q_INVOKABLE virtual int bindingLoopDest(int index) const;
QVariantMap locationFromTypeId(int index) const;
virtual void loadData() = 0;
void clear();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment