QmlProfiler: drag&drop reordering of models in timeline

Task-number: QTCREATORBUG-12337
Change-Id: I399593f44aa8ff8dd79c623108fecb3c317cb63c
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-08-27 12:11:26 +02:00
parent 00650c8b65
commit 36d8ad4c39
6 changed files with 136 additions and 4 deletions

View File

@@ -56,12 +56,16 @@ void TimelineRenderer::setProfilerModelProxy(QObject *profilerModelProxy)
if (m_profilerModelProxy) {
disconnect(m_profilerModelProxy, SIGNAL(expandedChanged()), this, SLOT(requestPaint()));
disconnect(m_profilerModelProxy, SIGNAL(rowHeightChanged()), this, SLOT(requestPaint()));
disconnect(m_profilerModelProxy, SIGNAL(modelsChanged(int,int)),
this, SLOT(swapSelections(int,int)));
}
m_profilerModelProxy = qobject_cast<TimelineModelAggregator *>(profilerModelProxy);
if (m_profilerModelProxy) {
connect(m_profilerModelProxy, SIGNAL(expandedChanged()), this, SLOT(requestPaint()));
connect(m_profilerModelProxy, SIGNAL(rowHeightChanged()), this, SLOT(requestPaint()));
connect(m_profilerModelProxy, SIGNAL(modelsChanged(int,int)),
this, SLOT(swapSelections(int,int)));
}
emit profilerModelProxyChanged(m_profilerModelProxy);
}
@@ -84,6 +88,20 @@ void TimelineRenderer::requestPaint()
update();
}
void TimelineRenderer::swapSelections(int modelIndex1, int modelIndex2)
{
// Any hovered event is most likely useless now. Reset it.
resetCurrentSelection();
// Explicitly selected events can be tracked in a useful way.
if (m_selectedModel == modelIndex1)
setSelectedModel(modelIndex2);
else if (m_selectedModel == modelIndex2)
setSelectedModel(modelIndex1);
update();
}
inline void TimelineRenderer::getItemXExtent(int modelIndex, int i, int &currentX, int &itemWidth)
{
qint64 start = m_profilerModelProxy->startTime(modelIndex, i) - m_startTime;