/usr/lib/x86_64-linux-gnu/qt5/qml/Ubuntu/Components/ListItems/1.2/Expandable.qml is in qml-module-ubuntu-components 1.3.1918+16.04.20160404-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.4
import Ubuntu.Components 1.2
/*!
\qmltype Expandable
\inqmlmodule Ubuntu.Components.ListItems 1.0
\ingroup ubuntu-listitems
\brief An expandable list item with no contents.
The Expandable class can be used for generic list items containing other
components such as buttons. It subclasses \l Empty and thus brings all that
functionality, but additionally provides means to expand and collapse the item.
When used together with an \l UbuntuListView or \l ExpandablesColumn it
can coordinate with other items in the list to make sure it is scrolled while
expanding to be fully visible in the view. Additionally it is made sure that
only one Expandable item is expanded at a time and it is collapsed when the
user clicks outside the item.
You can set \l expanded to true/false to expand/collapse the item.
Examples:
\qml
import Ubuntu.Components 1.2
import Ubuntu.Components.ListItems 1.0 as ListItem
Item {
ListModel {
id: listModel
}
ListItem.UbuntuListView {
anchors { left: parent.left; right: parent.right }
height: units.gu(24)
model: listModel
delegate: ListItem.Expandable {
id: expandingItem
expandedHeight: units.gu(30)
onClicked: {
expanded = true;
}
}
}
}
\endqml
*/
Empty {
id: root
implicitHeight: expanded ? priv.maxExpandedHeight : collapsedHeight
/*!
Reflects the expanded state. Set this to true/false to expand/collapse the item.
*/
property bool expanded: false
/*!
The collapsed (normal) height of the item. Defaults to the standard height for list items.
*/
property real collapsedHeight: __height
/*!
The expanded height of the item's content. Defaults to the same as collapsedHeight which
disables the expanding feature. In order for the item to be expandable, set this to the
expanded size. Note that the actual expanded size can be smaller if there is not enough
space in the containing list. In that case the item becomes flickable automatically.
*/
property real expandedHeight: collapsedHeight
/*!
If set to true, the item will collapse again when the user clicks somewhere in the always
visible (when collapsed) area.
*/
property bool collapseOnClick: false
/*!
Reparent any content to inside the Flickable
\qmlproperty QtObject children
\default
*/
default property alias children: flickableContent.data
/*! \internal */
QtObject {
id: priv
/*!
\internal
Points to the containing ExpandablesListView or ExpandablesColumn
*/
property Item view: root.ListView.view ? root.ListView.view : (root.parent.parent.parent.hasOwnProperty("expandItem") ? root.parent.parent.parent : null)
/*! \internal
Gives information whether this item is inside an item based container supporting Expandable items, such as ExpandablesColumn
*/
readonly property bool isInExpandableColumn: view && view !== undefined && view.hasOwnProperty("expandItem") && view.hasOwnProperty("collapse")
/*! \internal
Gives information whether this item is inside an index based container supporting Expandable items, such as UbuntuListView
*/
readonly property bool isInExpandableListView: view && view !== undefined && view.hasOwnProperty("expandedIndex")
/*! \internal
Gives information if there is another item expanded in the containing ExpandablesListView or ExpandablesColumn
*/
readonly property bool otherExpanded: (isInExpandableColumn && view.expandedItem !== null && view.expandedItem !== undefined && view.expandedItem !== root)
|| (isInExpandableListView && view.expandedIndex !== -1 && view.expandedIndex !== index)
/*! \internal
Gives information about the maximum expanded height, in case that is limited by the containing ExpandablesListView or ExpandablesColumn
*/
readonly property real maxExpandedHeight: (isInExpandableColumn || isInExpandableListView) ? Math.min(view.height - collapsedHeight, expandedHeight) : expandedHeight
}
states: [
State {
name: ""
PropertyChanges { target: root; opacity: 1 }
},
State {
name: "otherExpanded"; when: priv.otherExpanded
PropertyChanges { target: root; opacity: .5 }
},
State {
name: "expanded"; when: expanded
PropertyChanges { target: root; z: 3 }
}
]
Component.onCompleted: {
if (priv.isInExpandableListView && priv.view.expandedIndex == index) {
root.expanded = true;
}
}
Connections {
target: priv.isInExpandableListView ? priv.view : null
onExpandedIndexChanged: {
if (priv.view.expandedIndex == index) {
root.expanded = true;
} else if (root.expanded = true) {
root.expanded = false;
}
}
}
/*! \internal */
onExpandedChanged: {
if (!expanded) {
contentFlickable.contentY = 0;
}
if (priv.isInExpandableColumn) {
if (expanded) {
priv.view.expandItem(root);
} else {
priv.view.collapse();
}
}
}
Behavior on height {
UbuntuNumberAnimation {}
}
Behavior on opacity {
UbuntuNumberAnimation {}
}
Flickable {
id: contentFlickable
objectName: "__expandableContentFlickable"
anchors { fill: parent; leftMargin: root.__contentsMargins; rightMargin: __contentsMargins; bottomMargin: divider.height }
interactive: root.expanded && contentHeight > height + root.divider.height
contentHeight: root.expandedHeight
flickableDirection: Flickable.VerticalFlick
clip: true
Behavior on contentY {
UbuntuNumberAnimation {}
}
Item {
id: flickableContent
anchors {
left: parent.left
right: parent.right
}
height: childrenRect.height
}
}
MouseArea {
anchors { left: parent.left; top: parent.top; right: parent.right }
enabled: root.collapseOnClick && root.expanded
height: root.collapsedHeight
onClicked: {
if (priv.isInExpandableListView) {
priv.view.expandedIndex = -1;
} else {
root.expanded = false;
}
}
}
}
|