Skip to content
Snippets Groups Projects
Commit 3807b0fa authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

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: default avatarAlessandro Portale <alessandro.portale@nokia.com>
parent 02d74bd3
No related branches found
No related tags found
No related merge requests found
...@@ -52,18 +52,14 @@ Rectangle { ...@@ -52,18 +52,14 @@ Rectangle {
caption: qsTr("Examples") caption: qsTr("Examples")
} }
CustomScrollArea { CustomizedGridView {
id: scrollArea;
anchors.rightMargin: 38 anchors.rightMargin: 38
anchors.bottomMargin: 60 anchors.bottomMargin: 60
anchors.leftMargin: 38 anchors.leftMargin: 38
anchors.topMargin: 102 anchors.topMargin: 102
anchors.fill: parent anchors.fill: parent
CustomizedGridView { model: examplesModel
model: examplesModel
}
} }
SearchBar { SearchBar {
......
...@@ -52,23 +52,14 @@ Rectangle { ...@@ -52,23 +52,14 @@ Rectangle {
caption: qsTr("Tutorials") caption: qsTr("Tutorials")
} }
CustomScrollArea { CustomizedGridView {
id: scrollArea;
anchors.rightMargin: 38 anchors.rightMargin: 38
anchors.bottomMargin: 60 anchors.bottomMargin: 60
anchors.leftMargin: 38 anchors.leftMargin: 38
anchors.topMargin: 102 anchors.topMargin: 102
anchors.fill: parent anchors.fill: parent
clip: true model: tutorialsModel
horizontalScrollBar.visible: false
frame: false
CustomizedGridView {
model: tutorialsModel
}
} }
SearchBar { SearchBar {
......
/**************************************************************************
**
** 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
}
...@@ -31,14 +31,16 @@ ...@@ -31,14 +31,16 @@
**************************************************************************/ **************************************************************************/
import QtQuick 1.0 import QtQuick 1.0
import qtcomponents 1.0
GridView { GridView {
id: gridView
interactive: false interactive: false
width: scrollArea.width clip: true
cellHeight: 240 cellHeight: 240
cellWidth: 216 cellWidth: 216
property int columns: Math.max(Math.floor(width / cellWidth), 1) 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); x: Math.max((width - (cellWidth * columns)) / 2, 0);
...@@ -61,4 +63,28 @@ GridView { ...@@ -61,4 +63,28 @@ GridView {
tags: model.tags 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
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment