Commit ae32a276 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlProfiler: Make sure that very narrow events can be hovered over



By giving the area the mouse "covers" a non-zero width events that last
only a very short time can be selected even if no pixel in the timeline
falls "into" them.

Task-number: QTCREATORBUG-11692
Change-Id: I53b74e2a770719872e0afc57740f7762636dc641
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 03fd61ff
......@@ -317,21 +317,23 @@ void TimelineRenderer::manageHovered(int mouseX, int mouseY)
if (m_endTime - m_startTime <=0 || m_lastEndTime - m_lastStartTime <= 0)
return;
qint64 time = mouseX * (m_endTime - m_startTime) / width() + m_startTime;
// Make the "selected" area 3 pixels wide by adding/subtracting 1 to catch very narrow events.
qint64 startTime = (mouseX - 1) * (m_endTime - m_startTime) / width() + m_startTime;
qint64 endTime = (mouseX + 1) * (m_endTime - m_startTime) / width() + m_startTime;
int row = (mouseY + y()) / DefaultRowHeight;
int modelIndex = modelFromPosition(mouseY + y());
// already covered? nothing to do
if (m_currentSelection.eventIndex != -1 &&
time >= m_currentSelection.startTime &&
time <= m_currentSelection.endTime &&
endTime >= m_currentSelection.startTime &&
startTime <= m_currentSelection.endTime &&
row == m_currentSelection.row) {
return;
}
// find if there's items in the time range
int eventFrom = m_profilerModelProxy->findFirstIndex(modelIndex, time);
int eventTo = m_profilerModelProxy->findLastIndex(modelIndex, time);
int eventFrom = m_profilerModelProxy->findFirstIndex(modelIndex, startTime);
int eventTo = m_profilerModelProxy->findLastIndex(modelIndex, endTime);
if (eventFrom == -1 ||
eventTo < eventFrom || eventTo >= m_profilerModelProxy->count()) {
m_currentSelection.eventIndex = -1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment