From 24c990475a81b4b511d01402fe05c9ff681c81b4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 29 Sep 2014 18:20:26 +0200 Subject: [PATCH] QmlProfiler: Prefer events with notes when propagating selections If you click on a row with a note in the timeline you probably want to see the place with the note, not some other occurrence of the event type. Change-Id: Ic94514e460a33dbadca5cfed0b1455a1718b6d03 Reviewed-by: Kai Koehne --- src/plugins/qmlprofiler/qml/MainView.qml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index 9b10afba9b5..0ee8d4e6857 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -161,7 +161,19 @@ Rectangle { // which tracks only events from the basic model if (!lockItemSelection) { lockItemSelection = true; - var itemIndex = view.nextItemFromSelectionId(modelIndex, selectionId); + var itemIndex = -1; + var notes = qmlProfilerModelProxy.notesByTypeId(selectionId); + if (notes.length !== 0) { + itemIndex = qmlProfilerModelProxy.noteTimelineIndex(notes[0]); + // for some models typeId != selectionId. In that case we cannot select the noted + // events. This is purely theoretical as their data doesn't show up in the events + // view so that we cannot receive a selection event for them. + if (qmlProfilerModelProxy.typeId(modelIndex, itemIndex) !== selectionId) + itemIndex = -1; + } + + if (itemIndex === -1) + itemIndex = view.nextItemFromSelectionId(modelIndex, selectionId); // select an item, lock to it, and recenter if necessary view.selectFromEventIndex(modelIndex, itemIndex); // triggers recentering if (itemIndex !== -1)