diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index adf61d2325f..46bcfb4a045 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -218,6 +218,14 @@ Rectangle { zoomControl.setRange(newStart, newStart + windowLength); } + function recenterOnItem( itemIndex ) + { + // if item is outside of the view, jump back to its position + if (qmlEventList.getEndTime(itemIndex) < view.startTime || qmlEventList.getStartTime(itemIndex) > view.endTime) { + recenter((qmlEventList.getStartTime(itemIndex) + qmlEventList.getEndTime(itemIndex)) / 2); + } + } + function globalZoom() { zoomControl.setRange(qmlEventList.traceStartTime(), qmlEventList.traceEndTime()); } diff --git a/src/plugins/qmlprofiler/qml/RangeDetails.qml b/src/plugins/qmlprofiler/qml/RangeDetails.qml index 0b3b58d7f0e..b394081be2b 100644 --- a/src/plugins/qmlprofiler/qml/RangeDetails.qml +++ b/src/plugins/qmlprofiler/qml/RangeDetails.qml @@ -113,6 +113,7 @@ BorderImage { drag.target: parent onClicked: { root.gotoSourceLocation(file, line); + root.recenterOnItem(view.selectedItem); } }