Changeset View
Changeset View
Standalone View
Standalone View
src/declarativeimports/plasmacomponents/qml/ListItem.qml
Show All 26 Lines | |||||
27 | * | 27 | * | ||
28 | * @inherit QtQuick.Item | 28 | * @inherit QtQuick.Item | ||
29 | */ | 29 | */ | ||
30 | Item { | 30 | Item { | ||
31 | id: listItem | 31 | id: listItem | ||
32 | default property alias content: paddingItem.data | 32 | default property alias content: paddingItem.data | ||
33 | 33 | | |||
34 | /** | 34 | /** | ||
35 | * type:bool Holds if the item emits signals related to mouse interaction. | 35 | * type: bool | ||
36 | * | 36 | * True if the item emits signals related to mouse interaction. | ||
37 | * The default value is false. | 37 | * The default value is false. | ||
38 | */ | 38 | */ | ||
39 | property alias enabled: itemMouse.enabled | 39 | property alias enabled: itemMouse.enabled | ||
40 | //item has been clicked or pressed+hold | | |||
41 | 40 | | |||
42 | /** | 41 | /** | ||
43 | * This signal is emitted when there is a click. | 42 | * This signal is emitted when there is a click. | ||
44 | * | 43 | * | ||
45 | * This is disabled by default, set enabled to true to use it. | 44 | * This is disabled by default, set enabled to true to use it. | ||
46 | * @see enabled | 45 | * @see enabled | ||
47 | */ | 46 | */ | ||
48 | signal clicked | 47 | signal clicked | ||
49 | 48 | | |||
50 | 49 | | |||
51 | /** | 50 | /** | ||
52 | * The user pressed the item with the mouse and didn't release it for a | 51 | * The user pressed the item with the mouse and didn't release it for a | ||
53 | * certain amount of time. | 52 | * certain amount of time. | ||
54 | * | 53 | * | ||
55 | * This is disabled by default, set enabled to true to use it. | 54 | * This is disabled by default, set enabled to true to use it. | ||
56 | * @see enabled | 55 | * @see enabled | ||
57 | */ | 56 | */ | ||
58 | signal pressAndHold | 57 | signal pressAndHold | ||
59 | 58 | | |||
60 | /** | 59 | /** | ||
61 | * If true makes the list item look as checked or pressed. It has to be set | 60 | * If true makes the list item look as checked or pressed. It has to be set | ||
62 | * from the code, it won't change by itself. | 61 | * from the code, it won't change by itself. | ||
63 | */ | 62 | */ | ||
64 | //plasma extension | | |||
65 | //always look pressed? | | |||
66 | property bool checked: false | 63 | property bool checked: false | ||
67 | 64 | | |||
68 | /** | 65 | /** | ||
69 | * If true the item will be a delegate for a section, so will look like a | 66 | * If true the item will be a delegate for a section, so will look like a | ||
70 | * "title" for the otems under it. | 67 | * "title" for the items under it. | ||
71 | */ | 68 | */ | ||
72 | //is this to be used as section delegate? | | |||
73 | property bool sectionDelegate: false | 69 | property bool sectionDelegate: false | ||
74 | 70 | | |||
75 | /** | 71 | /** | ||
76 | * True if the list item contains mouse | 72 | * True if the list item contains mouse | ||
77 | */ | 73 | */ | ||
78 | property alias containsMouse: itemMouse.containsMouse | 74 | property alias containsMouse: itemMouse.containsMouse | ||
79 | 75 | | |||
80 | /** | 76 | /** | ||
Show All 11 Lines | |||||
92 | PlasmaCore.FrameSvgItem { | 88 | PlasmaCore.FrameSvgItem { | ||
93 | id : background | 89 | id : background | ||
94 | imagePath: "widgets/listitem" | 90 | imagePath: "widgets/listitem" | ||
95 | prefix: (listItem.sectionDelegate ? "section" : | 91 | prefix: (listItem.sectionDelegate ? "section" : | ||
96 | (itemMouse.pressed || listItem.checked) ? "pressed" : "normal") | 92 | (itemMouse.pressed || listItem.checked) ? "pressed" : "normal") | ||
97 | 93 | | |||
98 | anchors.fill: parent | 94 | anchors.fill: parent | ||
99 | visible: listItem.ListView.view ? listItem.ListView.view.highlight === null : true | 95 | visible: listItem.ListView.view ? listItem.ListView.view.highlight === null : true | ||
100 | Behavior on opacity { NumberAnimation { duration: units.longDuration } } | | |||
101 | } | 96 | } | ||
102 | PlasmaCore.SvgItem { | 97 | PlasmaCore.SvgItem { | ||
103 | svg: PlasmaCore.Svg {imagePath: "widgets/listitem"} | 98 | svg: PlasmaCore.Svg {imagePath: "widgets/listitem"} | ||
104 | elementId: "separator" | 99 | elementId: "separator" | ||
105 | anchors { | 100 | anchors { | ||
106 | left: parent.left | 101 | left: parent.left | ||
107 | right: parent.right | 102 | right: parent.right | ||
108 | top: parent.top | 103 | top: parent.top | ||
109 | } | 104 | } | ||
110 | height: naturalSize.height | 105 | height: naturalSize.height | ||
111 | visible: separatorVisible && (listItem.sectionDelegate || (typeof(index) != "undefined" && index > 0 && !listItem.checked && !itemMouse.pressed)) | 106 | visible: separatorVisible && (listItem.sectionDelegate || (typeof(index) != "undefined" && index > 0 && !listItem.checked && !itemMouse.pressed)) | ||
112 | } | 107 | } | ||
113 | 108 | | |||
114 | MouseArea { | 109 | MouseArea { | ||
115 | id: itemMouse | 110 | id: itemMouse | ||
116 | property bool changeBackgroundOnPress: !listItem.checked && !listItem.sectionDelegate | | |||
117 | anchors.fill: background | 111 | anchors.fill: background | ||
118 | enabled: false | 112 | enabled: false | ||
119 | hoverEnabled: true | 113 | hoverEnabled: true | ||
120 | 114 | | |||
121 | onClicked: listItem.clicked() | 115 | onClicked: listItem.clicked() | ||
122 | onPressAndHold: listItem.pressAndHold() | 116 | onPressAndHold: listItem.pressAndHold() | ||
123 | 117 | | |||
124 | Item { | 118 | Item { | ||
Show All 13 Lines |