@@ -20,6 +20,7 @@ import Ubuntu.Components 0.1
22 property var department: null
22 property var department: null
23+ property var currentDepartment: null
23 signal enterDepartment(var newDepartmentId, bool hasChildren)
24 signal enterDepartment(var newDepartmentId, bool hasChildren)
24 signal goBackToParentClicked()
25 signal goBackToParentClicked()
25 signal allDepartmentClicked()
26 signal allDepartmentClicked()
@@ -51,7 +52,8 @@ Item {
52 anchors.fill: parent
53 anchors.fill: parent
55+ readonly property int nTopButtonsVisible: 0 + (backButton.visible ? 1 : 0) + (allButton.visible ? 1 : 0)
54− readonly property int nItems: department && department.loaded ? (department.count + (department.isRoot ? 0 : 2)) : 0
56+ readonly property int nItems: department && department.loaded ? (department.count + nTopButtonsVisible) : 0
55 contentHeight: nItems * root.itemHeight
57 contentHeight: nItems * root.itemHeight
56 contentWidth: width
58 contentWidth: width
@@ -59,7 +61,7 @@ Item {
59 id: backButton
61 id: backButton
60 width: parent.width
62 width: parent.width
61 visible: department && !department.isRoot
63 visible: department && !department.isRoot
62− height: itemHeight
64+ height: visible ? itemHeight : 0
64 onClicked: root.goBackToParentClicked();
66 onClicked: root.goBackToParentClicked();
@@ -97,7 +99,7 @@ Item {
97 id: allButton
99 id: allButton
98 anchors.top: backButton.bottom
100 anchors.top: backButton.bottom
99 width: parent.width
101 width: parent.width
100− visible: backButton.visible
102+ visible: department && (!department.isRoot || currentDepartment.parentId == department.departmentId)
101 height: itemHeight
103 height: itemHeight
@@ -129,7 +131,7 @@ Item {
129 delegate: AbstractButton {
131 delegate: AbstractButton {
130 height: root.itemHeight
132 height: root.itemHeight
131 width: root.width
133 width: root.width
132− y: ((department.isRoot ? 0 : 2) + index) * root.itemHeight
134+ y: (flickable.nTopButtonsVisible + index) * root.itemHeight
134 onClicked: root.enterDepartment(departmentId, hasChildren)
136 onClicked: root.enterDepartment(departmentId, hasChildren)