2
* Copyright (C) 2014 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
import Ubuntu.Components 0.1
22
property var department: null
23
property var currentDepartment: null
24
signal enterDepartment(var newDepartmentId, bool hasChildren)
25
signal goBackToParentClicked()
26
signal allDepartmentClicked()
28
readonly property int itemHeight: units.gu(5)
29
implicitHeight: flickable.contentHeight
38
anchors.centerIn: parent
39
running: !(department && department.loaded)
44
UbuntuNumberAnimation {
46
duration: UbuntuAnimation.SnapDuration
55
contentHeight: column.height
62
// TODO: check if SDK ListItems could be used here
63
// and if not make them be useful since this is a quite common pattern
67
objectName: "backButton"
69
visible: department && !department.isRoot || false
72
onClicked: root.goBackToParentClicked();
77
verticalCenter: parent.verticalCenter
79
leftMargin: units.gu(2)
81
source: "image://theme/back"
82
sourceSize.height: parent.height - units.gu(3)
83
sourceSize.width: units.gu(3)
84
fillMode: Image.PreserveAspectFit
89
verticalCenter: parent.verticalCenter
91
leftMargin: units.gu(0.5)
93
text: department ? department.parentLabel : ""
94
color: "gray" // TODO remove once we're a separate app
102
leftMargin: units.gu(2)
103
rightMargin: units.gu(2)
113
objectName: "allButton"
115
visible: department && (!department.isRoot || (root.currentDepartment && !root.currentDepartment.isRoot && root.currentDepartment.parentDepartmentId == department.departmentId)) || false
120
verticalCenter: parent.verticalCenter
122
leftMargin: units.gu(2)
124
text: department ? (department.allLabel != "" ? department.allLabel : department.label) : ""
126
color: "gray" // TODO remove once we're a separate app
131
bottom: parent.bottom
134
leftMargin: units.gu(2)
135
rightMargin: units.gu(2)
142
onClicked: root.allDepartmentClicked();
146
model: department && department.loaded ? department : null
148
delegate: AbstractButton {
149
objectName: root.objectName + "child" + index
150
height: root.itemHeight
153
onClicked: root.enterDepartment(departmentId, hasChildren)
157
verticalCenter: parent.verticalCenter
159
leftMargin: units.gu(2)
162
color: "gray" // TODO remove once we're a separate app
167
verticalCenter: parent.verticalCenter
169
rightMargin: units.gu(2)
171
source: hasChildren ? "image://theme/chevron" : "graphics/tick.png"
172
sourceSize.height: parent.height - units.gu(3)
173
sourceSize.width: units.gu(3)
174
fillMode: Image.PreserveAspectFit
175
visible: hasChildren || isActive
180
bottom: parent.bottom
183
leftMargin: units.gu(2)
184
rightMargin: units.gu(2)
189
visible: index != department.count - 1