Merge lp:~tpeeters/ubuntu-ui-toolkit/10-tabsModelIndex into lp:ubuntu-ui-toolkit/staging

Proposed by Tim Peeters
Status: Merged
Approved by: Zsombor Egri
Approved revision: 991
Merged at revision: 1012
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/10-tabsModelIndex
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 209 lines (+45/-9)
6 files modified
CHANGES (+1/-0)
modules/Ubuntu/Components/TabBar.qml (+25/-5)
modules/Ubuntu/Components/Tabs.qml (+8/-1)
modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml (+1/-1)
tests/resources/navigation/TabView.qml (+3/-2)
tests/unit_x11/tst_components/tst_tabbar.qml (+7/-0)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/10-tabsModelIndex
Reviewer Review Type Date Requested Status
Zsombor Egri Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+215278@code.launchpad.net

Commit message

Move the property to keep track of the selected tab to the tabs model.

Description of the change

Move the property to keep track of the selected tab to the tabs model.

To avoid breaking unity8, this MR must only be landed together with this MR in unity8:
https://code.launchpad.net/~tpeeters/unity8/new_tabbar-again/+merge/215658

This is the second try of the changes in this MR: https://code.launchpad.net/~tpeeters/ubuntu-ui-toolkit/tabsModelIndex/+merge/210568 which was reverted because it broke the gallery-app autopilot tests in the image.

To post a comment you must log in.
988. By Tim Peeters

remove fixSelectedIndex() again

989. By Tim Peeters

document checkRoles

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:989
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/13/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-trusty-touch/195
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4768
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-trusty-amd64-ci/13
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-trusty-armhf-ci/13
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-trusty-armhf-ci/13/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-trusty-i386-ci/13
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/187
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4350
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4350/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/5924
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/4118
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4897
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4897/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/13/rebuild

review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

I ran UITK and unity8 tests locally on mako with image 294:

http://paste.ubuntu.com/7254918/

UITK and unity8 tests pass. There are some failures in system-settings, same as here http://ci.ubuntu.com/smokeng/trusty/touch/mako/290:20140411.3:20140411.3/7698/ubuntu_system_settings/ I guess I have some older packages version or the tests are flaky?

I also manually tested gallery-app and ran the gallery-app autopilot tests, and they passed.

990. By Tim Peeters

merge revert-dynamic-tabs

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:990
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/38/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-trusty-touch/285
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4895
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-trusty-amd64-ci/38
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-trusty-armhf-ci/38
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-trusty-armhf-ci/38/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-trusty-i386-ci/38
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/270
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4472
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4472/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/6117
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/4229
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/5038
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/5038/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/38/rebuild

review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

I ran the gallery_app tests again in image 294 after reverting the dynamic tabs, all good:

Tests running...

Ran 35 tests in 782.567s
OK

991. By Tim Peeters

empty

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:991
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/54/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-trusty-touch/337
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4959
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-trusty-amd64-ci/54
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-trusty-armhf-ci/54
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-trusty-armhf-ci/54/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-trusty-i386-ci/54
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/310
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4552
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4552/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/6228
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/4277
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/5124
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/5124/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/54/rebuild

review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

