forked from qt-creator/qt-creator
QmlProfiler: Move location lookup into base model
We will need it in a second derived model. Change-Id: I5d2459c490034b592f643f248bf5be2e44af44aa Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user