Warning, /plasma/plasma-systemmonitor/src/table/FirstCellDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 import QtQuick 2.12 0008 import QtQuick.Controls 2.12 0009 import QtQuick.Layouts 1.12 0010 import QtQml.Models 2.12 0011 0012 import org.kde.kirigami 2.2 as Kirigami 0013 0014 BaseCellDelegate { 0015 id: delegate 0016 0017 property string iconName 0018 property string text: model.display != undefined ? model.display : "" 0019 property real iconSize: Kirigami.Units.iconSizes.small 0020 property bool treeDecorationVisible: false 0021 0022 leftPadding: Kirigami.Units.largeSpacing 0023 0024 contentItem: RowLayout { 0025 id: row 0026 property Item treeDecoration 0027 Kirigami.Icon { 0028 id:blah 0029 Layout.preferredWidth: delegate.iconName != "" ? delegate.iconSize : 0 0030 Layout.preferredHeight: Layout.preferredWidth 0031 source: delegate.iconName 0032 fallback: "" 0033 } 0034 Label { 0035 id: label 0036 0037 padding: Kirigami.Units.smallSpacing 0038 0039 Layout.fillWidth: true 0040 Layout.fillHeight: true 0041 text: delegate.text 0042 horizontalAlignment: Text.AlignLeft 0043 elide: Text.ElideRight 0044 } 0045 } 0046 0047 hoverEnabled: true 0048 0049 onTreeDecorationVisibleChanged: { 0050 if (treeDecorationVisible) { 0051 var component = Qt.createComponent("TreeDecoration.qml") 0052 if (component.status == Component.Ready) { 0053 var incubator = component.incubateObject(null, { 0054 hasSiblings: Qt.binding(() => model.kDescendantHasSiblings), 0055 level: Qt.binding(() => model.kDescendantLevel), 0056 expandable: Qt.binding(() => model.kDescendantExpandable), 0057 expanded: Qt.binding(() => model.kDescendantExpanded) 0058 }) 0059 var finishCreation = () => { 0060 row.treeDecoration = incubator.object 0061 row.treeDecoration.clicked.connect(() => descendantsModel.toggleChildren(index)) 0062 var children = Array.from(row.children) 0063 children.unshift(row.treeDecoration) 0064 row.children = children 0065 } 0066 if (incubator.status == Component.Ready) { 0067 finishCreation() 0068 } else { 0069 incubator.onStatusChanged = (status) => { 0070 if (status == Component.Ready) { 0071 finishCreation() 0072 } 0073 } 0074 } 0075 } 0076 } else { 0077 if (row.treeDecoration) { 0078 row.treeDecoration.destroy() 0079 } 0080 } 0081 } 0082 ToolTip.text: delegate.text 0083 ToolTip.delay: Kirigami.Units.toolTipDelay 0084 ToolTip.visible: delegate.hovered && label.truncated 0085 }