From f1138920b91892775c31e040de98303e8431fd85 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 18 Jan 2018 17:13:26 +0100 Subject: [PATCH] Timeline: Only load the scale for rows that need it Typically at most a handful of rows have scales, but the creation of the Text elements is expensive. Put the whole scale handling into a loader and condition it on scaleActive. Change-Id: I0e0cc349f5c6b88953a96b87ba37331586ec702f Reviewed-by: Christian Kandeler --- src/libs/timeline/qml/TimeMarks.qml | 64 ++++++++++++++++------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/src/libs/timeline/qml/TimeMarks.qml b/src/libs/timeline/qml/TimeMarks.qml index fa0900824db..4c91d644edf 100644 --- a/src/libs/timeline/qml/TimeMarks.qml +++ b/src/libs/timeline/qml/TimeMarks.qml @@ -97,41 +97,49 @@ Item { return ret; } - TimelineText { - id: scaleTopLabel - visible: parent.scaleVisible - font.pixelSize: 8 - anchors.top: parent.top - anchors.leftMargin: 2 - anchors.topMargin: 2 - anchors.left: parent.left - text: prettyPrintScale(row.maxVal) - } + Loader { + anchors.fill: parent + active: parent.scaleVisible + sourceComponent: Item { + id: scaleParent + anchors.fill: parent - Repeater { - model: parent.scaleVisible ? row.valDiff / row.stepVal : 0 - - Item { - anchors.left: row.left - anchors.right: row.right - height: row.stepVal * row.height / row.valDiff - y: row.height - (index + 1) * height - visible: y > scaleTopLabel.height TimelineText { + id: scaleTopLabel font.pixelSize: 8 - anchors.bottom: parent.bottom - anchors.bottomMargin: 2 + anchors.top: parent.top anchors.leftMargin: 2 + anchors.topMargin: 2 anchors.left: parent.left - text: prettyPrintScale(index * row.stepVal) + text: prettyPrintScale(row.maxVal) } - Rectangle { - height: 1 - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - color: Theme.color(Theme.Timeline_DividerColor) + Repeater { + model: row.valDiff / row.stepVal + + Item { + anchors.left: scaleParent.left + anchors.right: scaleParent.right + height: row.stepVal * row.height / row.valDiff + y: row.height - (index + 1) * height + visible: y > scaleTopLabel.height + TimelineText { + font.pixelSize: 8 + anchors.bottom: parent.bottom + anchors.bottomMargin: 2 + anchors.leftMargin: 2 + anchors.left: parent.left + text: prettyPrintScale(index * row.stepVal) + } + + Rectangle { + height: 1 + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + color: Theme.color(Theme.Timeline_DividerColor) + } + } } } }