Warning, /libraries/kquickitemviews/tests/modeltest.qml is written in an unsupported language. File is not indexed.
0001 /*************************************************************************** 0002 * Copyright (C) 2017 by Emmanuel Lepage Vallee * 0003 * Author : Emmanuel Lepage Vallee <elv1313@gmail.com> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 3 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0017 **************************************************************************/ 0018 import QtQuick.Window 2.2 0019 import QtQuick 2.7 0020 import QtQuick.Layouts 1.0 0021 import QtQuick.Controls 2.0 0022 import org.kde.kirigami 2.2 as Kirigami 0023 import org.kde.playground.kquickitemviews 1.0 as KQuickItemViews 0024 import modeltest 1.0 0025 0026 Kirigami.ApplicationWindow { 0027 id: window 0028 visible: true 0029 0030 globalDrawer: Kirigami.GlobalDrawer { 0031 id: globalDrawer 0032 title: "KQuickItemViews" 0033 bannerImageSource: "" 0034 actions: [ 0035 Kirigami.Action { 0036 iconName: "document-edit" 0037 text: "HierarchyView" 0038 onTriggered: { 0039 treeViewLayout.visible = true 0040 freeFloatingLayout.visible = false 0041 listview.model = treeTester 0042 treeTester.run() 0043 } 0044 }, 0045 Kirigami.Action { 0046 iconName: "document-edit" 0047 text: "HierarchyView (list)" 0048 onTriggered: { 0049 // listview.model = treeTester2 0050 // treeTester2.run() 0051 } 0052 }, 0053 Kirigami.Action { 0054 iconName: "document-edit" 0055 text: "TreeView" 0056 onTriggered: {} 0057 }, 0058 Kirigami.Action { 0059 iconName: "document-edit" 0060 text: "ListView" 0061 onTriggered: {} 0062 }, 0063 Kirigami.Action { 0064 iconName: "document-edit" 0065 text: "FreeFloatingView" 0066 onTriggered: { 0067 treeViewLayout.visible = false 0068 freeFloatingLayout.visible = true 0069 } 0070 } 0071 ] 0072 handleVisible: true 0073 drawerOpen: false 0074 } 0075 0076 ModelViewTester { 0077 id: treeTester 0078 } 0079 0080 // ListModelTester { 0081 // id: treeTester2 0082 // } 0083 0084 FreeFloatingModel { 0085 id: freeFloatingModel 0086 } 0087 0088 ColumnLayout { 0089 id: treeViewLayout 0090 anchors.fill: parent 0091 0092 Slider { 0093 Layout.fillWidth: true 0094 from: 0 0095 to: 5000 0096 onValueChanged: treeTester.interval = value 0097 } 0098 0099 KQuickItemViews.TreeView { 0100 id: listview 0101 Layout.fillHeight: true 0102 Layout.fillWidth: true 0103 model: treeTester 0104 delegate: Rectangle { 0105 anchors.leftMargin: offset 0106 opacity: 0.7 0107 height: 20 0108 width: listview.width 0109 color: "blue" 0110 Text { 0111 anchors.leftMargin: offset 0112 anchors.fill: parent 0113 text: display 0114 color: "red" 0115 } 0116 } 0117 } 0118 } 0119 0120 ColumnLayout { 0121 id: freeFloatingLayout 0122 anchors.fill: parent 0123 KQuickItemViews.SizeHintView { 0124 id: sizehintview 0125 Layout.fillHeight: true 0126 Layout.fillWidth: true 0127 model: freeFloatingModel 0128 0129 delegate: Rectangle { 0130 color: index == 0 ? "red" : index == 1 ? "blue" : "green" 0131 border.width: 1 0132 border.color: "gray" 0133 0134 Text { 0135 anchors.fill: parent 0136 text: display 0137 } 0138 } 0139 } 0140 } 0141 }