on xenial help sign in
Show the "all" button if you are on the root with a leaf selected
c1f85baAlbert Astals
qml/Dash/DashDepartments.qml+1
@@ -111,6 +111,7 @@ AbstractButton {
111 width: departmentListView.width
111 width: departmentListView.width
112 height: !root.showList ? 0 : department && department.loaded ? Math.min(implicitHeight, departmentListView.maxHeight) : departmentListView.prevHeight
112 height: !root.showList ? 0 : department && department.loaded ? Math.min(implicitHeight, departmentListView.maxHeight) : departmentListView.prevHeight
113 department: nullifyDepartment ? null : scope.getDepartment(departmentId)
113 department: nullifyDepartment ? null : scope.getDepartment(departmentId)
114+ currentDepartment: root.currentDepartment
114 onEnterDepartment: {
115 onEnterDepartment: {
115 scope.loadDepartment(newDepartmentId);
116 scope.loadDepartment(newDepartmentId);
116 // We only need to add a new item to the model
117 // We only need to add a new item to the model
qml/Dash/DashDepartmentsList.qml+6−4
@@ -20,6 +20,7 @@ import Ubuntu.Components 0.1
20Item {
20Item {
21 id: root
21 id: root
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 {
51
52
52 anchors.fill: parent
53 anchors.fill: parent
53
54
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
57
59
@@ -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
63
65
64 onClicked: root.goBackToParentClicked();
66 onClicked: root.goBackToParentClicked();
65
67
@@ -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
102
104
103 Label {
105 Label {
@@ -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
133
135
134 onClicked: root.enterDepartment(departmentId, hasChildren)
136 onClicked: root.enterDepartment(departmentId, hasChildren)
135
137
tests/mocks/Unity/fake_department.cpp+2−2
@@ -82,7 +82,7 @@ bool Department::isRoot() const
82
82
83int Department::rowCount(const QModelIndex & /*parent*/) const
83int Department::rowCount(const QModelIndex & /*parent*/) const
84{
84{
85− if (m_departmentId.startsWith("child"))
85+ if (m_departmentId.startsWith("child") || m_departmentId == "middle3")
86 return 0;
86 return 0;
87 else
87 else
88 return 8;
88 return 8;
@@ -111,7 +111,7 @@ QVariant Department::data(const QModelIndex &index, int role) const
111 return QString("%1Child%2").arg(m_departmentId).arg(index.row());
111 return QString("%1Child%2").arg(m_departmentId).arg(index.row());
112 break;
112 break;
113 case RoleHasChildren:
113 case RoleHasChildren:
114− return m_departmentId == "root";
114+ return m_departmentId == "root" && index.row() != 3;
115 break;
115 break;
116 case RoleIsActive:
116 case RoleIsActive:
117 return m_scope->currentDepartment() == data(index, RoleDepartmentId);
117 return m_scope->currentDepartment() == data(index, RoleDepartmentId);