forked from qt-creator/qt-creator
QmlProfiler: scroll automatically when selecting events out of view
Change-Id: I2f242895b00792d2e6930ec642209be886e22bad Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -127,6 +127,7 @@ public slots:
|
||||
void selectNextEvent(int eventId);
|
||||
void updateProfilerState();
|
||||
void updateToolTip(const QString &text);
|
||||
void updateVerticalScroll(int newPosition);
|
||||
|
||||
signals:
|
||||
void viewUpdated();
|
||||
|
||||
Reference in New Issue
Block a user