OSDN Git Service

QmlProfiler: nesting events in the timeline view
authorChristiaan Janssen <christiaan.janssen@nokia.com>
Mon, 27 Jun 2011 15:12:25 +0000 (17:12 +0200)
committerChristiaan Janssen <christiaan.janssen@nokia.com>
Tue, 28 Jun 2011 15:09:05 +0000 (17:09 +0200)
Change-Id: I6bc534a7fc02cb8c647dfc90a78b698592719a91
Reviewed-on: http://codereview.qt.nokia.com/843
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
src/plugins/qmlprofiler/qml/MainView.js
src/plugins/qmlprofiler/qml/MainView.qml
src/plugins/qmlprofiler/timelineview.cpp

index 40b5fd6..bbdc25c 100644 (file)
@@ -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()
index cbdfbc9..635b4ef 100644 (file)
@@ -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) }
index 265fe94..4af994f 100644 (file)
@@ -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<QVariantList>();
             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)