Merge lp:~zsombi/ubuntu-ui-toolkit/45-selected-option-rebinds into lp:~zsombi/ubuntu-ui-toolkit/listitem-master

Proposed by Zsombor Egri
Status: Merged
Approved by: Tim Peeters
Approved revision: 1288
Merged at revision: 1274
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/45-selected-option-rebinds
Merge into: lp:~zsombi/ubuntu-ui-toolkit/listitem-master
Prerequisite: lp:~zsombi/ubuntu-ui-toolkit/40-visualize-options
Diff against target: 198 lines (+63/-17)
3 files modified
modules/Ubuntu/Components/Themes/Ambiance/ListItemPanel.qml (+22/-6)
modules/Ubuntu/Components/plugin/uclistitem_p.h (+1/-3)
tests/unit_x11/tst_components/tst_listitem.qml (+40/-8)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/45-selected-option-rebinds
Reviewer Review Type Date Requested Status
Tim Peeters Approve
Review via email: mp+235169@code.launchpad.net

Commit message

Selected leading/trailing action rebinds contentItem.

To post a comment you must log in.
1252. By Zsombor Egri

prereq sync

1253. By Zsombor Egri

prereq sync

1254. By Zsombor Egri

prereq sync

1255. By Zsombor Egri

fixing test cases

1256. By Zsombor Egri

tests fixed

1257. By Zsombor Egri

naming fix

1258. By Zsombor Egri

prereq sync

1259. By Zsombor Egri

prereq sync

1260. By Zsombor Egri

prereq sync

1261. By Zsombor Egri

prereq sync

1262. By Zsombor Egri

prereq sync

1263. By Zsombor Egri

prereq sync

1264. By Zsombor Egri

prereq sync

1265. By Zsombor Egri

prereq sync

1266. By Zsombor Egri

prereq sync

1267. By Zsombor Egri

prereq sync

1268. By Zsombor Egri

test fixed

1269. By Zsombor Egri

prereq sync

1270. By Zsombor Egri

prereq sync

1271. By Zsombor Egri

prereq sync

1272. By Zsombor Egri

prereq sync

1273. By Zsombor Egri

test fix ongoing

1274. By Zsombor Egri

based on Flickable's thinking, rename data and children properties to listItemData/listItemChildren to not to interfere with the original properties. This affects testing as well, as by using the original property names the QML children or data lookup cannot find the panelItem anymore.

1275. By Zsombor Egri

API updated

1276. By Zsombor Egri

prereq sync

1277. By Zsombor Egri

prereq sync

1278. By Zsombor Egri

prereq sync

1279. By Zsombor Egri

prereq sync

1280. By Zsombor Egri

prereq sync

1281. By Zsombor Egri

prereq sync

1282. By Zsombor Egri

prereq sync

1283. By Zsombor Egri

prereq sync

1284. By Zsombor Egri

prereq sync

1285. By Zsombor Egri

prereq sync

1286. By Zsombor Egri

prereq sync

1287. By Zsombor Egri

prereq sync

1288. By Zsombor Egri

options renamed to actions

Revision history for this message
Tim Peeters (tpeeters) wrote :

for lp:~tpeeters/+junk/lists I am trying to print the index of the list item for which an action was triggered, by adding
onTriggered: print("Action "+value)
value returns undefined if I don't set the parameterType of the Action to be Integer.

Can/Should we set the parameterType automatically? Or at least document that we should set it here? We can at least check that the parameterType is Integer, but I'm not sure what to do if it is not.

Revision history for this message
Tim Peeters (tpeeters) wrote :

