aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktableview/data/qqmllistpropertymodel.qml
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-07-20 14:05:09 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-02 09:50:35 +0000
commit382812cd2917180a160917d24b11825a7eeb2cf1 (patch)
treedac6fbf8260e90e0347e23b5f863128d9689607c /tests/auto/quick/qquicktableview/data/qqmllistpropertymodel.qml
parentca1f69757421845f563ebe90a5880509839efb31 (diff)
QQuickTableView: implement support for reusing delegate items
This patch will make use of the recent changes in QQmlTableInstanceModel to support reusing delegate items. The API in TableView to enable this will mainly be a new property "reuseItems". This property is true by default. By setting it to false, reusing items will never happen. When an item is reused, the signal "TableView.reused" is emitted after the fact, in case the delegate item needs to execute some extra code during the process. Likewise, a signal "TableView.pooled" is emitted when the item is pooled. From an implementation point of view, TableView only need to do two things to enable reusing of items. First, whenever it releases items, it provides a second argument to release(), informing QQmlTableInstanceModel if the item can be reused. Second, it needs to call drainReusePool() at appropriate times to ensure that no item will be kept alive in the pool for too long. Change-Id: I830e2eace776302ac58946733566208aa8954159 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview/data/qqmllistpropertymodel.qml')
-rw-r--r--tests/auto/quick/qquicktableview/data/qqmllistpropertymodel.qml85
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktableview/data/qqmllistpropertymodel.qml b/tests/auto/quick/qquicktableview/data/qqmllistpropertymodel.qml
new file mode 100644
index 0000000000..c866af8526
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/qqmllistpropertymodel.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** 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-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+import Qt.labs.tableview 1.0
+
+Item {
+ id: root
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ anchors.margins: 1
+ clip: true
+ delegate: tableViewDelegate
+ cacheBuffer: 0
+ }
+
+ Item {
+ Repeater {
+ model: 100
+ Item { property string someCustomProperty: index }
+ }
+ Component.onCompleted: tableView.model = children
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ objectName: "tableViewDelegate"
+ implicitWidth: 100
+ implicitHeight: 50
+ color: "lightgray"
+ border.width: 1
+
+ Text {
+ anchors.centerIn: parent
+ text: column
+ }
+ }
+ }
+
+}