diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index a693b14452f..bf0fd6f6f6c 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -75,6 +75,7 @@ Rectangle { property variant selectionRangeEnd: selectionRange.startTime + selectionRange.duration signal changeToolTip(string text) + signal updateVerticalScroll(int newPosition) // ***** connections with external objects Connections { @@ -426,7 +427,7 @@ Rectangle { rangeDetails.visible = true; - // center view + // center view (horizontally) var windowLength = view.endTime - view.startTime; var eventStartTime = qmlEventList.getStartTime(selectedItem); var eventEndTime = eventStartTime + qmlEventList.getDuration(selectedItem); @@ -438,6 +439,15 @@ Rectangle { zoomControl.setRange(from, from + windowLength); } + + // center view (vertically) + var itemY = view.getYPosition(selectedItem); + if (itemY < root.scrollY) { + root.updateVerticalScroll(itemY); + } else + if (itemY + root.singleRowHeight > root.scrollY + root.candidateHeight) { + root.updateVerticalScroll(itemY + root.singleRowHeight - root.candidateHeight); + } } else { root.hideRangeDetails(); } diff --git a/src/plugins/qmlprofiler/timelineview.cpp b/src/plugins/qmlprofiler/timelineview.cpp index a9b9034cf38..7acffef45a9 100644 --- a/src/plugins/qmlprofiler/timelineview.cpp +++ b/src/plugins/qmlprofiler/timelineview.cpp @@ -347,6 +347,19 @@ QString TimelineView::getDetails(int index) const return m_eventList->getDetails(index); } +int TimelineView::getYPosition(int index) const +{ + Q_ASSERT(m_eventList); + if (index >= m_eventList->count()) + return 0; + int y, eventType = m_eventList->getType(index); + if (m_rowsExpanded[eventType]) + y = m_rowStarts[eventType] + DefaultRowHeight*(m_eventList->eventPosInType(index) + 1); + else + y = m_rowStarts[eventType] + DefaultRowHeight*m_eventList->getNestingLevel(index); + return y; +} + void TimelineView::setRowExpanded(int rowIndex, bool expanded) { m_rowsExpanded[rowIndex] = expanded; diff --git a/src/plugins/qmlprofiler/timelineview.h b/src/plugins/qmlprofiler/timelineview.h index 75d720e8593..9b04b6dc5bb 100644 --- a/src/plugins/qmlprofiler/timelineview.h +++ b/src/plugins/qmlprofiler/timelineview.h @@ -95,6 +95,7 @@ public: Q_INVOKABLE QString getFilename(int index) const; Q_INVOKABLE int getLine(int index) const; Q_INVOKABLE QString getDetails(int index) const; + Q_INVOKABLE int getYPosition(int index) const; Q_INVOKABLE void setRowExpanded(int rowIndex, bool expanded); diff --git a/src/plugins/qmlprofiler/tracewindow.cpp b/src/plugins/qmlprofiler/tracewindow.cpp index bc2ffed37f6..498a46c8f25 100644 --- a/src/plugins/qmlprofiler/tracewindow.cpp +++ b/src/plugins/qmlprofiler/tracewindow.cpp @@ -303,6 +303,7 @@ void TraceWindow::reset(QDeclarativeDebugConnection *conn) connect(this, SIGNAL(selectNextEventInDisplay(QVariant)), m_mainView->rootObject(), SLOT(selectNextWithId(QVariant))); connect(m_mainView->rootObject(), SIGNAL(selectedEventIdChanged(int)), this, SIGNAL(selectedEventIdChanged(int))); connect(m_mainView->rootObject(), SIGNAL(changeToolTip(QString)), this, SLOT(updateToolTip(QString))); + connect(m_mainView->rootObject(), SIGNAL(updateVerticalScroll(int)), this, SLOT(updateVerticalScroll(int))); connect(this, SIGNAL(internalClearDisplay()), m_mainView->rootObject(), SLOT(clearAll())); connect(this,SIGNAL(internalClearDisplay()), m_overview->rootObject(), SLOT(clearDisplay())); @@ -582,5 +583,10 @@ void TraceWindow::updateToolTip(const QString &text) setToolTip(text); } +void TraceWindow::updateVerticalScroll(int newPosition) +{ + m_mainView->verticalScrollBar()->setValue(newPosition); +} + } // namespace Internal } // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/tracewindow.h b/src/plugins/qmlprofiler/tracewindow.h index 2317b412551..4b0d9c7f140 100644 --- a/src/plugins/qmlprofiler/tracewindow.h +++ b/src/plugins/qmlprofiler/tracewindow.h @@ -127,6 +127,7 @@ public slots: void selectNextEvent(int eventId); void updateProfilerState(); void updateToolTip(const QString &text); + void updateVerticalScroll(int newPosition); signals: void viewUpdated();