From 137e5eba229f0ebd8308e6a45f03135234019ed6 Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Tue, 11 Jun 2013 18:02:05 +0200 Subject: QmlProfiler: fixing issues with rendering several models together Change-Id: Ib6c94302952f4b7b20a33257e078db5cfad495ef --- plugins/qmlprofiler/abstracttimelinemodel.cpp | 8 ++ plugins/qmlprofiler/abstracttimelinemodel.h | 1 + plugins/qmlprofiler/qml/Label.qml | 57 ++------- plugins/qmlprofiler/qml/MainView.qml | 4 +- plugins/qmlprofiler/qml/TimeMarks.qml | 17 +-- .../qmlprofiler/qmlprofilertimelinemodelproxy.cpp | 29 +++-- .../qmlprofiler/qmlprofilertimelinemodelproxy.h | 4 - plugins/qmlprofiler/timelinemodelaggregator.cpp | 90 +++++--------- plugins/qmlprofiler/timelinemodelaggregator.h | 11 +- plugins/qmlprofiler/timelinerenderer.cpp | 129 +++++++-------------- plugins/qmlprofiler/timelinerenderer.h | 10 -- 11 files changed, 131 insertions(+), 229 deletions(-) diff --git a/plugins/qmlprofiler/abstracttimelinemodel.cpp b/plugins/qmlprofiler/abstracttimelinemodel.cpp index 66d5be7296..b3878c7bee 100644 --- a/plugins/qmlprofiler/abstracttimelinemodel.cpp +++ b/plugins/qmlprofiler/abstracttimelinemodel.cpp @@ -65,6 +65,14 @@ int AbstractTimelineModel::getState() const return (int)m_modelManager->state(); } +int AbstractTimelineModel::rowCount() const +{ + int count = 0; + for (int i=0; i 0; onVisibleChanged: { - if (visible) - modelIndex = view.modelIndexFromType(index); + if (visible) { + modelIndex = qmlProfilerModelProxy.modelIndexForCategory(index); + categoryIndex = qmlProfilerModelProxy.correctedCategoryIndexForModel(modelIndex, index); + } } onExpandedChanged: { - qmlProfilerModelProxy.setExpanded(typeIndex, expanded); + qmlProfilerModelProxy.setExpanded(modelIndex, categoryIndex, expanded); backgroundMarks.requestRedraw(); getDescriptions(); updateHeight(); @@ -61,19 +63,14 @@ Item { } function updateHeight() { - height = root.singleRowHeight * qmlProfilerModelProxy.categoryDepth(typeIndex); - /* - height = root.singleRowHeight * (1 + - (expanded ? qmlProfilerDataModel.uniqueEventsOfType(typeIndex) : - qmlProfilerDataModel.maxNestingForType(typeIndex))); - */ + height = root.singleRowHeight * qmlProfilerModelProxy.categoryDepth(modelIndex, categoryIndex); } function getDescriptions() { var desc=[]; var ids=[]; var extdesc=[]; - var labelList = qmlProfilerModelProxy.getLabelsForCategory(typeIndex); + var labelList = qmlProfilerModelProxy.getLabelsForCategory(modelIndex, categoryIndex); for (var i = 0; i < labelList.length; i++ ) { desc[i] = labelList[i].description; ids[i] = labelList[i].id; @@ -85,45 +82,14 @@ Item { updateHeight(); } - /* - Connections { - target: qmlProfilerDataModel - onReloadDetailLabels: getDescriptions(); - onStateChanged: { - // Empty - if (qmlProfilerDataModel.getCurrentStateFromQml() == 0) { - descriptions = []; - eventIds = []; - extdescriptions = []; - updateHeight(); - } else - // Done - if (qmlProfilerDataModel.getCurrentStateFromQml() == 3) { - getDescriptions(); - } - } - } - */ Connections { target: qmlProfilerModelProxy -// onReloadDetailLabels: getDescriptions(); onExpandedChanged: { updateHeight(); } onStateChanged: { getDescriptions(); -// // Empty -// if (qmlProfilerDataModel.getCurrentStateFromQml() == 0) { -// descriptions = []; -// eventIds = []; -// extdescriptions = []; -// updateHeight(); -// } else -// // Done -// if (qmlProfilerDataModel.getCurrentStateFromQml() == 3) { - -// } } } @@ -131,6 +97,7 @@ Item { id: txt x: 5 font.pixelSize: 12 + text: labelContainer.text color: "#232323" height: root.singleRowHeight width: 140 diff --git a/plugins/qmlprofiler/qml/MainView.qml b/plugins/qmlprofiler/qml/MainView.qml index 170c963f0a..efb6d0365e 100644 --- a/plugins/qmlprofiler/qml/MainView.qml +++ b/plugins/qmlprofiler/qml/MainView.qml @@ -543,9 +543,7 @@ Rectangle { id: col Repeater { model: labels.rowCount - delegate: Label { - text: qmlProfilerModelProxy.categoryLabel(index) - } + delegate: Label { } } } } diff --git a/plugins/qmlprofiler/qml/TimeMarks.qml b/plugins/qmlprofiler/qml/TimeMarks.qml index 431a54914e..977e733e20 100644 --- a/plugins/qmlprofiler/qml/TimeMarks.qml +++ b/plugins/qmlprofiler/qml/TimeMarks.qml @@ -129,15 +129,16 @@ Canvas2D { // separators var cumulatedHeight = 0; - var modelIndex = 0; - for (var i=0; ifindBindingLoops(); + d->computeRowStarts(); + emit countChanged(); } @@ -294,6 +295,7 @@ void BasicTimelineModel::BasicTimelineModelPrivate::computeNestingContracted() // nestingdepth for (i = 0; i < eventCount; i++) { int eventType = q->getEventType(i); + categorySpan[eventType].empty = false; if (categorySpan[eventType].contractedRows <= startTimeData[i].displayRowCollapsed) categorySpan[eventType].contractedRows = startTimeData[i].displayRowCollapsed + 1; } @@ -307,6 +309,7 @@ void BasicTimelineModel::BasicTimelineModelPrivate::computeExpandedLevels() int eventId = startTimeData[i].eventId; int eventType = eventDict[eventId].eventType; if (!eventRow.contains(eventId)) { + categorySpan[eventType].empty = false; eventRow[eventId] = categorySpan[eventType].expandedRows++; } startTimeData[i].displayRowExpanded = eventRow[eventId]; @@ -378,6 +381,15 @@ void BasicTimelineModel::BasicTimelineModelPrivate::findBindingLoops() } +void BasicTimelineModel::BasicTimelineModelPrivate::computeRowStarts() +{ + int rowStart = 0; + for (int i = 0; i < categorySpan.count(); i++) { + categorySpan[i].rowStart = rowStart; + rowStart += q->categoryDepth(i); + } +} + /////////////////// QML interface bool BasicTimelineModel::isEmpty() const @@ -398,6 +410,7 @@ qint64 BasicTimelineModel::lastTimeMark() const void BasicTimelineModel::setExpanded(int category, bool expanded) { d->categorySpan[category].expanded = expanded; + d->computeRowStarts(); emit expandedChanged(); } @@ -405,6 +418,8 @@ int BasicTimelineModel::categoryDepth(int categoryIndex) const { if (d->categorySpan.count() <= categoryIndex) return 1; + if (d->categorySpan[categoryIndex].empty) + return 1; // TODO if (d->categorySpan[categoryIndex].expanded) return d->categorySpan[categoryIndex].expandedRows; else @@ -525,9 +540,9 @@ int BasicTimelineModel::getEventType(int index) const int BasicTimelineModel::getEventRow(int index) const { if (d->categorySpan[getEventType(index)].expanded) - return d->startTimeData[index].displayRowExpanded; + return d->startTimeData[index].displayRowExpanded + d->categorySpan[getEventType(index)].rowStart; else - return d->startTimeData[index].displayRowCollapsed; + return d->startTimeData[index].displayRowCollapsed + d->categorySpan[getEventType(index)].rowStart; } qint64 BasicTimelineModel::getDuration(int index) const diff --git a/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h b/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h index 96b2cd85c8..616013e8d9 100644 --- a/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h +++ b/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h @@ -123,10 +123,6 @@ public: bool isEmpty() const; Q_INVOKABLE qint64 lastTimeMark() const; -// Q_INVOKABLE qint64 traceStartTime() const; -// Q_INVOKABLE qint64 traceEndTime() const; -// Q_INVOKABLE qint64 traceDuration() const; -// Q_INVOKABLE int getState() const; Q_INVOKABLE void setExpanded(int category, bool expanded); Q_INVOKABLE int categoryDepth(int categoryIndex) const; diff --git a/plugins/qmlprofiler/timelinemodelaggregator.cpp b/plugins/qmlprofiler/timelinemodelaggregator.cpp index 42a5882137..5391da5696 100644 --- a/plugins/qmlprofiler/timelinemodelaggregator.cpp +++ b/plugins/qmlprofiler/timelinemodelaggregator.cpp @@ -69,10 +69,11 @@ void TimelineModelAggregator::setModelManager(QmlProfilerModelManager *modelMana connect(modelManager,SIGNAL(stateChanged()),this,SLOT(dataChanged())); connect(modelManager,SIGNAL(countChanged()),this,SIGNAL(countChanged())); -// m_modelManager = modelManager; -// connect(modelManager,SIGNAL(stateChanged()),this,SLOT(dataChanged())); -// connect(modelManager,SIGNAL(countChanged()),this,SIGNAL(countChanged())); -// d->modelList << new BasicTimelineModel(modelManager, this); + // external models pushed on top + foreach (AbstractTimelineModel *timelineModel, QmlProfilerPlugin::instance->getModels()) { + timelineModel->setModelManager(modelManager); + addModel(timelineModel); + } PaintEventsModelProxy *paintEventsModelProxy = new PaintEventsModelProxy(this); paintEventsModelProxy->setModelManager(modelManager); @@ -82,11 +83,6 @@ void TimelineModelAggregator::setModelManager(QmlProfilerModelManager *modelMana basicTimelineModel->setModelManager(modelManager); addModel(basicTimelineModel); -// qDebug() << "models" << QmlProfilerPlugin::timelineModels.count(); - foreach (AbstractTimelineModel *timelineModel, QmlProfilerPlugin::instance->getModels()) { - timelineModel->setModelManager(modelManager); - addModel(timelineModel); - } } @@ -162,18 +158,13 @@ qint64 TimelineModelAggregator::lastTimeMark() const return mark; } -void TimelineModelAggregator::setExpanded(int category, bool expanded) +void TimelineModelAggregator::setExpanded(int modelIndex, int category, bool expanded) { - int modelIndex = modelIndexForCategory(category, &category); +// int modelIndex = modelIndexForCategory(category); +// category = correctedCategoryIndexForModel(modelIndex, categoryIndex); d->modelList[modelIndex]->setExpanded(category, expanded); } -int TimelineModelAggregator::categoryDepth(int categoryIndex) const -{ - int modelIndex = modelIndexForCategory(categoryIndex, &categoryIndex); - return categoryDepth(modelIndex, categoryIndex); -} - int TimelineModelAggregator::categoryDepth(int modelIndex, int categoryIndex) const { return d->modelList[modelIndex]->categoryDepth(categoryIndex); @@ -181,28 +172,26 @@ int TimelineModelAggregator::categoryDepth(int modelIndex, int categoryIndex) co int TimelineModelAggregator::categoryCount(int modelIndex) const { - // TODO return d->modelList[modelIndex]->categoryCount(); } -const QString TimelineModelAggregator::categoryLabel(int categoryIndex) const +int TimelineModelAggregator::rowCount(int modelIndex) const { - int modelIndex = modelIndexForCategory(categoryIndex, &categoryIndex); - return d->modelList[modelIndex]->categoryLabel(categoryIndex); + return d->modelList[modelIndex]->rowCount(); } -//const QString TimelineModelAggregator::categoryLabel(int categoryIndex) const -//{ -// int modelIndex = modelIndexForCategory(categoryIndex, &categoryIndex); -// return d->modelList[modelIndex]->categoryLabel(categoryIndex); -//} +const QString TimelineModelAggregator::categoryLabel(int modelIndex, int categoryIndex) const +{ +// int modelIndex = modelIndexForCategory(categoryIndex); +// categoryIndex = correctedCategoryIndexForModel(modelIndex, categoryIndex); + return d->modelList[modelIndex]->categoryLabel(categoryIndex); +} -int TimelineModelAggregator::modelIndexForCategory(int categoryIndex, int *newCategoryIndex) const +int TimelineModelAggregator::modelIndexForCategory(int absoluteCategoryIndex) const { + int categoryIndex = absoluteCategoryIndex; for (int modelIndex = 0; modelIndex < d->modelList.count(); modelIndex++) if (categoryIndex < d->modelList[modelIndex]->categoryCount()) { - if (newCategoryIndex) - *newCategoryIndex = categoryIndex; return modelIndex; } else { categoryIndex -= d->modelList[modelIndex]->categoryCount(); @@ -211,75 +200,56 @@ int TimelineModelAggregator::modelIndexForCategory(int categoryIndex, int *newCa return modelCount()-1; } +int TimelineModelAggregator::correctedCategoryIndexForModel(int modelIndex, int absoluteCategoryIndex) const +{ + int categoryIndex = absoluteCategoryIndex; + for (int mi = 0; mi < modelIndex; mi++) + categoryIndex -= d->modelList[mi]->categoryCount(); + return categoryIndex; +} + int TimelineModelAggregator::findFirstIndex(int modelIndex, qint64 startTime) const { -// int index = count(); -// foreach (const AbstractTimelineModel *modelProxy, d->modelList) { -// int newIndex = modelProxy->findFirstIndex(startTime); -// if (newIndex < index) -// index = newIndex; -// } -// return index; return d->modelList[modelIndex]->findFirstIndex(startTime); } int TimelineModelAggregator::findFirstIndexNoParents(int modelIndex, qint64 startTime) const { -// int index = count(); -// foreach (const AbstractTimelineModel *modelProxy, d->modelList) { -// int newIndex = modelProxy->findFirstIndexNoParents(startTime); -// if (newIndex < index) -// index = newIndex; -// } -// return index; return d->modelList[modelIndex]->findFirstIndexNoParents(startTime); } int TimelineModelAggregator::findLastIndex(int modelIndex, qint64 endTime) const { -// int index = -1; -// foreach (const AbstractTimelineModel *modelProxy, d->modelList) { -// int newIndex = modelProxy->findLastIndex(endTime); -// if (newIndex > index) -// index = newIndex; -// } -// return index; return d->modelList[modelIndex]->findLastIndex(endTime); } int TimelineModelAggregator::getEventType(int modelIndex, int index) const { - // TODO return d->modelList[modelIndex]->getEventType(index); } int TimelineModelAggregator::getEventRow(int modelIndex, int index) const { - // TODO return d->modelList[modelIndex]->getEventRow(index); } qint64 TimelineModelAggregator::getDuration(int modelIndex, int index) const { - // TODO return d->modelList[modelIndex]->getDuration(index); } qint64 TimelineModelAggregator::getStartTime(int modelIndex, int index) const { - // TODO return d->modelList[modelIndex]->getStartTime(index); } qint64 TimelineModelAggregator::getEndTime(int modelIndex, int index) const { - // TODO return d->modelList[modelIndex]->getEndTime(index); } int TimelineModelAggregator::getEventId(int modelIndex, int index) const { - // TODO return d->modelList[modelIndex]->getEventId(index); } @@ -290,7 +260,6 @@ int TimelineModelAggregator::getBindingLoopDest(int modelIndex,int index) const QColor TimelineModelAggregator::getColor(int modelIndex, int index) const { - // TODO return d->modelList[modelIndex]->getColor(index); } @@ -299,16 +268,15 @@ float TimelineModelAggregator::getHeight(int modelIndex, int index) const return d->modelList[modelIndex]->getHeight(index); } -const QVariantList TimelineModelAggregator::getLabelsForCategory(int category) const +const QVariantList TimelineModelAggregator::getLabelsForCategory(int modelIndex, int category) const { - // TODO - int modelIndex = modelIndexForCategory(category, &category); +// int modelIndex = modelIndexForCategory(category); +// category = correctedCategoryIndexForModel(modelIndex, category); return d->modelList[modelIndex]->getLabelsForCategory(category); } const QVariantList TimelineModelAggregator::getEventDetails(int modelIndex, int index) const { - // TODO return d->modelList[modelIndex]->getEventDetails(index); } diff --git a/plugins/qmlprofiler/timelinemodelaggregator.h b/plugins/qmlprofiler/timelinemodelaggregator.h index 60679e3da9..7468d06613 100644 --- a/plugins/qmlprofiler/timelinemodelaggregator.h +++ b/plugins/qmlprofiler/timelinemodelaggregator.h @@ -65,11 +65,11 @@ public: Q_INVOKABLE qint64 lastTimeMark() const; - Q_INVOKABLE void setExpanded(int category, bool expanded); - Q_INVOKABLE int categoryDepth(int categoryIndex) const; + Q_INVOKABLE void setExpanded(int modelIndex, int category, bool expanded); Q_INVOKABLE int categoryDepth(int modelIndex, int categoryIndex) const; Q_INVOKABLE int categoryCount(int modelIndex) const; - Q_INVOKABLE const QString categoryLabel(int categoryIndex) const; + Q_INVOKABLE int rowCount(int modelIndex) const; + Q_INVOKABLE const QString categoryLabel(int modelIndex, int categoryIndex) const; int findFirstIndex(int modelIndex, qint64 startTime) const; int findFirstIndexNoParents(int modelIndex, qint64 startTime) const; @@ -85,11 +85,12 @@ public: Q_INVOKABLE QColor getColor(int modelIndex, int index) const; Q_INVOKABLE float getHeight(int modelIndex, int index) const; - Q_INVOKABLE const QVariantList getLabelsForCategory(int category) const; + Q_INVOKABLE const QVariantList getLabelsForCategory(int modelIndex, int category) const; Q_INVOKABLE const QVariantList getEventDetails(int modelIndex, int index) const; - Q_INVOKABLE int modelIndexForCategory(int categoryIndex, int *newCategoryIndex = 0) const; + Q_INVOKABLE int modelIndexForCategory(int absoluteCategoryIndex) const; + Q_INVOKABLE int correctedCategoryIndexForModel(int modelIndex, int absoluteCategoryIndex) const; signals: void countChanged(); diff --git a/plugins/qmlprofiler/timelinerenderer.cpp b/plugins/qmlprofiler/timelinerenderer.cpp index 893eae01e6..288193a832 100644 --- a/plugins/qmlprofiler/timelinerenderer.cpp +++ b/plugins/qmlprofiler/timelinerenderer.cpp @@ -51,8 +51,6 @@ TimelineRenderer::TimelineRenderer(QDeclarativeItem *parent) : setFlag(QGraphicsItem::ItemHasNoContents, false); setAcceptedMouseButtons(Qt::LeftButton); setAcceptHoverEvents(true); - for (int i=0; icategoryDepth(i); - } - - m_rowStarts.clear(); - int pos = 0; - for (int i=0; imodelCount(); i++) { - for (int j = 0; j < m_profilerModelProxy->categoryCount(i); j++) - pos += DefaultRowHeight * m_profilerModelProxy->categoryDepth(i,j); - m_modelRowEnds << pos; - } - p->setPen(Qt::transparent); - // speedup: don't draw overlapping events, just skip them - m_rowLastX.clear(); - for (int i=0; imodelCount(); modelIndex++) { int lastIndex = m_profilerModelProxy->findLastIndex(modelIndex, m_endTime); if (lastIndex < m_profilerModelProxy->count(modelIndex)) { @@ -128,13 +98,19 @@ void TimelineRenderer::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid void TimelineRenderer::drawItemsToPainter(QPainter *p, int modelIndex, int fromIndex, int toIndex) { - int x, y, width, height, eventType; + int x, y, width, height; + p->save(); p->setPen(Qt::transparent); + int modelRowStart = 0; + for (int mi = 0; mi < modelIndex; mi++) + modelRowStart += m_profilerModelProxy->rowCount(mi); + for (int i = fromIndex; i <= toIndex; i++) { x = (m_profilerModelProxy->getStartTime(modelIndex, i) - m_startTime) * m_spacing; - eventType = m_profilerModelProxy->getEventType(modelIndex, i); + int rowNumber = m_profilerModelProxy->getEventRow(modelIndex, i); - y = m_rowStarts[eventType] + rowNumber * DefaultRowHeight; + y = (modelRowStart + rowNumber) * DefaultRowHeight; + width = m_profilerModelProxy->getDuration(modelIndex, i)*m_spacing; if (width < 1) width = 1; @@ -142,30 +118,11 @@ void TimelineRenderer::drawItemsToPainter(QPainter *p, int modelIndex, int fromI height = DefaultRowHeight * m_profilerModelProxy->getHeight(modelIndex, i); y += DefaultRowHeight - height; - // special: animations - /*if (eventType == 0 && m_profilerDataModel->getAnimationCount(i) >= 0) { - double scale = m_profilerDataModel->getMaximumAnimationCount() - - m_profilerDataModel->getMinimumAnimationCount(); - double fraction; - if (scale > 1) - fraction = (double)(m_profilerDataModel->getAnimationCount(i) - - m_profilerDataModel->getMinimumAnimationCount()) / scale; - else - fraction = 1.0; - height = DefaultRowHeight * (fraction * 0.85 + 0.15); - y += DefaultRowHeight - height; - - double fpsFraction = m_profilerDataModel->getFramerate(i) / 60.0; - if (fpsFraction > 1.0) - fpsFraction = 1.0; - p->setBrush(QColor::fromHsl((fpsFraction*96)+10, 76, 166)); - p->drawRect(x, y, width, height); - } else */ { - // normal events - p->setBrush(m_profilerModelProxy->getColor(modelIndex, i)); - p->drawRect(x, y, width, height); - } + // normal events + p->setBrush(m_profilerModelProxy->getColor(modelIndex, i)); + p->drawRect(x, y, width, height); } + p->restore(); } void TimelineRenderer::drawSelectionBoxes(QPainter *p, int modelIndex, int fromIndex, int toIndex) @@ -176,7 +133,12 @@ void TimelineRenderer::drawSelectionBoxes(QPainter *p, int modelIndex, int fromI int id = m_profilerModelProxy->getEventId(modelIndex, m_selectedItem); - p->setBrush(Qt::transparent); + int modelRowStart = 0; + for (int mi = 0; mi < modelIndex; mi++) + modelRowStart += m_profilerModelProxy->rowCount(mi); + + p->save(); + QColor selectionColor = Qt::blue; if (m_selectionLocked) selectionColor = QColor(96,0,255); @@ -184,18 +146,16 @@ void TimelineRenderer::drawSelectionBoxes(QPainter *p, int modelIndex, int fromI QPen lightPen(QBrush(selectionColor.lighter(130)), 2); lightPen.setJoinStyle(Qt::MiterJoin); p->setPen(lightPen); + p->setBrush(Qt::transparent); - int x, y, width, eventType; - p->setPen(lightPen); - + int x, y, width; QRect selectedItemRect(0,0,0,0); for (int i = fromIndex; i <= toIndex; i++) { if (m_profilerModelProxy->getEventId(modelIndex, i) != id) continue; x = (m_profilerModelProxy->getStartTime(modelIndex, i) - m_startTime) * m_spacing; - eventType = m_profilerModelProxy->getEventType(modelIndex, i); - y = m_rowStarts[eventType] + DefaultRowHeight * m_profilerModelProxy->getEventRow(modelIndex, i); + y = (modelRowStart + m_profilerModelProxy->getEventRow(modelIndex, i)) * DefaultRowHeight; width = m_profilerModelProxy->getDuration(modelIndex, i)*m_spacing; if (width<1) @@ -212,6 +172,8 @@ void TimelineRenderer::drawSelectionBoxes(QPainter *p, int modelIndex, int fromI p->setPen(strongPen); p->drawRect(selectedItemRect); } + + p->restore(); } void TimelineRenderer::drawBindingLoopMarkers(QPainter *p, int modelIndex, int fromIndex, int toIndex) @@ -273,9 +235,12 @@ void TimelineRenderer::drawBindingLoopMarkers(QPainter *p, int modelIndex, int f int TimelineRenderer::modelFromPosition(int y) { - for (int i = 0; i < m_modelRowEnds.count(); i++) - if (y < m_modelRowEnds[i]) - return i; + y = y / DefaultRowHeight; + for (int modelIndex = 0; modelIndex < m_profilerModelProxy->modelCount(); modelIndex++) { + y -= m_profilerModelProxy->rowCount(modelIndex); + if (y < 0) + return modelIndex; + } } void TimelineRenderer::mousePressEvent(QGraphicsSceneMouseEvent *event) @@ -350,17 +315,17 @@ void TimelineRenderer::manageHovered(int x, int y) return; } + int modelRowStart = 0; + for (int mi = 0; mi < modelIndex; mi++) + modelRowStart += m_profilerModelProxy->rowCount(mi); + // find if we are in the right column - int itemRow, eventType; + int itemRow; for (int i=eventTo; i>=eventFrom; --i) { if (ceil(m_profilerModelProxy->getEndTime(modelIndex, i)*m_spacing) < floor(time*m_spacing)) continue; -// qDebug() << i << m_profilerModelProxy->getStartTime(modelIndex,i) << m_profilerModelProxy->getDuration(modelIndex,i) << m_profilerModelProxy->getEndTime(modelIndex,i) << "at" << time; - - eventType = m_profilerModelProxy->getEventType(modelIndex, i); - itemRow = m_rowStarts[eventType]/DefaultRowHeight + - m_profilerModelProxy->getEventRow(modelIndex, i); + itemRow = modelRowStart + m_profilerModelProxy->getEventRow(modelIndex, i); if (itemRow == row) { // match @@ -420,20 +385,17 @@ QString TimelineRenderer::getDetails(int index) const int TimelineRenderer::getYPosition(int modelIndex, int index) const { Q_ASSERT(m_profilerModelProxy); - if (index >= m_profilerModelProxy->count() || m_rowStarts.isEmpty()) + if (index >= m_profilerModelProxy->count()) return 0; - int eventType = m_profilerModelProxy->getEventType(modelIndex, index); - int y = m_rowStarts[eventType] + DefaultRowHeight * m_profilerModelProxy->getEventRow(modelIndex, index); + + int modelRowStart = 0; + for (int mi = 0; mi < modelIndex; mi++) + modelRowStart += m_profilerModelProxy->rowCount(mi); + + int y = DefaultRowHeight * (modelRowStart + m_profilerModelProxy->getEventRow(modelIndex, index)); return y; } -//void TimelineRenderer::setRowExpanded(int modelIndex, int rowIndex, bool expanded) -//{ -// // todo: m_rowsExpanded, should that be removed? where do I have it duplicated? -// m_rowsExpanded[rowIndex] = expanded; -// update(); -//} - void TimelineRenderer::selectNext() { if (m_profilerModelProxy->count() == 0) @@ -601,8 +563,3 @@ void TimelineRenderer::selectPrevFromId(int modelIndex, int eventId) setSelectedItem(eventIndex); } } - -int TimelineRenderer::modelIndexFromType(int typeIndex) const -{ - return m_profilerModelProxy->modelIndexForCategory(typeIndex, &typeIndex); -} diff --git a/plugins/qmlprofiler/timelinerenderer.h b/plugins/qmlprofiler/timelinerenderer.h index 81f30e1af6..e43b1473ef 100644 --- a/plugins/qmlprofiler/timelinerenderer.h +++ b/plugins/qmlprofiler/timelinerenderer.h @@ -108,15 +108,12 @@ public: Q_INVOKABLE QString getDetails(int index) const; Q_INVOKABLE int getYPosition(int modelIndex, int index) const; -// Q_INVOKABLE void setRowExpanded(int modelIndex, int rowIndex, bool expanded); - Q_INVOKABLE void selectNext(); Q_INVOKABLE void selectPrev(); Q_INVOKABLE int nextItemFromId(int modelIndex, int eventId) const; Q_INVOKABLE int prevItemFromId(int modelIndex, int eventId) const; Q_INVOKABLE void selectNextFromId(int modelIndex, int eventId); Q_INVOKABLE void selectPrevFromId(int modelIndex, int eventId); - Q_INVOKABLE int modelIndexFromType(int typeIndex) const; signals: void startTimeChanged(qint64 arg); @@ -218,13 +215,6 @@ private: qint64 m_lastEndTime; TimelineModelAggregator *m_profilerModelProxy; -// BasicTimelineModel *m_profilerModelProxy; - - QList m_rowLastX; - QList m_rowStarts; - QList m_rowWidths; - QList m_rowsExpanded; - QList m_modelRowEnds; struct { qint64 startTime; -- cgit v1.2.3