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
=== modified file 'CHANGES'
--- CHANGES 2014-04-16 11:51:47 +0000
+++ CHANGES 2014-04-21 22:45:54 +0000
@@ -93,6 +93,7 @@
93- 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 horizontally93- 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
94- 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.94- 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.
95- CHANGED IN Action, ActionItem, OptionSelectorDelegate: Setting iconName now always selects the requested icon from ubuntu-mobile theme, not the system icon theme.95- CHANGED IN Action, ActionItem, OptionSelectorDelegate: Setting iconName now always selects the requested icon from ubuntu-mobile theme, not the system icon theme.
96- CHANGED IN TabBar: The model now needs to have a selectedIndex property.
9697
97SDK 0.1.4698SDK 0.1.46
98##########99##########
99100
=== modified file 'modules/Ubuntu/Components/TabBar.qml'
--- modules/Ubuntu/Components/TabBar.qml 2014-04-08 12:38:35 +0000
+++ modules/Ubuntu/Components/TabBar.qml 2014-04-21 22:45:54 +0000
@@ -63,8 +63,18 @@
6363
64 /*!64 /*!
65 The property holds the index of the selected Tab item.65 The property holds the index of the selected Tab item.
66 Note: Setting this property is DEPRECATED. Set the selectedIndex of the model instead.
66 */67 */
67 property int selectedIndex: (model && internal.modelChecked && model.count > 0) ? 0 : -168 property int selectedIndex: (model && internal.modelChecked) ? model.selectedIndex : -1
69
70 /*! \internal */
71 onSelectedIndexChanged: {
72 if (!model) return;
73 if (tabBar.selectedIndex !== model.selectedIndex) {
74 console.warn("Setting TabBar.selectedIndex is DEPRECATED. Set selectedIndex of the model instead");
75 tabBar.selectedIndex = Qt.binding(function() { return (model && internal.modelChecked) ? model.selectedIndex : -1 });
76 }
77 }
6878
69 /*!79 /*!
70 Do not deactivate the tab bar after a specified idle time or when the user selects a new tab.80 Do not deactivate the tab bar after a specified idle time or when the user selects a new tab.
@@ -93,20 +103,24 @@
93103
94 property bool modelChecked: true;104 property bool modelChecked: true;
95105
106 // returns true if the roles are good, false otherwise.
96 function checkRoles() {107 function checkRoles() {
97 if (tabBar.model.count <= 0)108 if (tabBar.model.count <= 0)
98 return;109 return false;
99110
100 modelChecked = true;111 modelChecked = true;
101 var f = tabBar.model.get(0);112 var f = tabBar.model.get(0);
102 if (f.tab === undefined && f.title === undefined) {113 if (f.tab === undefined && f.title === undefined) {
103 console.error("TabBar model must provide either tab or title role.");114 console.error("TabBar model must provide either tab or title role.");
104 tabBar.model = null;115 tabBar.model = null;
116 return false;
105 }117 }
106 if (f.tab !== undefined && f.tab.title === undefined) {118 if (f.tab !== undefined && f.tab.title === undefined) {
107 console.error("TabBar model's tab role must have title property.");119 console.error("TabBar model's tab role must have title property.");
108 tabBar.model = null;120 tabBar.model = null;
121 return false;
109 }122 }
123 return true;
110 }124 }
111 }125 }
112126
@@ -117,6 +131,12 @@
117 if (!model)131 if (!model)
118 return;132 return;
119133
134 if (!model.hasOwnProperty("selectedIndex")) {
135 console.error("TabBar model must have selectedIndex property defined.");
136 tabBar.model = null;
137 return;
138 }
139
120 if (!model.hasOwnProperty("count")) {140 if (!model.hasOwnProperty("count")) {
121 console.error("TabBar model must have count property defined.");141 console.error("TabBar model must have count property defined.");
122 tabBar.model = null;142 tabBar.model = null;
@@ -130,11 +150,11 @@
130 }150 }
131151
132 if (model.count > 0) {152 if (model.count > 0) {
133 internal.checkRoles();153 if (internal.checkRoles()) {
134 tabBar.selectedIndex = Math.max(Math.min(tabBar.selectedIndex, model.count - 1), 0);154 model.selectedIndex = Math.max(Math.min(tabBar.selectedIndex, model.count - 1), 0);
155 }
135 } else {156 } else {
136 internal.modelChecked = false;157 internal.modelChecked = false;
137 tabBar.selectedIndex = Qt.binding(function() { return (model && internal.modelChecked && model.count > 0) ? 0 : -1 })
138 }158 }
139 }159 }
140160
141161
=== modified file 'modules/Ubuntu/Components/Tabs.qml'
--- modules/Ubuntu/Components/Tabs.qml 2014-04-16 11:51:47 +0000
+++ modules/Ubuntu/Components/Tabs.qml 2014-04-21 22:45:54 +0000
@@ -161,7 +161,7 @@
161 The first tab is 0, and -1 means that no tab is selected.161 The first tab is 0, and -1 means that no tab is selected.
162 The initial value is 0 if Tabs has contents, or -1 otherwise.162 The initial value is 0 if Tabs has contents, or -1 otherwise.
163 */163 */
164 property alias selectedTabIndex: bar.selectedIndex164 property alias selectedTabIndex: tabsModel.selectedIndex
165165
166 /*!166 /*!
167 \preliminary167 \preliminary
@@ -212,6 +212,13 @@
212 ListModel {212 ListModel {
213 id: tabsModel213 id: tabsModel
214214
215 property bool updateDisabled: false
216
217 /*!
218 The index of the selected tab.
219 */
220 property int selectedIndex: tabsModel.count > 0 ? 0 : -1
221
215 function listModel(tab) {222 function listModel(tab) {
216 return {"title": tab.title, "tab": tab};223 return {"title": tab.title, "tab": tab};
217 }224 }
218225
=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml'
--- modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml 2014-04-16 11:51:47 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml 2014-04-21 22:45:54 +0000
@@ -212,7 +212,7 @@
212 if (mouseArea.enteringSelectionMode) {212 if (mouseArea.enteringSelectionMode) {
213 mouseArea.enteringSelectionMode = false;213 mouseArea.enteringSelectionMode = false;
214 } else if (opacity > 0.0) {214 } else if (opacity > 0.0) {
215 styledItem.selectedIndex = index;215 styledItem.model.selectedIndex = index;
216 if (!styledItem.alwaysSelectionMode) {216 if (!styledItem.alwaysSelectionMode) {
217 styledItem.selectionMode = false;217 styledItem.selectionMode = false;
218 }218 }
219219
=== modified file 'tests/resources/navigation/TabView.qml'
--- tests/resources/navigation/TabView.qml 2013-11-20 10:25:12 +0000
+++ tests/resources/navigation/TabView.qml 2014-04-21 22:45:54 +0000
@@ -25,6 +25,7 @@
2525
26 ListModel {26 ListModel {
27 id: pages27 id: pages
28 property int selectedIndex: 0
28 ListElement {29 ListElement {
29 title: "Tab 1"30 title: "Tab 1"
30 }31 }
@@ -68,7 +69,7 @@
68 color: Qt.rgba(Math.random(0.5), Math.random(1), Math.random(0.5), 1)69 color: Qt.rgba(Math.random(0.5), Math.random(1), Math.random(0.5), 1)
69 MouseArea {70 MouseArea {
70 anchors.fill: parent71 anchors.fill: parent
71 onClicked: tabBar.selectedIndex = index72 onClicked: pages.selectedIndex = index
72 }73 }
73 }74 }
74 }75 }
@@ -83,6 +84,6 @@
83 orientation: Qt.Horizontal84 orientation: Qt.Horizontal
84 model: pages85 model: pages
85 delegate: tabComponent86 delegate: tabComponent
86 currentIndex: tabBar.selectedIndex87 currentIndex: pages.selectedIndex
87 }88 }
88}89}
8990
=== modified file 'tests/unit_x11/tst_components/tst_tabbar.qml'
--- tests/unit_x11/tst_components/tst_tabbar.qml 2014-04-08 12:38:35 +0000
+++ tests/unit_x11/tst_components/tst_tabbar.qml 2014-04-21 22:45:54 +0000
@@ -60,6 +60,7 @@
6060
61 ListModel {61 ListModel {
62 id: pages62 id: pages
63 property int selectedIndex: 0
63 ListElement {64 ListElement {
64 title: "Tab 1"65 title: "Tab 1"
65 }66 }
@@ -79,6 +80,7 @@
7980
80 ListModel {81 ListModel {
81 id: invalidModel82 id: invalidModel
83 property int selectedIndex: 0
82 ListElement {84 ListElement {
83 fruit: "Pear"85 fruit: "Pear"
84 }86 }
@@ -86,6 +88,7 @@
8688
87 ListModel {89 ListModel {
88 id: invalidModelTab90 id: invalidModelTab
91 property int selectedIndex: 0
89 ListElement {92 ListElement {
90 tab: "Pear"93 tab: "Pear"
91 }94 }
@@ -98,18 +101,22 @@
98101
99 ListModel {102 ListModel {
100 id: validModelTab103 id: validModelTab
104 property int selectedIndex: count > 0 ? 0 : -1
101 }105 }
102106
103 ListModel {107 ListModel {
104 id: emptyModelWillBeInvalid108 id: emptyModelWillBeInvalid
109 property int selectedIndex: count > 0 ? 0 : -1
105 }110 }
106111
107 ListModel {112 ListModel {
108 id: emptyModel113 id: emptyModel
114 property int selectedIndex: count > 0 ? 0 : -1
109 }115 }
110116
111 TabsModel {117 TabsModel {
112 id: pagesCpp118 id: pagesCpp
119 property int selectedIndex: count > 0 ? 0 : -1
113 }120 }
114121
115 Label {122 Label {

Subscribers

People subscribed via source and target branches