From 5ad0fea83c24231c2d19d4484872d6a20c8b24cd Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 18 Jan 2018 16:26:44 +0100 Subject: [PATCH] Timeline: Improve performance of labels a, We don't need our special synchronous reloader anymore because the stock Loader does the same now. b, Creating and removing the labels while scrolling only accounts for a relatively small part of the total overhead. The most expensive part is the offset calculation which has to be performed for each label on each scroll movement. Move parts of that to the parent item. c, Asynchronous loading of items in a repeater doesn't work because the repeater will still wait until all the items are loaded. Thus, the previous code would still load all the labels immediately when expanding. Use the "active" property instead to load labels on demand. d, The repeater initializes all the labels to y == 0 before moving them into place. Make sure they aren't all initially active because of that. Change-Id: I4d8b762899c4aa88173dacec668341f592ffe38c Reviewed-by: Christian Kandeler --- src/libs/timeline/qml/CategoryLabel.qml | 11 ++++-- src/libs/timeline/qml/SynchronousReloader.qml | 38 ------------------- src/libs/timeline/qml/TimelineLabels.qml | 2 +- src/libs/timeline/qml/timeline.qrc | 1 - 4 files changed, 8 insertions(+), 44 deletions(-) delete mode 100644 src/libs/timeline/qml/SynchronousReloader.qml diff --git a/src/libs/timeline/qml/CategoryLabel.qml b/src/libs/timeline/qml/CategoryLabel.qml index ecb2cbab591..e6dd396547a 100644 --- a/src/libs/timeline/qml/CategoryLabel.qml +++ b/src/libs/timeline/qml/CategoryLabel.qml @@ -42,6 +42,7 @@ Item { property int visualIndex property int dragOffset property Item draggerParent + property int contentBottom: draggerParent.contentY + draggerParent.height - dragOffset signal dragStarted; signal dragStopped; @@ -101,12 +102,14 @@ Item { visible: expanded Repeater { model: expanded ? labels.length : 0 - SynchronousReloader { + Loader { id: loader - asynchronous: dragOffset - draggerParent.contentY + y + txt.height > - draggerParent.height - active: expanded + // Initially y == 0 for all the items. Don't enable them until they have been moved + // into place. + property int offset: (index === 0 || y > 0) ? (y + txt.height) + : draggerParent.contentHeight + active: contentBottom > offset width: labelContainer.width height: column.parentModel ? column.parentModel.rowHeight(index + 1) : 0 diff --git a/src/libs/timeline/qml/SynchronousReloader.qml b/src/libs/timeline/qml/SynchronousReloader.qml deleted file mode 100644 index a53f829ba02..00000000000 --- a/src/libs/timeline/qml/SynchronousReloader.qml +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -import QtQuick 2.0 - -Loader { - onAsynchronousChanged: { - if (!asynchronous && active && status !== Loader.Ready) { - // Trigger a synchronous reload to avoid glitches - var component = sourceComponent; - sourceComponent = undefined; - sourceComponent = component; - } - } -} - diff --git a/src/libs/timeline/qml/TimelineLabels.qml b/src/libs/timeline/qml/TimelineLabels.qml index 95b82f7d854..71434822f4b 100644 --- a/src/libs/timeline/qml/TimelineLabels.qml +++ b/src/libs/timeline/qml/TimelineLabels.qml @@ -71,7 +71,7 @@ Flickable { } model: modelProxy.models - delegate: SynchronousReloader { + delegate: Loader { id: loader asynchronous: y < categories.contentY + categories.height && y + height > categories.contentY diff --git a/src/libs/timeline/qml/timeline.qrc b/src/libs/timeline/qml/timeline.qrc index 18a1933c6f6..ca6493ba5c4 100644 --- a/src/libs/timeline/qml/timeline.qrc +++ b/src/libs/timeline/qml/timeline.qrc @@ -27,7 +27,6 @@ TimelineLabels.qml TimelineContent.qml RowLabel.qml - SynchronousReloader.qml TimelineText.qml ImageToolButton.qml TimelineRulers.qml