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

Proposed by Tim Peeters
Status: Superseded
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/tabsModelIndex
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 191 lines (+44/-7)
5 files modified
modules/Ubuntu/Components/TabBar.qml (+28/-5)
modules/Ubuntu/Components/Tabs.qml (+6/-1)
modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml (+1/-1)
tests/unit_x11/tst_components/tst_tabbar.qml (+7/-0)
tests/unit_x11/tst_components/tst_ubuntulistview.qml (+2/-0)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/tabsModelIndex
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu SDK team Pending
Review via email: mp+210380@code.launchpad.net

This proposal has been superseded by a proposal from 2014-03-12.

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/~aacid/unity8/new_tabbar/+merge/210453

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
972. By Tim Peeters

merge more-stable-ubuntulistview-tests branch to fix a test

973. By Tim Peeters

fix docs

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
974. By Tim Peeters

merge trunk

975. By Tim Peeters

re-do changes

976. By Tim Peeters

remove fixSelectedIndex function

977. By Tim Peeters

merge trunk

978. By Tim Peeters

link bug

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
979. By Tim Peeters

merge trunk

980. By Tim Peeters

merge trunk

981. By Tim Peeters

empty commit

982. By Tim Peeters

merge trunk

983. By Tim Peeters

merge trunk

984. By Tim Peeters

update TabView example

985. By Tim Peeters

