Warning, /frameworks/kitemmodels/tests/proxymodeltestapp/tree.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 import QtQuick 2.6 0007 import QtQuick.Layouts 1.4 0008 import QtQuick.Controls as QQC2 0009 import org.kde.kitemmodels 1.0 0010 import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate 0011 0012 0013 QQC2.ScrollView { 0014 id: root 0015 width: 600 0016 height: 500 0017 0018 ListView { 0019 spacing: 0 0020 clip: true 0021 add: Transition { 0022 NumberAnimation { 0023 property: "opacity"; from: 0; to: 1; duration: 250 } 0024 } 0025 addDisplaced: Transition { 0026 NumberAnimation { properties: "y"; duration: 250 } 0027 } 0028 remove: Transition { 0029 NumberAnimation { 0030 property: "opacity"; from: 1; to: 0; duration: 250 } 0031 } 0032 removeDisplaced: Transition { 0033 NumberAnimation { properties: "y"; duration: 250 } 0034 } 0035 model: KDescendantsProxyModel { 0036 id: descendantsModel 0037 expandsByDefault: false 0038 model: _model 0039 } 0040 0041 delegate: QQC2.ItemDelegate { 0042 id: delegate 0043 highlighted: false 0044 0045 contentItem: RowLayout { 0046 RowLayout { 0047 Layout.topMargin: -delegate.topPadding 0048 Layout.bottomMargin: -delegate.bottomPadding 0049 Repeater { 0050 0051 model: kDescendantLevel-1 0052 0053 delegate: StylePrivate.StyleItem { 0054 Layout.preferredWidth: controlRoot.width 0055 Layout.fillHeight: true 0056 visible: true 0057 // control: controlRoot 0058 elementType: "itembranchindicator" 0059 properties: { 0060 "isItem": false, 0061 "hasSibling": kDescendantHasSiblings[modelData] 0062 } 0063 } 0064 } 0065 QQC2.Button { 0066 id: controlRoot 0067 Layout.preferredWidth: background.pixelMetric("treeviewindentation") 0068 Layout.fillHeight: true 0069 enabled: model.kDescendantExpandable 0070 text: model.kDescendantExpanded ? "-" : "+" 0071 onClicked: descendantsModel.toggleChildren(index) 0072 background: StylePrivate.StyleItem { 0073 id: styleitem 0074 control: controlRoot 0075 hover: controlRoot.hovered 0076 elementType: "itembranchindicator" 0077 on: model.kDescendantExpanded 0078 properties: { 0079 "isItem": true, 0080 "hasChildren": model.kDescendantExpandable, 0081 "hasSibling": model.kDescendantHasSiblings[model.kDescendantHasSiblings.length - 1] 0082 } 0083 } 0084 } 0085 } 0086 0087 QQC2.Label { 0088 Layout.fillWidth: true 0089 text: model.display 0090 } 0091 } 0092 } 0093 } 0094 }