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
34 property bool isGoingBack:
false
36 visible: root.currentDepartment != null
38 height: visible ? units.gu(5) : 0
41 root.showList = !root.showList;
47 opacity: departmentListView.currentItem && departmentListView.currentItem.visible ? 0.3 : 0
48 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
49 anchors.top: departmentListView.top
50 anchors.right: parent.right
60 fillMode: Image.Stretch
61 source:
"graphics/dash_divider_top_lightgrad.png"
71 fillMode: Image.Stretch
72 source:
"graphics/dash_divider_top_darkgrad.png"
78 anchors.margins: units.gu(2)
79 verticalAlignment: Text.AlignVCenter
80 text: root.currentDepartment ? root.currentDepartment.label :
""
85 anchors.verticalCenter: parent.verticalCenter
86 anchors.right: parent.right
87 anchors.rightMargin: units.gu(2)
88 rotation: showList ? 180 : 0
89 source:
"image://theme/dropdown-menu"
90 sourceSize.height: parent.height - units.gu(2)
91 sourceSize.width: units.gu(2)
92 fillMode: Image.PreserveAspectFit
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 property real desiredHeight: {
129 if (department && department.loaded && x == departmentListView.contentX)
131 return Math.min(implicitHeight, departmentListView.maxHeight);
133 return departmentListView.prevHeight;
139 height: desiredHeight
140 department: (nullifyDepartment || !scope) ? null : scope.getDepartment(departmentId)
141 currentDepartment: root.currentDepartment
143 scope.loadDepartment(newDepartmentId);
148 departmentModel.append({
"departmentId": newDepartmentId,
"nullifyDepartment":
false});
149 departmentListView.currentIndex++;
154 onGoBackToParentClicked: {
155 scope.loadDepartment(department.parentDepartmentId);
157 departmentModel.setProperty(departmentListView.currentIndex - 1,
"nullifyDepartment",
false);
158 departmentListView.currentIndex--;
160 onAllDepartmentClicked: {
162 if (root.currentDepartment.parentDepartmentId == department.departmentId) {
164 scope.loadDepartment(root.currentDepartment.parentDepartmentId);
169 if (contentX == width * departmentListView.currentIndex) {
171 departmentModel.remove(departmentListView.currentIndex + 1);
173 departmentModel.setProperty(departmentListView.currentIndex - 1,
"nullifyDepartment",
true);
180 anchors.fill: departmentListView
181 enabled: root.showList
182 onClicked: root.showList =
false
186 departmentModel.clear();
187 if (scope && scope.hasDepartments) {
188 departmentModel.append({
"departmentId": scope.currentDepartmentId,
"nullifyDepartment":
false});
194 onHasDepartmentsChanged: {
195 if (scope.hasDepartments) {
196 departmentModel.append({
"departmentId": scope.currentDepartmentId,
"nullifyDepartment":
false});
198 departmentModel.clear();