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