From 10a14ced366b6df5197f247a23ba628a0c5ae41d Mon Sep 17 00:00:00 2001
From: Ulf Hermann <ulf.hermann@digia.com>
Date: Mon, 13 Oct 2014 12:05:40 +0200
Subject: [PATCH] QmlProfiler: Increase minimum size of timeline items to 3px

One pixel wide lines are too hard to spot.

Change-Id: I94f71ba4305078d8682673618be0f5a5e1f85ba8
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
---
 src/plugins/qmlprofiler/timelinerenderer.cpp | 14 +++++++++-----
 src/plugins/qmlprofiler/timelinerenderer.h   |  2 ++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/plugins/qmlprofiler/timelinerenderer.cpp b/src/plugins/qmlprofiler/timelinerenderer.cpp
index e2961141c9e..366525dbf6f 100644
--- a/src/plugins/qmlprofiler/timelinerenderer.cpp
+++ b/src/plugins/qmlprofiler/timelinerenderer.cpp
@@ -109,16 +109,20 @@ inline void TimelineRenderer::getItemXExtent(int modelIndex, int i, int &current
     qint64 start = m_profilerModelProxy->startTime(modelIndex, i) - m_startTime;
     if (start > 0) {
         currentX = start * m_spacing;
-        itemWidth = qMax(1.0, (qMin(m_profilerModelProxy->duration(modelIndex, i) *
-                                    m_spacing, m_spacedDuration)));
+        itemWidth = m_profilerModelProxy->duration(modelIndex, i) * m_spacing;
     } else {
         currentX = -OutOfScreenMargin;
         // Explicitly round the "start" part down, away from 0, to match the implicit rounding of
         // currentX in the > 0 case. If we don't do that we get glitches where a pixel is added if
         // the element starts outside the screen and subtracted if it starts inside the screen.
-        itemWidth = qMax(1.0, (qMin(m_profilerModelProxy->duration(modelIndex, i) * m_spacing +
-                                    floor(start * m_spacing) + OutOfScreenMargin,
-                                    m_spacedDuration)));
+        itemWidth = m_profilerModelProxy->duration(modelIndex, i) * m_spacing +
+                floor(start * m_spacing) + OutOfScreenMargin;
+    }
+    if (itemWidth < MinimumItemWidth) {
+        currentX -= (MinimumItemWidth - itemWidth) / 2;
+        itemWidth = MinimumItemWidth;
+    } else if (itemWidth > m_spacedDuration) {
+        itemWidth = m_spacedDuration;
     }
 }
 
diff --git a/src/plugins/qmlprofiler/timelinerenderer.h b/src/plugins/qmlprofiler/timelinerenderer.h
index cb07e8765c1..59d7b988c3f 100644
--- a/src/plugins/qmlprofiler/timelinerenderer.h
+++ b/src/plugins/qmlprofiler/timelinerenderer.h
@@ -197,6 +197,8 @@ private:
 
 private:
     static const int OutOfScreenMargin = 3; // margin to make sure the rectangles stay invisible
+    static const int MinimumItemWidth = 3;
+
     inline void getItemXExtent(int modelIndex, int i, int &currentX, int &itemWidth);
     void resetCurrentSelection();
 
-- 
GitLab