18 import Ubuntu.Components 0.1
22 objectName:
"dashDepartments"
24 property var scope: null
26 property bool showList:
false
28 readonly
property var currentDepartment: scope && scope.hasDepartments ? scope.getDepartment(scope.currentDepartmentId) : null
30 property alias windowWidth: blackRect.width
31 property alias windowHeight: blackRect.height
32 property var scopeStyle: null
35 property bool isGoingBack:
false
37 visible: root.currentDepartment != null
39 height: visible ? units.gu(5) : 0
42 root.showList = !root.showList;
48 opacity: departmentListView.currentItem && departmentListView.currentItem.visible ? 0.3 : 0
49 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
50 anchors.top: departmentListView.top
51 anchors.right: parent.right
61 fillMode: Image.Stretch
62 source:
"graphics/dash_divider_top_lightgrad.png"
72 fillMode: Image.Stretch
73 source:
"graphics/dash_divider_top_darkgrad.png"
79 anchors.margins: units.gu(2)
80 verticalAlignment: Text.AlignVCenter
81 text: root.currentDepartment ? root.currentDepartment.label :
""
82 color: root.scopeStyle ? root.scopeStyle.foreground :
"grey"
86 anchors.verticalCenter: parent.verticalCenter
87 anchors.right: parent.right
88 anchors.rightMargin: units.gu(2)
89 name: showList ?
"up" :
"down"
92 color: root.scopeStyle ? root.scopeStyle.foreground :
"grey"
97 id: departmentListView
98 objectName:
"departmentListView"
99 orientation: ListView.Horizontal
101 clip: root.width != windowWidth
114 readonly
property int maxHeight: (windowHeight - mapToItem(null, root.x, root.y).y) - units.gu(8)
115 property int prevHeight: maxHeight
116 height: currentItem ? currentItem.height : maxHeight
119 prevHeight = currentItem.desiredHeight;
122 highlightMoveDuration: UbuntuAnimation.FastDuration
123 delegate: DashDepartmentsList {
124 objectName:
"department" + index
126 width: departmentListView.width
127 scopeStyle: root.scopeStyle
128 property real desiredHeight: {
130 if (department && department.loaded && x == departmentListView.contentX)
132 return Math.min(implicitHeight, departmentListView.maxHeight);
134 return departmentListView.prevHeight;
140 height: desiredHeight
141 department: (nullifyDepartment || !scope) ? null : scope.getDepartment(departmentId)
142 currentDepartment: root.currentDepartment
144 scope.loadDepartment(newDepartmentId);
149 departmentModel.append({
"departmentId": newDepartmentId,
"nullifyDepartment":
false});
150 departmentListView.currentIndex++;
155 onGoBackToParentClicked: {
156 scope.loadDepartment(department.parentDepartmentId);
158 departmentModel.setProperty(departmentListView.currentIndex - 1,
"nullifyDepartment",
false);
159 departmentListView.currentIndex--;
161 onAllDepartmentClicked: {
163 if (root.currentDepartment.parentDepartmentId == department.departmentId) {
165 scope.loadDepartment(root.currentDepartment.parentDepartmentId);
170 if (contentX == width * departmentListView.currentIndex) {
172 departmentModel.remove(departmentListView.currentIndex + 1);
174 departmentModel.setProperty(departmentListView.currentIndex - 1,
"nullifyDepartment",
true);
181 anchors.fill: departmentListView
182 enabled: root.showList
183 onClicked: root.showList =
false
187 departmentModel.clear();
188 if (scope && scope.hasDepartments) {
189 departmentModel.append({
"departmentId": scope.currentDepartmentId,
"nullifyDepartment":
false});
195 onHasDepartmentsChanged: {
196 if (scope.hasDepartments) {
197 departmentModel.append({
"departmentId": scope.currentDepartmentId,
"nullifyDepartment":
false});
199 departmentModel.clear();