forked from qt-creator/qt-creator
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: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -585,20 +585,23 @@ void TimelineRenderer::selectPrev()
|
|||||||
|
|
||||||
int TimelineRenderer::nextItemFromSelectionId(int modelIndex, int selectionId) const
|
int TimelineRenderer::nextItemFromSelectionId(int modelIndex, int selectionId) const
|
||||||
{
|
{
|
||||||
|
int modelCount = m_profilerModelProxy->count(modelIndex);
|
||||||
|
if (modelCount == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
int ndx = -1;
|
int ndx = -1;
|
||||||
if (m_selectedItem == -1)
|
if (m_selectedItem == -1 || modelIndex != m_selectedModel)
|
||||||
ndx = m_profilerModelProxy->firstIndexNoParents(modelIndex, m_startTime);
|
ndx = m_profilerModelProxy->firstIndexNoParents(modelIndex, m_startTime);
|
||||||
else
|
else
|
||||||
ndx = m_selectedItem + 1;
|
ndx = m_selectedItem + 1;
|
||||||
if (ndx < 0)
|
|
||||||
return -1;
|
if (ndx < 0 || ndx >= modelCount)
|
||||||
if (ndx >= m_profilerModelProxy->count(modelIndex))
|
|
||||||
ndx = 0;
|
ndx = 0;
|
||||||
int startIndex = ndx;
|
int startIndex = ndx;
|
||||||
do {
|
do {
|
||||||
if (m_profilerModelProxy->selectionId(modelIndex, ndx) == selectionId)
|
if (m_profilerModelProxy->selectionId(modelIndex, ndx) == selectionId)
|
||||||
return ndx;
|
return ndx;
|
||||||
ndx = (ndx + 1) % m_profilerModelProxy->count(modelIndex);
|
ndx = (ndx + 1) % modelCount;
|
||||||
} while (ndx != startIndex);
|
} while (ndx != startIndex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -606,7 +609,7 @@ int TimelineRenderer::nextItemFromSelectionId(int modelIndex, int selectionId) c
|
|||||||
int TimelineRenderer::prevItemFromSelectionId(int modelIndex, int selectionId) const
|
int TimelineRenderer::prevItemFromSelectionId(int modelIndex, int selectionId) const
|
||||||
{
|
{
|
||||||
int ndx = -1;
|
int ndx = -1;
|
||||||
if (m_selectedItem == -1)
|
if (m_selectedItem == -1 || modelIndex != m_selectedModel)
|
||||||
ndx = m_profilerModelProxy->firstIndexNoParents(modelIndex, m_startTime);
|
ndx = m_profilerModelProxy->firstIndexNoParents(modelIndex, m_startTime);
|
||||||
else
|
else
|
||||||
ndx = m_selectedItem - 1;
|
ndx = m_selectedItem - 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user