• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

PlasmaComponents

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • plasmacomponents
  • qml
ListItem.qml
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Marco Martin <notmart@gmail.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Library General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 import QtQuick 1.0
21 import org.kde.plasma.core 0.1 as PlasmaCore
22 import "private/Config.js" as Config
23 
29 Item {
30  id: listItem
31  default property alias content: paddingItem.data
32 
38  property alias enabled: itemMouse.enabled
39  //item has been clicked or pressed+hold
40 
47  signal clicked
48 
49 
57  signal pressAndHold
58 
63  //plasma extension
64  //always look pressed?
65  property bool checked: false
66 
71  //is this to be used as section delegate?
72  property bool sectionDelegate: false
73 
74  width: parent ? parent.width : childrenRect.width
75  height: paddingItem.childrenRect.height + background.margins.top + background.margins.bottom
76 
77  property int implicitHeight: paddingItem.childrenRect.height + background.margins.top + background.margins.bottom
78 
79 
80  Connections {
81  target: listItem
82  onCheckedChanged: background.prefix = (listItem.checked ? "pressed" : "normal")
83  onSectionDelegateChanged: background.prefix = (listItem.sectionDelegate ? "section" : "normal")
84  }
85 
86  PlasmaCore.FrameSvgItem {
87  id : background
88  imagePath: "widgets/listitem"
89  prefix: "normal"
90 
91  anchors.fill: parent
92  visible: listItem.ListView.view ? listItem.ListView.view.highlight === null : true
93  opacity: itemMouse.containsMouse && !itemMouse.pressed ? 0.5 : 1
94  Component.onCompleted: {
95  prefix = (listItem.sectionDelegate ? "section" : (listItem.checked ? "pressed" : "normal"))
96  }
97  Behavior on opacity { NumberAnimation { duration: 200 } }
98  }
99  PlasmaCore.SvgItem {
100  svg: PlasmaCore.Svg {imagePath: "widgets/listitem"}
101  elementId: "separator"
102  anchors {
103  left: parent.left
104  right: parent.right
105  top: parent.top
106  }
107  height: naturalSize.height
108  visible: listItem.sectionDelegate || (typeof(index) != "undefined" && index > 0 && !listItem.checked && !itemMouse.pressed)
109  }
110 
111  MouseArea {
112  id: itemMouse
113  property bool changeBackgroundOnPress: !listItem.checked && !listItem.sectionDelegate
114  anchors.fill: background
115  enabled: false
116  hoverEnabled: Config.mouseOverEnabled
117 
118  onClicked: listItem.clicked()
119  onPressAndHold: listItem.pressAndHold()
120  onPressed: if (changeBackgroundOnPress) background.prefix = "pressed"
121  onReleased: if (changeBackgroundOnPress) background.prefix = "normal"
122  onCanceled: if (changeBackgroundOnPress) background.prefix = "normal"
123  }
124 
125  Item {
126  id: paddingItem
127  anchors {
128  fill: background
129  leftMargin: background.margins.left
130  topMargin: background.margins.top
131  rightMargin: background.margins.right
132  bottomMargin: background.margins.bottom
133  }
134  }
135 }
Item
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PlasmaComponents

Skip menu "PlasmaComponents"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal