Libplasma

ListItem.qml
1/*
2 SPDX-FileCopyrightText: 2020 Carson Black <uhhadd@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7import QtQuick
8import org.kde.plasma.components as PC3
9import org.kde.kirigami as Kirigami
10import org.kde.ksvg as KSvg
11
12PC3.ItemDelegate {
13 id: __listItem
14
15 /**
16 * content: list<Object>
17 *
18 * The content of this ListItem.
19 */
20 default property alias content: __innerItem.data
21
22 /**
23 * separatorVisible: bool
24 *
25 * Whether this ListItem displays a separator.
26 */
27 property bool separatorVisible: true
28
29 /**
30 * sectionDelegate: bool
31 *
32 * Whether this ListItem renders as a section header.
33 */
34 property bool sectionDelegate: false
35
36 /**
37 * containsMouse: bool
38 *
39 * Whether this ListItem contains the mouse.
40 *
41 * Alias of Control.hovered.
42 */
43 readonly property bool containsMouse: hovered
44
45 leftPadding: __background.margins.left
46 rightPadding: __background.margins.right
47 topPadding: __background.margins.top
48 bottomPadding: __background.margins.bottom
49
50 // TODO KF6: `implicitContentWidth, implicitBackgroundWidth, leftInset and rightInset are not available in Controls 2.2 which this component is based on.
51 implicitWidth: (contentItem ? contentItem.implicitWidth : 0) + leftPadding + rightPadding
52
53 // TODO KF6: Make this behave more like the normal Control default.
54 // Behaving this way for backwards compatibility reasons.
55 contentItem: Item {
56 id: __innerItem
57 }
58
59 background: KSvg.FrameSvgItem {
60 id: __background
61 imagePath: "widgets/listitem"
62 prefix: (__listItem.sectionDelegate ? "section" :
63 (__listItem.pressed || __listItem.checked) ? "pressed" : "normal")
64
65 anchors.fill: parent
66 visible: __listItem.ListView.view ? __listItem.ListView.view.highlight === null : true
67
68 KSvg.SvgItem {
69 svg: KSvg.Svg {
70 imagePath: "widgets/listitem"
71 }
72 elementId: "separator"
73 anchors {
74 left: parent.left
75 right: parent.right
76 top: parent.top
77 }
78 height: naturalSize.height
79 visible: __listItem.separatorVisible && (__listItem.sectionDelegate || (typeof(index) != "undefined" && index > 0 && !__listItem.checked && !__listItem.pressed))
80 }
81 }
82}
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:34:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.