@@ -20,6 +20,7 @@ import Ubuntu.Components 0.1
2020Item {
2121 id: root
2222 property var department: null
23+ property var currentDepartment: null
2324 signal enterDepartment(var newDepartmentId, bool hasChildren)
2425 signal goBackToParentClicked()
2526 signal allDepartmentClicked()
@@ -51,7 +52,8 @@ Item {
5152
5253 anchors.fill: parent
5354
54− readonly property int nItems: department && department.loaded ? (department.count + (department.isRoot ? 0 : 2)) : 0
55+ readonly property int nTopButtonsVisible: 0 + (backButton.visible ? 1 : 0) + (allButton.visible ? 1 : 0)
56+ readonly property int nItems: department && department.loaded ? (department.count + nTopButtonsVisible) : 0
5557 contentHeight: nItems * root.itemHeight
5658 contentWidth: width
5759
@@ -59,7 +61,7 @@ Item {
5961 id: backButton
6062 width: parent.width
6163 visible: department && !department.isRoot
62− height: itemHeight
64+ height: visible ? itemHeight : 0
6365
6466 onClicked: root.goBackToParentClicked();
6567
@@ -97,7 +99,7 @@ Item {
9799 id: allButton
98100 anchors.top: backButton.bottom
99101 width: parent.width
100− visible: backButton.visible
102+ visible: department && (!department.isRoot || currentDepartment.parentId == department.departmentId)
101103 height: itemHeight
102104
103105 Label {
@@ -129,7 +131,7 @@ Item {
129131 delegate: AbstractButton {
130132 height: root.itemHeight
131133 width: root.width
132− y: ((department.isRoot ? 0 : 2) + index) * root.itemHeight
134+ y: (flickable.nTopButtonsVisible + index) * root.itemHeight
133135
134136 onClicked: root.enterDepartment(departmentId, hasChildren)
135137