on xenial help sign in
more department -> navigation renaming
commit60661e3f599c590dfddee8d7061b31bbe7f43088 authorAlbert Astals <albert.astals@canonical.com> dateMon 4 Aug 2014, 10:57 (12 years ago) parent30fc442
3 files changed+143−143
qml/Dash/DashNavigation.qml+37−37 qml/Dash/DashNavigationList.qml+13−13 tests/qmltests/Dash/tst_DashContent.qml+93−93
qml/Dash/DashNavigation.qml+37−37
@@ -19,13 +19,13 @@ import Ubuntu.Components 1.1
1919
2020AbstractButton {
2121 id: root
22− objectName: "dashDepartments"
22+ objectName: "dashNavigation"
2323
2424 property var scope: null
2525
2626 property bool showList: false
2727
28− readonly property var currentDepartment: scope && scope.hasNavigation ? scope.getNavigation(scope.currentNavigationId) : null
28+ readonly property var currentNavigation: scope && scope.hasNavigation ? scope.getNavigation(scope.currentNavigationId) : null
2929
3030 property alias windowWidth: blackRect.width
3131 property alias windowHeight: blackRect.height
@@ -34,7 +34,7 @@ AbstractButton {
3434 // Are we drilling down the tree or up?
3535 property bool isGoingBack: false
3636
37− visible: root.currentDepartment != null
37+ visible: root.currentNavigation != null
3838
3939 height: visible ? units.gu(5) : 0
4040
@@ -45,9 +45,9 @@ AbstractButton {
4545 Rectangle {
4646 id: blackRect
4747 color: "black"
48− opacity: departmentListView.currentItem && departmentListView.currentItem.visible ? 0.3 : 0
48+ opacity: navigationListView.currentItem && navigationListView.currentItem.visible ? 0.3 : 0
4949 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
50− anchors.top: departmentListView.top
50+ anchors.top: navigationListView.top
5151 anchors.right: parent.right
5252 visible: opacity != 0
5353 }
@@ -78,7 +78,7 @@ AbstractButton {
7878 anchors.fill: parent
7979 anchors.margins: units.gu(2)
8080 verticalAlignment: Text.AlignVCenter
81− text: root.currentDepartment ? root.currentDepartment.label : ""
81+ text: root.currentNavigation ? root.currentNavigation.label : ""
8282 color: root.scopeStyle ? root.scopeStyle.foreground : "grey"
8383 }
8484
@@ -92,18 +92,18 @@ AbstractButton {
9292 color: root.scopeStyle ? root.scopeStyle.foreground : "grey"
9393 }
9494
95− // departmentListView is outside root
95+ // navigationListView is outside root
9696 ListView {
97− id: departmentListView
98− objectName: "departmentListView"
97+ id: navigationListView
98+ objectName: "navigationListView"
9999 orientation: ListView.Horizontal
100100 interactive: false
101101 clip: root.width != windowWidth
102102 model: ListModel {
103− id: departmentModel
103+ id: navigationModel
104104 // We have two roles
105− // navigationId: the department id of the department the list represents
106− // nullifyDepartment: overrides navigationId to be null
105+ // navigationId: the navigation id of the navigation the list represents
106+ // nullifyNavigation: overrides navigationId to be null
107107 // This is used to "clear" the delegate when going "right" on the tree
108108 }
109109 anchors {
@@ -121,72 +121,72 @@ AbstractButton {
121121 }
122122 highlightMoveDuration: UbuntuAnimation.FastDuration
123123 delegate: DashNavigationList {
124− objectName: "department" + index
124+ objectName: "navigation" + index
125125 visible: height != 0
126− width: departmentListView.width
126+ width: navigationListView.width
127127 scopeStyle: root.scopeStyle
128128 property real desiredHeight: {
129129 if (root.showList) {
130− if (department && department.loaded && x == departmentListView.contentX)
130+ if (navigation && navigation.loaded && x == navigationListView.contentX)
131131 {
132− return Math.min(implicitHeight, departmentListView.maxHeight);
132+ return Math.min(implicitHeight, navigationListView.maxHeight);
133133 } else {
134− return departmentListView.prevHeight;
134+ return navigationListView.prevHeight;
135135 }
136136 } else {
137137 return 0;
138138 }
139139 }
140140 height: desiredHeight
141− department: (nullifyDepartment || !scope) ? null : scope.getNavigation(navigationId)
142− currentDepartment: root.currentDepartment
143− onEnterDepartment: {
144− scope.performQuery(departmentQuery);
141+ navigation: (nullifyNavigation || !scope) ? null : scope.getNavigation(navigationId)
142+ currentNavigation: root.currentNavigation
143+ onEnterNavigation: {
144+ scope.performQuery(navigationQuery);
145145 // We only need to add a new item to the model
146146 // if we have children, otherwise just load it
147147 if (hasChildren) {
148148 isGoingBack = false;
149− departmentModel.append({"navigationId": newNavigationId, "nullifyDepartment": false});
150− departmentListView.currentIndex++;
149+ navigationModel.append({"navigationId": newNavigationId, "nullifyNavigation": false});
150+ navigationListView.currentIndex++;
151151 } else {
152152 showList = false;
153153 }
154154 }
155155 onGoBackToParentClicked: {
156− scope.performQuery(department.parentQuery);
156+ scope.performQuery(navigation.parentQuery);
157157 isGoingBack = true;
158− departmentModel.setProperty(departmentListView.currentIndex - 1, "nullifyDepartment", false);
159− departmentListView.currentIndex--;
158+ navigationModel.setProperty(navigationListView.currentIndex - 1, "nullifyNavigation", false);
159+ navigationListView.currentIndex--;
160160 }
161− onAllDepartmentClicked: {
161+ onAllNavigationClicked: {
162162 showList = false;
163− if (root.currentDepartment.parentNavigationId == department.navigationId) {
163+ if (root.currentNavigation.parentNavigationId == navigation.navigationId) {
164164 // For leaves we have to go to the parent too
165− scope.performQuery(root.currentDepartment.parentQuery);
165+ scope.performQuery(root.currentNavigation.parentQuery);
166166 }
167167 }
168168 }
169169 onContentXChanged: {
170− if (contentX == width * departmentListView.currentIndex) {
170+ if (contentX == width * navigationListView.currentIndex) {
171171 if (isGoingBack) {
172− departmentModel.remove(departmentListView.currentIndex + 1);
172+ navigationModel.remove(navigationListView.currentIndex + 1);
173173 } else {
174− departmentModel.setProperty(departmentListView.currentIndex - 1, "nullifyDepartment", true);
174+ navigationModel.setProperty(navigationListView.currentIndex - 1, "nullifyNavigation", true);
175175 }
176176 }
177177 }
178178 }
179179
180180 InverseMouseArea {
181− anchors.fill: departmentListView
181+ anchors.fill: navigationListView
182182 enabled: root.showList
183183 onClicked: root.showList = false
184184 }
185185
186186 onScopeChanged: {
187− departmentModel.clear();
187+ navigationModel.clear();
188188 if (scope && scope.hasNavigation) {
189− departmentModel.append({"navigationId": scope.currentNavigationId, "nullifyDepartment": false});
189+ navigationModel.append({"navigationId": scope.currentNavigationId, "nullifyNavigation": false});
190190 }
191191 }
192192
@@ -194,9 +194,9 @@ AbstractButton {
194194 target: scope
195195 onHasNavigationChanged: {
196196 if (scope.hasNavigation) {
197− departmentModel.append({"navigationId": scope.currentNavigationId, "nullifyDepartment": false});
197+ navigationModel.append({"navigationId": scope.currentNavigationId, "nullifyNavigation": false});
198198 } else {
199− departmentModel.clear();
199+ navigationModel.clear();
200200 }
201201 }
202202 }
qml/Dash/DashNavigationList.qml+13−13
@@ -19,12 +19,12 @@ import Ubuntu.Components 1.1
1919
2020Item {
2121 id: root
22− property var department: null
23− property var currentDepartment: null
22+ property var navigation: null
23+ property var currentNavigation: null
2424 property var scopeStyle: null
25− signal enterDepartment(var newNavigationId, var departmentQuery, bool hasChildren)
25+ signal enterNavigation(var newNavigationId, var navigationQuery, bool hasChildren)
2626 signal goBackToParentClicked()
27− signal allDepartmentClicked()
27+ signal allNavigationClicked()
2828
2929 readonly property int itemHeight: units.gu(5)
3030 readonly property color foregroundColor: root.scopeStyle ? root.scopeStyle.foreground : "grey"
@@ -38,7 +38,7 @@ Item {
3838 ActivityIndicator {
3939 id: loadingIndicator
4040 anchors.centerIn: parent
41− running: !(department && department.loaded)
41+ running: !(navigation && navigation.loaded)
4242 }
4343 clip: true
4444
@@ -68,7 +68,7 @@ Item {
6868 id: backButton
6969 objectName: "backButton"
7070 width: parent.width
71− visible: department && !department.isRoot || false
71+ visible: navigation && !navigation.isRoot || false
7272 height: itemHeight
7373
7474 onClicked: root.goBackToParentClicked();
@@ -92,7 +92,7 @@ Item {
9292 left: backImage.right
9393 leftMargin: units.gu(0.5)
9494 }
95− text: department ? department.parentLabel : ""
95+ text: navigation ? navigation.parentLabel : ""
9696 color: root.foregroundColor
9797 }
9898
@@ -114,7 +114,7 @@ Item {
114114 id: allButton
115115 objectName: "allButton"
116116 width: parent.width
117− visible: department && (!department.isRoot || (root.currentDepartment && !root.currentDepartment.isRoot && root.currentDepartment.parentNavigationId == department.navigationId)) || false
117+ visible: navigation && (!navigation.isRoot || (root.currentNavigation && !root.currentNavigation.isRoot && root.currentNavigation.parentNavigationId == navigation.navigationId)) || false
118118 height: itemHeight
119119
120120 Label {
@@ -123,7 +123,7 @@ Item {
123123 left: parent.left
124124 leftMargin: units.gu(2)
125125 }
126− text: department ? (department.allLabel != "" ? department.allLabel : department.label) : ""
126+ text: navigation ? (navigation.allLabel != "" ? navigation.allLabel : navigation.label) : ""
127127 font.bold: true
128128 color: root.foregroundColor
129129 }
@@ -141,18 +141,18 @@ Item {
141141 height: units.dp(1)
142142 }
143143
144− onClicked: root.allDepartmentClicked();
144+ onClicked: root.allNavigationClicked();
145145 }
146146
147147 Repeater {
148− model: department && department.loaded ? department : null
148+ model: navigation && navigation.loaded ? navigation : null
149149 clip: true
150150 delegate: AbstractButton {
151151 objectName: root.objectName + "child" + index
152152 height: root.itemHeight
153153 width: root.width
154154
155− onClicked: root.enterDepartment(navigationId, query, hasChildren)
155+ onClicked: root.enterNavigation(navigationId, query, hasChildren)
156156
157157 Label {
158158 anchors {
@@ -188,7 +188,7 @@ Item {
188188 color: root.foregroundColor
189189 opacity: 0.1
190190 height: units.dp(1)
191− visible: index != department.count - 1
191+ visible: index != navigation.count - 1
192192 }
193193 }
194194 }
tests/qmltests/Dash/tst_DashContent.qml+93−93
@@ -265,119 +265,119 @@ Item {
265265 verify(carouselLV.tileWidth / carouselLV.tileHeight == cardTool.components["art"]["aspect-ratio"]);
266266 }
267267
268− function test_departments() {
268+ function test_navigations() {
269269 var dashContentList = findChild(dashContent, "dashContentList");
270− tryCompareFunction(function() { return findChild(dashContentList.currentItem, "dashDepartments") != null; }, true);
271− var dashDepartments = findChild(dashContentList.currentItem, "dashDepartments");
272− tryCompare(dashDepartments, "visible", true);
273− compare(dashDepartments.showList, false);
274− waitForRendering(dashDepartments);
275− mouseClick(dashDepartments, 0, 0);
276− compare(dashDepartments.showList, true);
277−
278− var departmentListView = findChild(dashDepartments, "departmentListView");
279− compare(departmentListView.count, 1);
280− tryCompare(departmentListView.currentItem.department, "loaded", true);
281−
282− waitForRendering(departmentListView);
283− waitForRendering(departmentListView.currentItem);
284−
285− var allButton = findChild(dashDepartments, "allButton");
270+ tryCompareFunction(function() { return findChild(dashContentList.currentItem, "dashNavigation") != null; }, true);
271+ var dashNavigation = findChild(dashContentList.currentItem, "dashNavigation");
272+ tryCompare(dashNavigation, "visible", true);
273+ compare(dashNavigation.showList, false);
274+ waitForRendering(dashNavigation);
275+ mouseClick(dashNavigation, 0, 0);
276+ compare(dashNavigation.showList, true);
277+
278+ var navigationListView = findChild(dashNavigation, "navigationListView");
279+ compare(navigationListView.count, 1);
280+ tryCompare(navigationListView.currentItem.navigation, "loaded", true);
281+
282+ waitForRendering(navigationListView);
283+ waitForRendering(navigationListView.currentItem);
284+
285+ var allButton = findChild(dashNavigation, "allButton");
286286 compare(allButton.visible, false);
287287
288− var department = findChild(dashDepartments, "department0child3");
289− mouseClick(department, 0, 0);
290− compare(dashDepartments.showList, false);
291− tryCompare(dashDepartments.currentDepartment, "navigationId", "middle3");
292− tryCompare(departmentListView.currentItem.department, "navigationId", "root");
288+ var navigation = findChild(dashNavigation, "navigation0child3");
289+ mouseClick(navigation, 0, 0);
290+ compare(dashNavigation.showList, false);
291+ tryCompare(dashNavigation.currentNavigation, "navigationId", "middle3");
292+ tryCompare(navigationListView.currentItem.navigation, "navigationId", "root");
293293
294− mouseClick(dashDepartments, 0, 0);
295− compare(dashDepartments.showList, true);
296− waitForRendering(departmentListView);
297− waitForRendering(departmentListView.currentItem);
294+ mouseClick(dashNavigation, 0, 0);
295+ compare(dashNavigation.showList, true);
296+ waitForRendering(navigationListView);
297+ waitForRendering(navigationListView.currentItem);
298298 compare(allButton.visible, true);
299299
300300 mouseClick(allButton, 0, 0);
301− compare(dashDepartments.showList, false);
302− tryCompare(dashDepartments.currentDepartment, "navigationId", "root");
303− tryCompare(departmentListView.currentItem.department, "navigationId", "root");
304−
305− mouseClick(dashDepartments, 0, 0);
306− compare(dashDepartments.showList, true);
307− waitForRendering(departmentListView);
308− waitForRendering(departmentListView.currentItem);
301+ compare(dashNavigation.showList, false);
302+ tryCompare(dashNavigation.currentNavigation, "navigationId", "root");
303+ tryCompare(navigationListView.currentItem.navigation, "navigationId", "root");
304+
305+ mouseClick(dashNavigation, 0, 0);
306+ compare(dashNavigation.showList, true);
307+ waitForRendering(navigationListView);
308+ waitForRendering(navigationListView.currentItem);
309309 compare(allButton.visible, false);
310310
311− department = findChild(dashDepartments, "department0child2");
312− mouseClick(department, 0, 0);
313− compare(dashDepartments.showList, true);
314− tryCompare(dashDepartments.currentDepartment, "navigationId", "middle2");
315− tryCompare(departmentListView.currentItem.department, "navigationId", "middle2");
311+ navigation = findChild(dashNavigation, "navigation0child2");
312+ mouseClick(navigation, 0, 0);
313+ compare(dashNavigation.showList, true);
314+ tryCompare(dashNavigation.currentNavigation, "navigationId", "middle2");
315+ tryCompare(navigationListView.currentItem.navigation, "navigationId", "middle2");
316316
317− var departmentList1 = findChild(dashDepartments, "department1");
318− allButton = findChild(departmentList1, "allButton");
319− var backButton = findChild(findChild(departmentList1, "department1"), "backButton");
317+ var navigationList1 = findChild(dashNavigation, "navigation1");
318+ allButton = findChild(navigationList1, "allButton");
319+ var backButton = findChild(findChild(navigationList1, "navigation1"), "backButton");
320320 compare(allButton.visible, true);
321321 compare(backButton.visible, true);
322322
323− tryCompare(departmentListView, "contentX", departmentList1.x);
324− waitForRendering(departmentListView);
323+ tryCompare(navigationListView, "contentX", navigationList1.x);
324+ waitForRendering(navigationListView);
325325 mouseClick(allButton, 0, 0);
326− compare(dashDepartments.showList, false);
327− tryCompare(dashDepartments.currentDepartment, "navigationId", "middle2");
328− tryCompare(departmentListView.currentItem.department, "navigationId", "middle2");
329−
330− mouseClick(dashDepartments, 0, 0);
331− compare(dashDepartments.showList, true);
332− waitForRendering(departmentListView);
333− waitForRendering(departmentListView.currentItem);
326+ compare(dashNavigation.showList, false);
327+ tryCompare(dashNavigation.currentNavigation, "navigationId", "middle2");
328+ tryCompare(navigationListView.currentItem.navigation, "navigationId", "middle2");
329+
330+ mouseClick(dashNavigation, 0, 0);
331+ compare(dashNavigation.showList, true);
332+ waitForRendering(navigationListView);
333+ waitForRendering(navigationListView.currentItem);
334334 compare(allButton.visible, true);
335335 compare(backButton.visible, true);
336336
337− tryCompare(departmentList1.department, "loaded", true);
338− department = findChild(dashDepartments, "department1child2");
339− mouseClick(department, 0, 0);
340− compare(dashDepartments.showList, false);
341− tryCompare(dashDepartments.currentDepartment, "navigationId", "childmiddle22");
342− tryCompare(departmentListView.currentItem.department, "navigationId", "middle2");
343−
344− mouseClick(dashDepartments, 0, 0);
345− compare(dashDepartments.showList, true);
346− waitForRendering(departmentListView);
347− waitForRendering(departmentListView.currentItem);
348−
349− tryCompare(departmentList1.department, "loaded", true);
350− department = findChild(dashDepartments, "department1child3");
351− mouseClick(department, 0, 0);
352− compare(dashDepartments.showList, false);
353− tryCompare(dashDepartments.currentDepartment, "navigationId", "childmiddle23");
354− tryCompare(departmentListView.currentItem.department, "navigationId", "middle2");
355−
356− mouseClick(dashDepartments, 0, 0);
357− compare(dashDepartments.showList, true);
358− waitForRendering(departmentListView);
359− waitForRendering(departmentListView.currentItem);
337+ tryCompare(navigationList1.navigation, "loaded", true);
338+ navigation = findChild(dashNavigation, "navigation1child2");
339+ mouseClick(navigation, 0, 0);
340+ compare(dashNavigation.showList, false);
341+ tryCompare(dashNavigation.currentNavigation, "navigationId", "childmiddle22");
342+ tryCompare(navigationListView.currentItem.navigation, "navigationId", "middle2");
343+
344+ mouseClick(dashNavigation, 0, 0);
345+ compare(dashNavigation.showList, true);
346+ waitForRendering(navigationListView);
347+ waitForRendering(navigationListView.currentItem);
348+
349+ tryCompare(navigationList1.navigation, "loaded", true);
350+ navigation = findChild(dashNavigation, "navigation1child3");
351+ mouseClick(navigation, 0, 0);
352+ compare(dashNavigation.showList, false);
353+ tryCompare(dashNavigation.currentNavigation, "navigationId", "childmiddle23");
354+ tryCompare(navigationListView.currentItem.navigation, "navigationId", "middle2");
355+
356+ mouseClick(dashNavigation, 0, 0);
357+ compare(dashNavigation.showList, true);
358+ waitForRendering(navigationListView);
359+ waitForRendering(navigationListView.currentItem);
360360 mouseClick(backButton, 0, 0);
361361
362− tryCompare(dashDepartments.currentDepartment, "navigationId", "root");
363− tryCompare(departmentListView.currentItem.department, "navigationId", "root");
364− compare(dashDepartments.showList, true);
365− mouseClick(dashDepartments, 0, 0);
366− compare(dashDepartments.showList, false);
367−
368− mouseClick(dashDepartments, 0, 0);
369− compare(dashDepartments.showList, true);
370− tryCompare(departmentListView.currentItem.department, "loaded", true);
371− department = findChild(dashDepartments, "department0child2");
372− mouseClick(department, 0, 0);
373− compare(dashDepartments.showList, true);
374− departmentList1 = findChild(dashDepartments, "department1");
375− compare(departmentList1.department.loaded, false);
376− tryCompare(dashDepartments.currentDepartment, "navigationId", "middle2");
377− allButton = findChild(departmentList1, "allButton");
378− tryCompare(dashDepartments.currentDepartment, "navigationId", "middle2");
362+ tryCompare(dashNavigation.currentNavigation, "navigationId", "root");
363+ tryCompare(navigationListView.currentItem.navigation, "navigationId", "root");
364+ compare(dashNavigation.showList, true);
365+ mouseClick(dashNavigation, 0, 0);
366+ compare(dashNavigation.showList, false);
367+
368+ mouseClick(dashNavigation, 0, 0);
369+ compare(dashNavigation.showList, true);
370+ tryCompare(navigationListView.currentItem.navigation, "loaded", true);
371+ navigation = findChild(dashNavigation, "navigation0child2");
372+ mouseClick(navigation, 0, 0);
373+ compare(dashNavigation.showList, true);
374+ navigationList1 = findChild(dashNavigation, "navigation1");
375+ compare(navigationList1.navigation.loaded, false);
376+ tryCompare(dashNavigation.currentNavigation, "navigationId", "middle2");
377+ allButton = findChild(navigationList1, "allButton");
378+ tryCompare(dashNavigation.currentNavigation, "navigationId", "middle2");
379379 mouseClick(allButton, 0, 0);
380− tryCompare(dashDepartments.currentDepartment, "navigationId", "middle2");
380+ tryCompare(dashNavigation.currentNavigation, "navigationId", "middle2");
381381 }
382382 }
383383}