Commit eef83495 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlProfiler: Pass model index to QML when selecting in trace view



This allows more precise specification of which event is supposed to be
selected.

Task-number: QTCREATORBUG-11945
Change-Id: Iff2e9bb8569711cc5df72a5ca55956e0091d6163
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 17febac8
......@@ -158,17 +158,16 @@ Rectangle {
rangeDetails.isBindingLoop = false;
}
function selectById(eventId)
function selectById(modelIndex, eventId)
{
if (eventId === -1 ||
eventId === qmlProfilerModelProxy.getEventId(view.selectedModel, view.selectedItem))
if (eventId === -1 || (modelIndex === view.selectedModel &&
eventId === qmlProfilerModelProxy.getEventId(modelIndex, view.selectedItem)))
return;
// this is a slot responding to events from the other pane
// which tracks only events from the basic model
if (!lockItemSelection) {
lockItemSelection = true;
var modelIndex = qmlProfilerModelProxy.basicModelIndex();
var itemIndex = view.nextItemFromId(modelIndex, eventId);
// select an item, lock to it, and recenter if necessary
view.selectFromId(modelIndex, itemIndex); // triggers recentering
......
......@@ -262,20 +262,34 @@ void QmlProfilerTraceView::clear()
void QmlProfilerTraceView::selectByHash(const QString &hash)
{
QQuickItem *rootObject = d->m_mainView->rootObject();
if (!rootObject)
return;
if (rootObject)
QMetaObject::invokeMethod(rootObject, "selectById",
Q_ARG(QVariant,QVariant(d->m_modelProxy->getEventIdForHash(hash))));
for (int modelIndex = 0; modelIndex < d->m_modelProxy->modelCount(); ++modelIndex) {
int eventId = d->m_modelProxy->getEventIdForHash(modelIndex, hash);
if (eventId != -1) {
QMetaObject::invokeMethod(rootObject, "selectById",
Q_ARG(QVariant,QVariant(modelIndex)),
Q_ARG(QVariant,QVariant(eventId)));
return;
}
}
}
void QmlProfilerTraceView::selectBySourceLocation(const QString &filename, int line, int column)
{
int eventId = d->m_modelProxy->getEventIdForLocation(filename, line, column);
QQuickItem *rootObject = d->m_mainView->rootObject();
if (!rootObject)
return;
if (eventId != -1) {
QQuickItem *rootObject = d->m_mainView->rootObject();
if (rootObject)
QMetaObject::invokeMethod(rootObject, "selectById", Q_ARG(QVariant,QVariant(eventId)));
for (int modelIndex = 0; modelIndex < d->m_modelProxy->modelCount(); ++modelIndex) {
int eventId = d->m_modelProxy->getEventIdForLocation(modelIndex, filename, line, column);
if (eventId != -1) {
QMetaObject::invokeMethod(rootObject, "selectById",
Q_ARG(QVariant,QVariant(modelIndex)),
Q_ARG(QVariant,QVariant(eventId)));
return;
}
}
}
......
......@@ -119,6 +119,7 @@ protected:
signals:
void gotoSourceLocation(const QString &fileUrl, int lineNumber, int columNumber);
void eventSelectedByHash(const QString &hash);
void resized();
private:
......
......@@ -47,7 +47,6 @@ public:
TimelineModelAggregator *q;
int basicModelIndex;
QList <AbstractTimelineModel *> modelList;
QmlProfilerModelManager *modelManager;
};
......@@ -81,9 +80,6 @@ void TimelineModelAggregator::setModelManager(QmlProfilerModelManager *modelMana
BasicTimelineModel *basicTimelineModel = new BasicTimelineModel(this);
basicTimelineModel->setModelManager(modelManager);
addModel(basicTimelineModel);
// the basic model is the last one here
d->basicModelIndex = d->modelList.count() - 1;
}
void TimelineModelAggregator::addModel(AbstractTimelineModel *m)
......@@ -149,11 +145,6 @@ bool TimelineModelAggregator::eventAccepted(const QmlProfilerDataModel::QmlEvent
return true;
}
int TimelineModelAggregator::basicModelIndex() const
{
return d->basicModelIndex;
}
qint64 TimelineModelAggregator::lastTimeMark() const
{
qint64 mark = -1;
......@@ -297,24 +288,15 @@ const QVariantMap TimelineModelAggregator::getEventLocation(int modelIndex, int
return d->modelList[modelIndex]->getEventLocation(index);
}
int TimelineModelAggregator::getEventIdForHash(const QString &hash) const
int TimelineModelAggregator::getEventIdForHash(int modelIndex, const QString &hash) const
{
foreach (const AbstractTimelineModel *model, d->modelList) {
int eventId = model->getEventIdForHash(hash);
if (eventId != -1)
return eventId;
}
return -1;
return d->modelList[modelIndex]->getEventIdForHash(hash);
}
int TimelineModelAggregator::getEventIdForLocation(const QString &filename, int line, int column) const
int TimelineModelAggregator::getEventIdForLocation(int modelIndex, const QString &filename,
int line, int column) const
{
foreach (const AbstractTimelineModel *model, d->modelList) {
int eventId = model->getEventIdForLocation(filename, line, column);
if (eventId != -1)
return eventId;
}
return -1;
return d->modelList[modelIndex]->getEventIdForLocation(filename, line, column);
}
void TimelineModelAggregator::dataChanged()
......
......@@ -63,8 +63,6 @@ public:
bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const;
Q_INVOKABLE int basicModelIndex() const;
Q_INVOKABLE qint64 lastTimeMark() const;
Q_INVOKABLE bool expanded(int modelIndex, int category) const;
......@@ -94,8 +92,9 @@ public:
Q_INVOKABLE const QVariantList getEventDetails(int modelIndex, int index) const;
Q_INVOKABLE const QVariantMap getEventLocation(int modelIndex, int index) const;
Q_INVOKABLE int getEventIdForHash(const QString &hash) const;
Q_INVOKABLE int getEventIdForLocation(const QString &filename, int line, int column) const;
Q_INVOKABLE int getEventIdForHash(int modelIndex, const QString &hash) const;
Q_INVOKABLE int getEventIdForLocation(int modelIndex, const QString &filename, int line,
int column) const;
Q_INVOKABLE int modelIndexForCategory(int absoluteCategoryIndex) const;
Q_INVOKABLE int correctedCategoryIndexForModel(int modelIndex, int absoluteCategoryIndex) const;
......
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