^comes in 60-

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/ListItemPanel.qml'
2--- modules/Ubuntu/Components/Themes/Ambiance/ListItemPanel.qml 2014-11-25 10:59:26 +0000
3+++ modules/Ubuntu/Components/Themes/Ambiance/ListItemPanel.qml 2014-11-25 10:59:28 +0000
4@@ -18,7 +18,7 @@
5 import Ubuntu.Components 1.2
6
7 /*
8- This component is the holder of the ListItem options.
9+ This component is the holder of the ListItem actions.
10 */
11 Item {
12
13@@ -43,8 +43,8 @@
14 // panel implementation
15 id: panel
16 width: Math.max(
17- optionsRow.childrenRect.width,
18- ListItemActions.visibleActions.length * MathUtils.clamp(visualizedActionWidth, height, optionsRow.maxItemWidth))
19+ actionsRow.childrenRect.width,
20+ ListItemActions.visibleActions.length * MathUtils.clamp(visualizedActionWidth, height, actionsRow.maxItemWidth))
21
22 // used for module/autopilot testing
23 objectName: "ListItemPanel" + (leading ? "Leading" : "Trailing")
24@@ -54,7 +54,7 @@
25 */
26 readonly property Item contentItem: parent ? parent.contentItem : null
27 /*
28- Specifies whether the panel is used to visualize leading or trailing options.
29+ Specifies whether the panel is used to visualize leading or trailing actions.
30 */
31 readonly property bool leading: panel.ListItemActions.status == panel.ListItemActions.Leading
32
33@@ -76,8 +76,16 @@
34 color: panel.backgroundColor
35 }
36
37+ // handle action triggering
38+ ListItemActions.onStatusChanged: {
39+ if (ListItemActions.status === ListItemActions.Disconnected && actionsRow.selectedAction) {
40+ actionsRow.selectedAction.trigger(actionsRow.listItemIndex >= 0 ? actionsRow.listItemIndex : null);
41+ actionsRow.selectedAction = null;
42+ }
43+ }
44+
45 Row {
46- id: optionsRow
47+ id: actionsRow
48 anchors {
49 left: parent.left
50 top: parent.top
51@@ -87,17 +95,25 @@
52
53 property real maxItemWidth: panel.parent ? (panel.parent.width / panel.ListItemActions.visibleActions.length) : 0
54
55+ property Action selectedAction
56+ property int listItemIndex
57+
58 Repeater {
59 model: panel.ListItemActions.visibleActions
60 AbstractButton {
61 action: modelData
62 enabled: action.enabled
63 opacity: action.enabled ? 1.0 : 0.5
64- width: MathUtils.clamp(delegateLoader.item ? delegateLoader.item.width : 0, height, optionsRow.maxItemWidth)
65+ width: MathUtils.clamp(delegateLoader.item ? delegateLoader.item.width : 0, height, actionsRow.maxItemWidth)
66 anchors {
67 top: parent.top
68 bottom: parent.bottom
69 }
70+ function trigger() {
71+ actionsRow.selectedAction = modelData;
72+ actionsRow.listItemIndex = panel.ListItemActions.listItemIndex;
73+ panel.ListItemActions.snapToPosition(0.0);
74+ }
75
76 Rectangle {
77 anchors.fill: parent
78
79=== modified file 'modules/Ubuntu/Components/plugin/uclistitem_p.h'
80--- modules/Ubuntu/Components/plugin/uclistitem_p.h 2014-11-25 10:59:26 +0000
81+++ modules/Ubuntu/Components/plugin/uclistitem_p.h 2014-11-25 10:59:28 +0000
82@@ -83,13 +83,11 @@
83 QQmlComponent *styleComponent;
84 UCListItemStyle *styleItem;
85
86- // getter/setters
87+ // getters/setters
88 QQmlListProperty<QObject> data();
89 QQmlListProperty<QQuickItem> children();
90 bool contentMoving() const;
91 void setContentMoving(bool moved);
92- QQuickPropertyAnimation *snapAnimation() const;
93- void setSnapAnimation(QQuickPropertyAnimation *animation);
94 QQmlComponent *style() const;
95 void setStyle(QQmlComponent *delegate);
96 bool loadStyle();
97
98=== modified file 'tests/unit_x11/tst_components/tst_listitem.qml'
99--- tests/unit_x11/tst_components/tst_listitem.qml 2014-11-25 10:59:26 +0000
100+++ tests/unit_x11/tst_components/tst_listitem.qml 2014-11-25 10:59:28 +0000
101@@ -50,7 +50,6 @@
102 id: trailing
103 actions: [
104 stockAction,
105- stockAction,
106 ]
107 }
108 ListItemActions {
109@@ -170,7 +169,7 @@
110 compare(defaults.__styleInstance, null, "__styleInstance must be null.");
111
112 compare(actionsDefault.delegate, null, "ListItemActions has no delegate set by default.");
113- compare(actionsDefault.actions.length, 0, "ListItemActions has no options set.");
114+ compare(actionsDefault.actions.length, 0, "ListItemActions has no actions set.");
115 }
116
117 function test_children_in_content_item() {
118@@ -244,7 +243,7 @@
119 testItem.divider.visible = true;
120 }
121
122- function test_touch_tug_options_data() {
123+ function test_tug_actions_data() {
124 var item = findChild(listView, "listItem0");
125 return [
126 {tag: "Trailing, mouse", item: item, pos: centerOf(item), dx: -units.gu(20), positiveDirection: false, mouse: true},
127@@ -253,7 +252,7 @@
128 {tag: "Leading, touch", item: item, pos: centerOf(item), dx: units.gu(20), positiveDirection: true, mouse: false},
129 ];
130 }
131- function test_touch_tug_options(data) {
132+ function test_tug_actions(data) {
133 listView.positionViewAtBeginning();
134 movingSpy.target = data.item;
135 if (data.mouse) {
136@@ -263,9 +262,9 @@
137 }
138 movingSpy.wait();
139 if (data.positiveDirection) {
140- verify(data.item.contentItem.x > 0, data.tag + " options did not show up");
141+ verify(data.item.contentItem.x > 0, data.tag + " actions did not show up");
142 } else {
143- verify(data.item.contentItem.x < 0, data.tag + " options did not show up");
144+ verify(data.item.contentItem.x < 0, data.tag + " actions did not show up");
145 }
146
147 // dismiss
148@@ -277,9 +276,9 @@
149 var item1 = findChild(listView, "listItem1");
150 return [
151 {tag: "Click on an other Item", item: item0, pos: centerOf(item0), dx: -units.gu(20), clickOn: item1, mouse: true},
152- {tag: "Click on the same Item", item: item0, pos: centerOf(item0), dx: -units.gu(20), clickOn: item0.contentItem, mouse: true},
153+ {tag: "Click on the same Item", item: item0, pos: centerOf(item0), dx: -units.gu(20), clickOn: item0, mouse: true},
154 {tag: "Tap on an other Item", item: item0, pos: centerOf(item0), dx: -units.gu(20), clickOn: item1, mouse: false},
155- {tag: "Tap on the same Item", item: item0, pos: centerOf(item0), dx: -units.gu(20), clickOn: item0.contentItem, mouse: false},
156+ {tag: "Tap on the same Item", item: item0, pos: centerOf(item0), dx: -units.gu(20), clickOn: item0, mouse: false},
157 ];
158 }
159 function test_rebound_when_pressed_outside_or_clicked(data) {
160@@ -352,5 +351,38 @@
161 // dismiss
162 rebound(data.item);
163 }
164+
165+ function test_selecting_action_rebounds_data() {
166+ var item0 = findChild(listView, "listItem0");
167+ return [
168+ {tag: "With mouse", item: item0, pos: centerOf(item0), dx: units.gu(20), leading: true, select: "leading_1", mouse: true},
169+ {tag: "With touch", item: item0, pos: centerOf(item0), dx: units.gu(20), leading: true, select: "leading_1", mouse: false},
170+ ]
171+ }
172+ function test_selecting_action_rebounds(data) {
173+ listView.positionViewAtBeginning();
174+ movingSpy.target = data.item;
175+ if (data.mouse) {
176+ flick(data.item, data.pos.x, data.pos.y, data.dx, 0);
177+ } else {
178+ TestExtras.touchDrag(0, data.item, data.pos, Qt.point(data.dx, 0));
179+ }
180+ movingSpy.wait();
181+ verify(data.item.contentItem.x > 0, "Not snapped in!");
182+ var panel = panelItem(data.item, data.leading);
183+ verify(panel, "panelItem not found");
184+ var selectedAction = findChild(panel, data.select);
185+ verify(selectedAction, "Cannot select action " + data.select);
186+
187+ // dismiss
188+ movingSpy.clear();
189+ if (data.mouse) {
190+ mouseClick(selectedAction, centerOf(selectedAction).x, centerOf(selectedAction).y);
191+ } else {
192+ TestExtras.touchClick(0, selectedAction, centerOf(selectedAction));
193+ }
194+ movingSpy.wait();
195+ fuzzyCompare(data.item.contentItem.x, 0.0, 0.1, "Content not snapped out");
196+ }
197 }
198 }

Subscribers

People subscribed via source and target branches

to all changes: