on xenial help sign in
Show the "all" button if you are on the root with a leaf selected
commitc1f85bab052a1cf9e021438be64616a0d063b0ee authorAlbert Astals <albert.astals@canonical.com> dateWed 28 May 2014, 14:30 (12 years ago) parent7d7c622
3 files changed+9−6
qml/Dash/DashDepartments.qml+1 qml/Dash/DashDepartmentsList.qml+6−4 tests/mocks/Unity/fake_department.cpp+2−2
qml/Dash/DashDepartments.qml+1
@@ -111,6 +111,7 @@ AbstractButton {
111111 width: departmentListView.width
112112 height: !root.showList ? 0 : department && department.loaded ? Math.min(implicitHeight, departmentListView.maxHeight) : departmentListView.prevHeight
113113 department: nullifyDepartment ? null : scope.getDepartment(departmentId)
114+ currentDepartment: root.currentDepartment
114115 onEnterDepartment: {
115116 scope.loadDepartment(newDepartmentId);
116117 // 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
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
tests/mocks/Unity/fake_department.cpp+2−2
@@ -82,7 +82,7 @@ bool Department::isRoot() const
8282
8383int Department::rowCount(const QModelIndex & /*parent*/) const
8484{
85− if (m_departmentId.startsWith("child"))
85+ if (m_departmentId.startsWith("child") || m_departmentId == "middle3")
8686 return 0;
8787 else
8888 return 8;
@@ -111,7 +111,7 @@ QVariant Department::data(const QModelIndex &index, int role) const
111111 return QString("%1Child%2").arg(m_departmentId).arg(index.row());
112112 break;
113113 case RoleHasChildren:
114− return m_departmentId == "root";
114+ return m_departmentId == "root" && index.row() != 3;
115115 break;
116116 case RoleIsActive:
117117 return m_scope->currentDepartment() == data(index, RoleDepartmentId);