Warning, /libraries/kirigami-addons/src/treeview/qml/BasicTreeItem.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Marco Martin <notmart@gmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.1 0008 import QtQuick.Layouts 1.2 0009 import QtQuick.Controls 2.0 as QQC2 0010 import org.kde.kirigami 2.14 0011 import org.kde.kirigamiaddons.treeview 1.0 as TreeView 0012 0013 /** 0014 * An item delegate for the TreeListView and TreeTableView components. 0015 * 0016 * It's intended to make all tree views look coherent. 0017 * It has a default icon and a label 0018 * 0019 * @since org.kde.kirigamiaddons.treeview 1.0 0020 */ 0021 TreeView.AbstractTreeItem { 0022 id: listItem 0023 0024 /** 0025 * This property holds the single text label the list item will contain. 0026 * 0027 * @since org.kde.kirigamiaddons.treeview 1.0 0028 */ 0029 property alias label: listItem.text 0030 0031 /** 0032 * This property holds a subtitle that goes below the main label. 0033 * Optional; if not defined, the list item will only have a main label. 0034 * 0035 * @since org.kde.kirigamiaddons.treeview 1.0 0036 */ 0037 property alias subtitle: subtitleItem.text 0038 0039 /** 0040 * This property controls whether the text (in both primary text and subtitle) 0041 * should be rendered as bold. 0042 * 0043 * @since org.kde.kirigamiaddons.treeview 1.0 0044 */ 0045 property bool bold: false 0046 0047 /** 0048 * This property holds the preferred size for the icon. 0049 * 0050 * @since org.kde.kirigamiaddons.treeview 1.0 0051 */ 0052 property alias iconSize: iconItem.size 0053 0054 /** 0055 * This property holds the color the icon should be colorized to. 0056 * If the icon shouldn't be colorized in any way, set it to "transparent" 0057 * 0058 * By default it will be the text color. 0059 * 0060 * @since org.kde.kirigamiaddons.treeview 1.0 0061 */ 0062 property alias iconColor: iconItem.color 0063 0064 /** 0065 * @brief This property holds whether when there is no icon the space will 0066 * still be reserved for it. 0067 * 0068 * It's useful in layouts where only some entries have an icon, having the 0069 * text all horizontally aligned. 0070 */ 0071 property alias reserveSpaceForIcon: iconItem.visible 0072 0073 /** 0074 * @brief This property holds whether the label will try to be as wide as 0075 * possible. 0076 * 0077 * It's useful in layouts containing entries without text. By default, true. 0078 */ 0079 property alias reserveSpaceForLabel: labelItem.visible 0080 0081 default property alias _basicDefault: layout.data 0082 0083 contentItem: RowLayout { 0084 id: layout 0085 spacing: Kirigami.Units.smallSpacing 0086 Icon { 0087 id: iconItem 0088 0089 property int size: visible ? Units.iconSizes.smallMedium : 0 0090 0091 source: { 0092 if (listItem.icon.name.length > 0) { 0093 return listItem.icon.name; 0094 } 0095 0096 return listItem.icon.source; 0097 } 0098 selected: (listItem.highlighted || listItem.checked || (listItem.pressed && listItem.supportsMouseEvents)) 0099 visible: listItem.icon.name.length > 0 || listItem.icon.source.length > 0 0100 0101 Layout.minimumHeight: size 0102 Layout.maximumHeight: size 0103 Layout.minimumWidth: size 0104 Layout.maximumWidth: size 0105 } 0106 0107 ColumnLayout { 0108 spacing: 0 0109 Layout.fillWidth: true 0110 Layout.alignment: Qt.AlignVCenter 0111 QQC2.Label { 0112 id: labelItem 0113 text: listItem.text 0114 Layout.fillWidth: true 0115 color: (listItem.highlighted || listItem.checked || (listItem.pressed && listItem.supportsMouseEvents)) ? listItem.activeTextColor : listItem.textColor 0116 elide: Text.ElideRight 0117 font.weight: listItem.bold ? Font.Bold : Font.Normal 0118 opacity: 1 0119 } 0120 QQC2.Label { 0121 id: subtitleItem 0122 Layout.fillWidth: true 0123 color: (listItem.highlighted || listItem.checked || (listItem.pressed && listItem.supportsMouseEvents)) ? listItem.activeTextColor : listItem.textColor 0124 elide: Text.ElideRight 0125 font: Theme.smallFont 0126 opacity: listItem.bold ? 0.9 : 0.7 0127 visible: text.length > 0 0128 } 0129 } 0130 } 0131 }