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 2 as QQC2
6import QtQuick.Layouts
7
8import org.kde.kirigami 2 as Kirigami
9import org.kde.kirigamiaddons.delegates 1 as Delegates
10import org.kde.kirigamiaddons.treeview 1.0 as Tree
11import org.kde.kitemmodels 1
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 index: root.index
42 kDescendantLevel: root.kDescendantLevel
43 kDescendantHasSiblings: root.kDescendantHasSiblings
44 kDescendantExpandable: root.kDescendantExpandable
45 kDescendantExpanded: root.kDescendantExpanded
46
47 anchors {
48 left: parent.left
49 top: parent.top
50 bottom: parent.bottom
51 leftMargin: parent.padding
52 }
53 }
54}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:46:57 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.