From 3807b0fae526dcf17337df2311f19d3b6aa6a5be Mon Sep 17 00:00:00 2001 From: Thomas Hartmann <Thomas.Hartmann@nokia.com> Date: Tue, 6 Dec 2011 15:57:16 +0100 Subject: [PATCH] WelcomePage: optimizing GridView Instead of placing the "complete" GridView to a ScrollArea we now add a ScrollBar to the GridView. This means that only visible delegates are instanciated and the GridView gets alot faster. Change-Id: I63b8593b260acd4d3a786a99c7dd58507c12e221 Reviewed-by: Alessandro Portale <alessandro.portale@nokia.com> --- share/qtcreator/welcomescreen/examples.qml | 8 +--- share/qtcreator/welcomescreen/tutorials.qml | 13 +----- .../widgets/CustomScrollArea.qml | 40 ------------------- .../widgets/CustomizedGridView.qml | 30 +++++++++++++- 4 files changed, 32 insertions(+), 59 deletions(-) delete mode 100644 share/qtcreator/welcomescreen/widgets/CustomScrollArea.qml diff --git a/share/qtcreator/welcomescreen/examples.qml b/share/qtcreator/welcomescreen/examples.qml index 3d48acb8676..6611e91aeaf 100644 --- a/share/qtcreator/welcomescreen/examples.qml +++ b/share/qtcreator/welcomescreen/examples.qml @@ -52,18 +52,14 @@ Rectangle { caption: qsTr("Examples") } - CustomScrollArea { - id: scrollArea; - + CustomizedGridView { anchors.rightMargin: 38 anchors.bottomMargin: 60 anchors.leftMargin: 38 anchors.topMargin: 102 anchors.fill: parent - CustomizedGridView { - model: examplesModel - } + model: examplesModel } SearchBar { diff --git a/share/qtcreator/welcomescreen/tutorials.qml b/share/qtcreator/welcomescreen/tutorials.qml index 698b60195c3..cf8ad88ea3c 100644 --- a/share/qtcreator/welcomescreen/tutorials.qml +++ b/share/qtcreator/welcomescreen/tutorials.qml @@ -52,23 +52,14 @@ Rectangle { caption: qsTr("Tutorials") } - CustomScrollArea { - id: scrollArea; - + CustomizedGridView { anchors.rightMargin: 38 anchors.bottomMargin: 60 anchors.leftMargin: 38 anchors.topMargin: 102 anchors.fill: parent - clip: true - - horizontalScrollBar.visible: false - frame: false - - CustomizedGridView { - model: tutorialsModel - } + model: tutorialsModel } SearchBar { diff --git a/share/qtcreator/welcomescreen/widgets/CustomScrollArea.qml b/share/qtcreator/welcomescreen/widgets/CustomScrollArea.qml deleted file mode 100644 index 230414c29c1..00000000000 --- a/share/qtcreator/welcomescreen/widgets/CustomScrollArea.qml +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -import QtQuick 1.1 -import qtcomponents 1.0 - -ScrollArea { - horizontalScrollBar.visible: false - frame: false - clip: true -} diff --git a/share/qtcreator/welcomescreen/widgets/CustomizedGridView.qml b/share/qtcreator/welcomescreen/widgets/CustomizedGridView.qml index ad3f8ee9dff..9898d034a63 100644 --- a/share/qtcreator/welcomescreen/widgets/CustomizedGridView.qml +++ b/share/qtcreator/welcomescreen/widgets/CustomizedGridView.qml @@ -31,14 +31,16 @@ **************************************************************************/ import QtQuick 1.0 +import qtcomponents 1.0 GridView { + id: gridView interactive: false - width: scrollArea.width + clip: true cellHeight: 240 cellWidth: 216 property int columns: Math.max(Math.floor(width / cellWidth), 1) - height: 240 * Math.ceil(count / columns) + cacheBuffer: 1000 x: Math.max((width - (cellWidth * columns)) / 2, 0); @@ -61,4 +63,28 @@ GridView { tags: model.tags } + WheelArea { + id: wheelarea + anchors.fill: parent + verticalMinimumValue: vscrollbar.minimumValue + verticalMaximumValue: vscrollbar.maximumValue + + onVerticalValueChanged: gridView.contentY = verticalValue + } + + ScrollBar { + id: vscrollbar + orientation: Qt.Vertical + property int availableHeight : gridView.height + visible: contentHeight > availableHeight + maximumValue: contentHeight > availableHeight ? gridView.contentHeight - availableHeight : 0 + minimumValue: 0 + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.topMargin: styleitem.style == "mac" ? 1 : 0 + onValueChanged: gridView.contentY = value + anchors.rightMargin: styleitem.frameoffset + anchors.bottomMargin: hscrollbar.visible ? hscrollbar.height : styleitem.frameoffset + } } -- GitLab