Looks good, good to go.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGES'
2--- CHANGES 2014-04-16 11:51:47 +0000
3+++ CHANGES 2014-04-21 22:45:54 +0000
4@@ -93,6 +93,7 @@
5 - CHANGED IN Page/MainView: Only enable auto-hide behavior of header when the Page's flickable can be flicked vertically, so that manual setting of anchors is no longer needed for flickables that only flick horizontally
6 - CHANGED IN Page: Automatic detection of flickable inside a Page to control the header is now limited to Flickables that are anchored to the top of the Page or fill the Page. Header automatically shows when flickable.contentHeight becomes <= flickable.height.
7 - CHANGED IN Action, ActionItem, OptionSelectorDelegate: Setting iconName now always selects the requested icon from ubuntu-mobile theme, not the system icon theme.
8+- CHANGED IN TabBar: The model now needs to have a selectedIndex property.
9
10 SDK 0.1.46
11 ##########
12
13=== modified file 'modules/Ubuntu/Components/TabBar.qml'
14--- modules/Ubuntu/Components/TabBar.qml 2014-04-08 12:38:35 +0000
15+++ modules/Ubuntu/Components/TabBar.qml 2014-04-21 22:45:54 +0000
16@@ -63,8 +63,18 @@
17
18 /*!
19 The property holds the index of the selected Tab item.
20+ Note: Setting this property is DEPRECATED. Set the selectedIndex of the model instead.
21 */
22- property int selectedIndex: (model && internal.modelChecked && model.count > 0) ? 0 : -1
23+ property int selectedIndex: (model && internal.modelChecked) ? model.selectedIndex : -1
24+
25+ /*! \internal */
26+ onSelectedIndexChanged: {
27+ if (!model) return;
28+ if (tabBar.selectedIndex !== model.selectedIndex) {
29+ console.warn("Setting TabBar.selectedIndex is DEPRECATED. Set selectedIndex of the model instead");
30+ tabBar.selectedIndex = Qt.binding(function() { return (model && internal.modelChecked) ? model.selectedIndex : -1 });
31+ }
32+ }
33
34 /*!
35 Do not deactivate the tab bar after a specified idle time or when the user selects a new tab.
36@@ -93,20 +103,24 @@
37
38 property bool modelChecked: true;
39
40+ // returns true if the roles are good, false otherwise.
41 function checkRoles() {
42 if (tabBar.model.count <= 0)
43- return;
44+ return false;
45
46 modelChecked = true;
47 var f = tabBar.model.get(0);
48 if (f.tab === undefined && f.title === undefined) {
49 console.error("TabBar model must provide either tab or title role.");
50 tabBar.model = null;
51+ return false;
52 }
53 if (f.tab !== undefined && f.tab.title === undefined) {
54 console.error("TabBar model's tab role must have title property.");
55 tabBar.model = null;
56+ return false;
57 }
58+ return true;
59 }
60 }
61
62@@ -117,6 +131,12 @@
63 if (!model)
64 return;
65
66+ if (!model.hasOwnProperty("selectedIndex")) {
67+ console.error("TabBar model must have selectedIndex property defined.");
68+ tabBar.model = null;
69+ return;
70+ }
71+
72 if (!model.hasOwnProperty("count")) {
73 console.error("TabBar model must have count property defined.");
74 tabBar.model = null;
75@@ -130,11 +150,11 @@
76 }
77
78 if (model.count > 0) {
79- internal.checkRoles();
80- tabBar.selectedIndex = Math.max(Math.min(tabBar.selectedIndex, model.count - 1), 0);
81+ if (internal.checkRoles()) {
82+ model.selectedIndex = Math.max(Math.min(tabBar.selectedIndex, model.count - 1), 0);
83+ }
84 } else {
85 internal.modelChecked = false;
86- tabBar.selectedIndex = Qt.binding(function() { return (model && internal.modelChecked && model.count > 0) ? 0 : -1 })
87 }
88 }
89
90
91=== modified file 'modules/Ubuntu/Components/Tabs.qml'
92--- modules/Ubuntu/Components/Tabs.qml 2014-04-16 11:51:47 +0000
93+++ modules/Ubuntu/Components/Tabs.qml 2014-04-21 22:45:54 +0000
94@@ -161,7 +161,7 @@
95 The first tab is 0, and -1 means that no tab is selected.
96 The initial value is 0 if Tabs has contents, or -1 otherwise.
97 */
98- property alias selectedTabIndex: bar.selectedIndex
99+ property alias selectedTabIndex: tabsModel.selectedIndex
100
101 /*!
102 \preliminary
103@@ -212,6 +212,13 @@
104 ListModel {
105 id: tabsModel
106
107+ property bool updateDisabled: false
108+
109+ /*!
110+ The index of the selected tab.
111+ */
112+ property int selectedIndex: tabsModel.count > 0 ? 0 : -1
113+
114 function listModel(tab) {
115 return {"title": tab.title, "tab": tab};
116 }
117
118=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml'
119--- modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml 2014-04-16 11:51:47 +0000
120+++ modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml 2014-04-21 22:45:54 +0000
121@@ -212,7 +212,7 @@
122 if (mouseArea.enteringSelectionMode) {
123 mouseArea.enteringSelectionMode = false;
124 } else if (opacity > 0.0) {
125- styledItem.selectedIndex = index;
126+ styledItem.model.selectedIndex = index;
127 if (!styledItem.alwaysSelectionMode) {
128 styledItem.selectionMode = false;
129 }
130
131=== modified file 'tests/resources/navigation/TabView.qml'
132--- tests/resources/navigation/TabView.qml 2013-11-20 10:25:12 +0000
133+++ tests/resources/navigation/TabView.qml 2014-04-21 22:45:54 +0000
134@@ -25,6 +25,7 @@
135
136 ListModel {
137 id: pages
138+ property int selectedIndex: 0
139 ListElement {
140 title: "Tab 1"
141 }
142@@ -68,7 +69,7 @@
143 color: Qt.rgba(Math.random(0.5), Math.random(1), Math.random(0.5), 1)
144 MouseArea {
145 anchors.fill: parent
146- onClicked: tabBar.selectedIndex = index
147+ onClicked: pages.selectedIndex = index
148 }
149 }
150 }
151@@ -83,6 +84,6 @@
152 orientation: Qt.Horizontal
153 model: pages
154 delegate: tabComponent
155- currentIndex: tabBar.selectedIndex
156+ currentIndex: pages.selectedIndex
157 }
158 }
159
160=== modified file 'tests/unit_x11/tst_components/tst_tabbar.qml'
161--- tests/unit_x11/tst_components/tst_tabbar.qml 2014-04-08 12:38:35 +0000
162+++ tests/unit_x11/tst_components/tst_tabbar.qml 2014-04-21 22:45:54 +0000
163@@ -60,6 +60,7 @@
164
165 ListModel {
166 id: pages
167+ property int selectedIndex: 0
168 ListElement {
169 title: "Tab 1"
170 }
171@@ -79,6 +80,7 @@
172
173 ListModel {
174 id: invalidModel
175+ property int selectedIndex: 0
176 ListElement {
177 fruit: "Pear"
178 }
179@@ -86,6 +88,7 @@
180
181 ListModel {
182 id: invalidModelTab
183+ property int selectedIndex: 0
184 ListElement {
185 tab: "Pear"
186 }
187@@ -98,18 +101,22 @@
188
189 ListModel {
190 id: validModelTab
191+ property int selectedIndex: count > 0 ? 0 : -1
192 }
193
194 ListModel {
195 id: emptyModelWillBeInvalid
196+ property int selectedIndex: count > 0 ? 0 : -1
197 }
198
199 ListModel {
200 id: emptyModel
201+ property int selectedIndex: count > 0 ? 0 : -1
202 }
203
204 TabsModel {
205 id: pagesCpp
206+ property int selectedIndex: count > 0 ? 0 : -1
207 }
208
209 Label {

Subscribers

People subscribed via source and target branches