From 1193cfa092ee7b3694d2aa5fede19fb86e224024 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 3 Dec 2013 17:34:51 +0100 Subject: Cache loaded items This is a somewhat different solution for improving the performance of the welcome screen. It has the added benefit of caching loaded items while still retaining a decent performance. Change-Id: I9927a90f1b7de5bb06c43b16dc80cb2afec3f8ad Reviewed-by: Ulf Hermann Reviewed-by: Eike Ziller --- share/qtcreator/welcomescreen/examples.qml | 6 ++-- .../welcomescreen/widgets/CustomizedGridView.qml | 34 +++++++++++++--------- 2 files changed, 23 insertions(+), 17 deletions(-) (limited to 'share') diff --git a/share/qtcreator/welcomescreen/examples.qml b/share/qtcreator/welcomescreen/examples.qml index b485aed540..8ff9865c0f 100644 --- a/share/qtcreator/welcomescreen/examples.qml +++ b/share/qtcreator/welcomescreen/examples.qml @@ -37,14 +37,12 @@ Rectangle { CustomizedGridView { id: grid + y: 82 + height: grid.contentHeight anchors.rightMargin: 38 anchors.leftMargin: 38 anchors.left: parent.left anchors.right: parent.right - height: scrollView.height - 82 - y: scrollView.flickableItem.contentY + 82 - contentY: scrollView.flickableItem.contentY - model: examplesModel } diff --git a/share/qtcreator/welcomescreen/widgets/CustomizedGridView.qml b/share/qtcreator/welcomescreen/widgets/CustomizedGridView.qml index bbe6b03109..59984d6d7f 100644 --- a/share/qtcreator/welcomescreen/widgets/CustomizedGridView.qml +++ b/share/qtcreator/welcomescreen/widgets/CustomizedGridView.qml @@ -38,22 +38,30 @@ GridView { cellWidth: 216 property int columns: Math.max(Math.floor(width / cellWidth), 1) - delegate: Delegate { - id: delegate + delegate: Loader { + property int delegateOffset: cellHeight * Math.floor(index / columns) + 100 + property bool isVisible: delegateOffset > scrollView.flickableItem.contentY - cellHeight + && delegateOffset < scrollView.flickableItem.contentY + scrollView.flickableItem.height + onIsVisibleChanged: active = true + visible: isVisible + active: false + sourceComponent: Delegate { + id: delegate - property bool isHelpImage: model.imageUrl.search(/qthelp/) != -1 - property string sourcePrefix: isHelpImage ? "image://helpimage/" : "" + property bool isHelpImage: model.imageUrl.search(/qthelp/) != -1 + property string sourcePrefix: isHelpImage ? "image://helpimage/" : "" - property string mockupSource: model.imageSource - property string helpSource: model.imageUrl !== "" ? sourcePrefix + encodeURI(model.imageUrl) : "" + property string mockupSource: model.imageSource + property string helpSource: model.imageUrl !== "" ? sourcePrefix + encodeURI(model.imageUrl) : "" - imageSource: isVideo ? "" : (model.imageSource === undefined ? helpSource : mockupSource) - videoSource: isVideo ? (model.imageSource === undefined ? model.imageUrl : mockupSource) : "" + imageSource: isVideo ? "" : (model.imageSource === undefined ? helpSource : mockupSource) + videoSource: isVideo ? (model.imageSource === undefined ? model.imageUrl : mockupSource) : "" - caption: model.name; - description: model.description - isVideo: model.isVideo === true - videoLength: model.videoLength !== undefined ? model.videoLength : "" - tags: model.tags + caption: model.name; + description: model.description + isVideo: model.isVideo === true + videoLength: model.videoLength !== undefined ? model.videoLength : "" + tags: model.tags + } } } -- cgit v1.2.1