Kirigami-addons

RoundedTreeDelegate.qml
1// SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu>
2// SPDX-License-Identifier: LGPL-2.1-only or LGPL-3.0-only or LicenseRef-KDE-Accepted-LGPL
3
4import QtQuick
5import QtQuick.Controls as QQC2
6import QtQuick.Layouts
7
8import org.kde.kirigami as Kirigami
9import org.kde.kirigamiaddons.delegates as Delegates
10import org.kde.kirigamiaddons.treeview as Tree
11import org.kde.kitemmodels
12
13/**
14 * Rounded item delegate meant to be used in combination with
15 * a ListView and a KDescendantsProxyModel to create a TreeView.
16 *
17 * @since KirigamiAddons 0.12.0
18 */
19Delegates.RoundedItemDelegate {
20 id: root
21
22 required property int index
23 required property int kDescendantLevel
24 required property var kDescendantHasSiblings
25 required property bool kDescendantExpandable
26 required property bool kDescendantExpanded
27
28 leftInset: (Qt.application.layoutDirection !== Qt.RightToLeft ? decoration.width + root.padding * 2 : 0)
29 leftPadding: (Qt.application.layoutDirection !== Qt.RightToLeft ? decoration.width + root.padding * 2 : 0) + Kirigami.Units.smallSpacing
30
31 rightInset: (Qt.application.layoutDirection === Qt.RightToLeft ? decoration.width + root.padding * 2 : 0) + Kirigami.Units.smallSpacing
32 rightPadding: (Qt.application.layoutDirection === Qt.RightToLeft ? decoration.width + root.padding * 2 : 0) + Kirigami.Units.smallSpacing * 2
33
34 data: Tree.TreeViewDecoration {
35 id: decoration
36
37 parent: root
38 parentDelegate: root
39 model: root.ListView.view.model
40
41 z: 2
42
43 index: root.index
44 kDescendantLevel: root.kDescendantLevel
45 kDescendantHasSiblings: root.kDescendantHasSiblings
46 kDescendantExpandable: root.kDescendantExpandable
47 kDescendantExpanded: root.kDescendantExpanded
48
49 anchors {
50 left: parent.left
51 top: parent.top
52 bottom: parent.bottom
53 leftMargin: parent.padding
54 }
55 }
56}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:48:17 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.