update CHANGES

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/TabBar.qml'
2--- modules/Ubuntu/Components/TabBar.qml 2013-12-04 19:46:49 +0000
3+++ modules/Ubuntu/Components/TabBar.qml 2014-03-11 13:22:26 +0000
4@@ -63,8 +63,17 @@
5
6 /*!
7 The property holds the index of the selected Tab item.
8+ Note: Setting this property is DEPRECATED. Set the selectedIndex of the model instead.
9 */
10- property int selectedIndex: (model && internal.modelChecked && model.count > 0) ? 0 : -1
11+ property int selectedIndex: (model && internal.modelChecked) ? model.selectedIndex : -1
12+
13+ /*! \internal */
14+ onSelectedIndexChanged: {
15+ if (!model) return;
16+ if (tabBar.selectedIndex !== model.selectedIndex) {
17+ internal.fixSelectedIndex();
18+ }
19+ }
20
21 /*!
22 Do not deactivate the tab bar after a specified idle time or when the user selects a new tab.
23@@ -91,22 +100,30 @@
24 QtObject {
25 id: internal
26
27+ function fixSelectedIndex() {
28+ console.warn("Setting TabBar.selectedIndex is DEPRECATED. Set selectedIndex of the model instead");
29+ tabBar.selectedIndex = Qt.binding(function() { return (model && internal.modelChecked) ? model.selectedIndex : -1 });
30+ }
31+
32 property bool modelChecked: true;
33
34 function checkRoles() {
35 if (tabBar.model.count <= 0)
36- return;
37+ return false;
38
39 modelChecked = true;
40 var f = tabBar.model.get(0);
41 if (f.tab === undefined && f.title === undefined) {
42 console.error("TabBar model must provide either tab or title role.");
43 tabBar.model = null;
44+ return false;
45 }
46 if (f.tab !== undefined && f.tab.title === undefined) {
47 console.error("TabBar model's tab role must have title property.");
48 tabBar.model = null;
49+ return false;
50 }
51+ return true;
52 }
53 }
54
55@@ -117,6 +134,12 @@
56 if (!model)
57 return;
58
59+ if (!model.hasOwnProperty("selectedIndex")) {
60+ console.error("TabBar model must have selectedIndex property defined.");
61+ tabBar.model = null;
62+ return;
63+ }
64+
65 if (!model.hasOwnProperty("count")) {
66 console.error("TabBar model must have count property defined.");
67 tabBar.model = null;
68@@ -130,11 +153,11 @@
69 }
70
71 if (model.count > 0) {
72- internal.checkRoles();
73- tabBar.selectedIndex = Math.max(Math.min(tabBar.selectedIndex, model.count - 1), 0);
74+ if (internal.checkRoles()) {
75+ model.selectedIndex = Math.max(Math.min(tabBar.selectedIndex, model.count - 1), 0);
76+ }
77 } else {
78 internal.modelChecked = false;
79- tabBar.selectedIndex = Qt.binding(function() { return (model && internal.modelChecked && model.count > 0) ? 0 : -1 })
80 }
81 }
82
83
84=== modified file 'modules/Ubuntu/Components/Tabs.qml'
85--- modules/Ubuntu/Components/Tabs.qml 2014-01-13 11:47:19 +0000
86+++ modules/Ubuntu/Components/Tabs.qml 2014-03-11 13:22:26 +0000
87@@ -161,7 +161,7 @@
88 The first tab is 0, and -1 means that no tab is selected.
89 The initial value is 0 if Tabs has contents, or -1 otherwise.
90 */
91- property alias selectedTabIndex: bar.selectedIndex
92+ property alias selectedTabIndex: tabsModel.selectedIndex
93
94 /*!
95 \preliminary
96@@ -212,6 +212,11 @@
97 ListModel {
98 id: tabsModel
99
100+ /*!
101+ The index of the selected tab.
102+ */
103+ property int selectedIndex: tabsModel.count > 0 ? 0 : -1
104+
105 function listModel(tab) {
106 return {"title": tab.title, "tab": tab};
107 }
108
109=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml'
110--- modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml 2014-02-26 18:29:40 +0000
111+++ modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml 2014-03-11 13:22:26 +0000
112@@ -212,7 +212,7 @@
113 if (mouseArea.enteringSelectionMode) {
114 mouseArea.enteringSelectionMode = false;
115 } else if (opacity > 0.0) {
116- styledItem.selectedIndex = index;
117+ styledItem.model.selectedIndex = index;
118 if (!styledItem.alwaysSelectionMode) {
119 styledItem.selectionMode = false;
120 }
121
122=== modified file 'tests/unit_x11/tst_components/tst_tabbar.qml'
123--- tests/unit_x11/tst_components/tst_tabbar.qml 2014-02-26 17:13:07 +0000
124+++ tests/unit_x11/tst_components/tst_tabbar.qml 2014-03-11 13:22:26 +0000
125@@ -60,6 +60,7 @@
126
127 ListModel {
128 id: pages
129+ property int selectedIndex: 0
130 ListElement {
131 title: "Tab 1"
132 }
133@@ -79,6 +80,7 @@
134
135 ListModel {
136 id: invalidModel
137+ property int selectedIndex: 0
138 ListElement {
139 fruit: "Pear"
140 }
141@@ -86,6 +88,7 @@
142
143 ListModel {
144 id: invalidModelTab
145+ property int selectedIndex: 0
146 ListElement {
147 tab: "Pear"
148 }
149@@ -98,18 +101,22 @@
150
151 ListModel {
152 id: validModelTab
153+ property int selectedIndex: count > 0 ? 0 : -1
154 }
155
156 ListModel {
157 id: emptyModelWillBeInvalid
158+ property int selectedIndex: count > 0 ? 0 : -1
159 }
160
161 ListModel {
162 id: emptyModel
163+ property int selectedIndex: count > 0 ? 0 : -1
164 }
165
166 TabsModel {
167 id: pagesCpp
168+ property int selectedIndex: count > 0 ? 0 : -1
169 }
170
171 Label {
172
173=== modified file 'tests/unit_x11/tst_components/tst_ubuntulistview.qml'
174--- tests/unit_x11/tst_components/tst_ubuntulistview.qml 2014-02-25 13:31:15 +0000
175+++ tests/unit_x11/tst_components/tst_ubuntulistview.qml 2014-03-11 13:22:26 +0000
176@@ -82,6 +82,7 @@
177 ubuntuListView.expandedIndex = index;
178 var targetHeight = Math.min(item.expandedHeight, ubuntuListView.height - item.collapsedHeight);
179 tryCompare(item, "height", targetHeight);
180+ waitForRendering(ubuntuListView)
181 }
182
183 function collapse() {
184@@ -92,6 +93,7 @@
185 var expandedItem = findChild(ubuntuListView, "expandable" + ubuntuListView.expandedIndex);
186 ubuntuListView.expandedIndex = -1;
187 tryCompare(expandedItem, "height", expandedItem.collapsedHeight);
188+ waitForRendering(ubuntuListView);
189 }
190
191 function test_expandedItem() {

Subscribers

People subscribed via source and target branches

to status/vote changes: