summaryrefslogtreecommitdiff
path: root/src/plugins/qmlprofiler
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-09-29 18:15:59 +0200
committerUlf Hermann <ulf.hermann@digia.com>2014-10-02 11:28:04 +0200
commit4481925b1a85aef1f8c7ae5ac23b5f8cec80d8a6 (patch)
tree0a6bc22d3aa96bdb63ffdeae0b1c97a2416271f9 /src/plugins/qmlprofiler
parent0f3f3df36c29c37452fa31c591489ccbfefeea9f (diff)
downloadqt-creator-4481925b1a85aef1f8c7ae5ac23b5f8cec80d8a6.tar.gz
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>
Diffstat (limited to 'src/plugins/qmlprofiler')
-rw-r--r--src/plugins/qmlprofiler/timelinerenderer.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/plugins/qmlprofiler/timelinerenderer.cpp b/src/plugins/qmlprofiler/timelinerenderer.cpp
index bc35f2aa07..e2961141c9 100644
--- a/src/plugins/qmlprofiler/timelinerenderer.cpp
+++ b/src/plugins/qmlprofiler/timelinerenderer.cpp
@@ -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;