From: Christiaan Janssen Date: Mon, 27 Jun 2011 15:12:25 +0000 (+0200) Subject: QmlProfiler: nesting events in the timeline view X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=79311f273adc3d3c9584c2be996c7b4005599e8f;p=qt-creator-jp%2Fqt-creator-jp.git QmlProfiler: nesting events in the timeline view Change-Id: I6bc534a7fc02cb8c647dfc90a78b698592719a91 Reviewed-on: http://codereview.qt.nokia.com/843 Reviewed-by: Qt Sanity Bot Reviewed-by: Kai Koehne --- diff --git a/src/plugins/qmlprofiler/qml/MainView.js b/src/plugins/qmlprofiler/qml/MainView.js index 40b5fd6a9d..bbdc25cfa9 100644 --- a/src/plugins/qmlprofiler/qml/MainView.js +++ b/src/plugins/qmlprofiler/qml/MainView.js @@ -40,6 +40,7 @@ var valuesdone = false; var xmargin = 0; var ymargin = 0; var drawFpsGraph = false; +var nestingDepth = []; var names = [ "Painting", "Compiling", "Creating", "Binding", "Handling Signal"] //### need better way to manipulate color from QML. In the meantime, these need to be kept in sync. @@ -55,6 +56,7 @@ function reset() xmargin = 0; ymargin = 0; valuesdone = false; + nestingDepth = []; } function calcFps() diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index cbdfbc96ad..635b4ef8fb 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -146,8 +146,15 @@ Rectangle { } // todo: consider nestingLevel - if (!Plotter.valuesdone) - Plotter.ranges.push( { type: type, start: startTime, duration: length, label: data, fileName: fileName, line: line } ); + if (!Plotter.valuesdone) { + if (!Plotter.nestingDepth[type]) + Plotter.nestingDepth[type] = nestingInType; + else + Plotter.nestingDepth[type] = Math.max(Plotter.nestingDepth[type], nestingInType); + Plotter.ranges.push( { type: type, start: startTime, duration: length, label: data, fileName: fileName, line: line, nestingLevel: nestingInType, nestingDepth: Plotter.nestingDepth[type] } ); + if (nestingInType == 1) + Plotter.nestingDepth[type] = 1; + } } onComplete: { @@ -265,8 +272,10 @@ Rectangle { mouseArea.exited() } - height: view.height / labels.rowCount - y: type * view.height / labels.rowCount; + property int baseY: type * view.height / labels.rowCount; + property int baseHeight: view.height / labels.rowCount + y: baseY + (nestingLevel-1)*(baseHeight / nestingDepth); + height: baseHeight / nestingDepth; gradient: Gradient { GradientStop { position: 0.0; color: myColor } GradientStop { position: 0.5; color: Qt.darker(myColor, 1.1) } diff --git a/src/plugins/qmlprofiler/timelineview.cpp b/src/plugins/qmlprofiler/timelineview.cpp index 265fe9464a..4af994fb22 100644 --- a/src/plugins/qmlprofiler/timelineview.cpp +++ b/src/plugins/qmlprofiler/timelineview.cpp @@ -202,6 +202,8 @@ void TimelineView::updateTimeline(bool updateStartX) ctxt->setContextProperty("fileName", m_ranges.property(i).property("fileName").toString()); ctxt->setContextProperty("line", m_ranges.property(i).property("line").toNumber()); ctxt->setContextProperty("index", i); + ctxt->setContextProperty("nestingLevel", m_ranges.property(i).property("nestingLevel").toNumber()); + ctxt->setContextProperty("nestingDepth", m_ranges.property(i).property("nestingDepth").toNumber()); QString label; QVariantList list = m_ranges.property(i).property("label").toVariant().value(); for (int i = 0; i < list.size(); ++i) { @@ -226,7 +228,8 @@ void TimelineView::updateTimeline(bool updateStartX) } if (item) { item->setX(m_starts.at(i)*spacing); - item->setWidth((m_ends.at(i)-m_starts.at(i)) * spacing); + qreal width = (m_ends.at(i)-m_starts.at(i)) * spacing; + item->setWidth(width > 1 ? width : 1); item->setZValue(++z); } if (creating)