Commit 4481925b authored by Ulf Hermann's avatar Ulf Hermann

QmlProfiler: Fix next/previous selection in timeline

If we've changed the model index we don't reuse the item index for
selecting the next item. Also, there are two reasons why
firstIndexNoParents() can return -1. They have to be handled
differently.

Change-Id: Ib33e3bd0e96a39a71658a0e4509926012a91bf27
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 0f3f3df3
......@@ -585,20 +585,23 @@ void TimelineRenderer::selectPrev()
int TimelineRenderer::nextItemFromSelectionId(int modelIndex, int selectionId) const
{
int modelCount = m_profilerModelProxy->count(modelIndex);
if (modelCount == 0)
return -1;
int ndx = -1;
if (m_selectedItem == -1)
if (m_selectedItem == -1 || modelIndex != m_selectedModel)
ndx = m_profilerModelProxy->firstIndexNoParents(modelIndex, m_startTime);
else
ndx = m_selectedItem + 1;
if (ndx < 0)
return -1;
if (ndx >= m_profilerModelProxy->count(modelIndex))
if (ndx < 0 || ndx >= modelCount)
ndx = 0;
int startIndex = ndx;
do {
if (m_profilerModelProxy->selectionId(modelIndex, ndx) == selectionId)
return ndx;
ndx = (ndx + 1) % m_profilerModelProxy->count(modelIndex);
ndx = (ndx + 1) % modelCount;
} while (ndx != startIndex);
return -1;
}
......@@ -606,7 +609,7 @@ int TimelineRenderer::nextItemFromSelectionId(int modelIndex, int selectionId) c
int TimelineRenderer::prevItemFromSelectionId(int modelIndex, int selectionId) const
{
int ndx = -1;
if (m_selectedItem == -1)
if (m_selectedItem == -1 || modelIndex != m_selectedModel)
ndx = m_profilerModelProxy->firstIndexNoParents(modelIndex, m_startTime);
else
ndx = m_selectedItem - 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