Plasma

plasmacomponents/qml/ListItem.qml
1 /*
2  SPDX-FileCopyrightText: 2010 Marco Martin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 import QtQuick 2.1
8 import org.kde.plasma.core 2.0 as PlasmaCore
9 
17 Item {
18  id: listItem
19  default property alias content: paddingItem.data
20 
26  property alias enabled: itemMouse.enabled
27 
34  signal clicked
35 
36 
44  signal pressAndHold
45 
50  property bool checked: false
51 
56  property bool sectionDelegate: false
57 
61  property alias containsMouse: itemMouse.containsMouse
62 
68  property bool separatorVisible: true
69 
70  width: parent ? parent.width : childrenRect.width
71  height: paddingItem.childrenRect.height + background.margins.top + background.margins.bottom
72 
73  implicitHeight: paddingItem.childrenRect.height + background.margins.top + background.margins.bottom
74 
75  PlasmaCore.FrameSvgItem {
76  id : background
77  imagePath: "widgets/listitem"
78  prefix: (listItem.sectionDelegate ? "section" :
79  (itemMouse.pressed || listItem.checked) ? "pressed" : "normal")
80 
81  anchors.fill: parent
82  visible: listItem.ListView.view ? listItem.ListView.view.highlight === null : true
83  }
84  PlasmaCore.SvgItem {
85  svg: PlasmaCore.Svg {imagePath: "widgets/listitem"}
86  elementId: "separator"
87  anchors {
88  left: parent.left
89  right: parent.right
90  top: parent.top
91  }
92  height: naturalSize.height
93  visible: separatorVisible && (listItem.sectionDelegate || (typeof(index) != "undefined" && index > 0 && !listItem.checked && !itemMouse.pressed))
94  }
95 
96  MouseArea {
97  id: itemMouse
98  anchors.fill: background
99  enabled: false
100  hoverEnabled: true
101 
102  onClicked: listItem.clicked()
103  onPressAndHold: listItem.pressAndHold()
104 
105  Item {
106  id: paddingItem
107  anchors {
108  fill: parent
109  leftMargin: background.margins.left
110  topMargin: background.margins.top
111  rightMargin: background.margins.right
112  bottomMargin: background.margins.bottom
113  }
114  }
115  }
116 
117  Accessible.role: Accessible.ListItem
118 }
QTextStream & left(QTextStream &s)
QTextStream & right(QTextStream &s)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Oct 20 2020 22:47:06 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.