Merge lp:~zsombi/ubuntu-ui-toolkit/60-action-value-type into lp:~bzoltan/ubuntu-ui-toolkit/new_list_item

Proposed by Zsombor Egri
Status: Superseded
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/60-action-value-type
Merge into: lp:~bzoltan/ubuntu-ui-toolkit/new_list_item
Prerequisite: lp:~zsombi/ubuntu-ui-toolkit/55-snap-options
Diff against target: 270 lines (+93/-17)
6 files modified
modules/Ubuntu/Components/ListItemPanel.qml (+23/-1)
modules/Ubuntu/Components/plugin/uclistitem.cpp (+10/-1)
modules/Ubuntu/Components/plugin/uclistitem_p.h (+1/-0)
modules/Ubuntu/Components/plugin/uclistitemoptions.cpp (+2/-1)
tests/resources/listitems/ListItemTest.qml (+6/-7)
tests/unit_x11/tst_components/tst_listitem.qml (+51/-7)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/60-action-value-type
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Pending
Ubuntu SDK team Pending
Review via email: mp+234639@code.launchpad.net

Commit message

Use the index of the ListItem if the item has been used in a component which declares the "index" context property within the ListItem's context. Usually comes from ListView or Repeater usage.

Description of the change

Use the index of the ListItem if the item has been used in a component which declares the "index" context property within the ListItem's context. Usually comes from ListView or Repeater usage.

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

prereq

1241. By Zsombor Egri

prereq merge

1242. By Zsombor Egri

prereq

1243. By Zsombor Egri

test adjusted to be able to swipe teh 4th list item as well

1244. By Zsombor Egri

prereq

1245. By Zsombor Egri

prereq

1246. By Zsombor Egri

prereq

1247. By Zsombor Egri

prereq

1248. By Zsombor Egri

prereq

1249. By Zsombor Egri

prereq

1250. By Zsombor Egri

prereq

1251. By Zsombor Egri

fixes

1252. By Zsombor Egri

prereq sync

1253. By Zsombor Egri

prereq sync

1254. By Zsombor Egri

prereq sync

1255. By Zsombor Egri

prereq sync

1256. By Zsombor Egri

prereq sync

1257. By Zsombor Egri

prereq sync

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

fixing action triggering due to snap policy changes

1268. By Zsombor Egri

prereq sync

1269. By Zsombor Egri

test case adjusted

1270. By Zsombor Egri

index fetched every time is required to make sure we always use teh proper index

1271. By Zsombor Egri

prereq sync

1272. By Zsombor Egri

index fix

1273. By Zsombor Egri

prereq sync

1274. By Zsombor Egri

prereq sync

1275. By Zsombor Egri

panel width fixes

1276. By Zsombor Egri

prereq sync

1277. By Zsombor Egri

build fix

1278. By Zsombor Egri

tests adjustments

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

prereq sync

1289. By Zsombor Egri

semicolon removal rolled back

1290. By Zsombor Egri

prereq sync

1291. By Zsombor Egri

prereq sync

1292. By Zsombor Egri

prereq sync

1293. By Zsombor Egri

move action parameterType checking to C++ at the action's addition time

1294. By Zsombor Egri

prere sync

1295. By Zsombor Egri

action parameter type restrictions documentation reformulated

1296. By Zsombor Egri

prereq sync

1297. By Zsombor Egri

prereq sync

Unmerged revisions

1297. By Zsombor Egri

prereq sync

1296. By Zsombor Egri

prereq sync

1295. By Zsombor Egri

action parameter type restrictions documentation reformulated

1294. By Zsombor Egri

prere sync

1293. By Zsombor Egri

move action parameterType checking to C++ at the action's addition time

1292. By Zsombor Egri

prereq sync

1291. By Zsombor Egri

prereq sync

1290. By Zsombor Egri

prereq sync

1289. By Zsombor Egri

semicolon removal rolled back

1288. By Zsombor Egri

prereq sync

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/ListItemPanel.qml'
2--- modules/Ubuntu/Components/ListItemPanel.qml 2014-09-15 08:45:40 +0000
3+++ modules/Ubuntu/Components/ListItemPanel.qml 2014-09-15 08:45:41 +0000
4@@ -25,6 +25,13 @@
5 width: optionsRow.childrenRect.width
6
7 readonly property Item contentItem: parent ? parent.contentItem : null
8+
9+ /*
10+ Index of the ListItem, if the ListItem is inside a ListView or has been
11+ created using a Repeater.
12+ */
13+ property int listItemIndex: -1
14+
15 /*
16 Specifies whether the panel is used to visualize leading or trailing options.
17 */
18@@ -44,6 +51,15 @@
19 */
20 signal selected()
21
22+ // fire selected action when parent is removed
23+ onParentChanged: {
24+ if (!parent && selectedAction) {
25+ selectedAction.triggered(listItemIndex >= 0 ? listItemIndex : null);
26+ selectedAction = null;
27+ }
28+ }
29+ property Action selectedAction: null
30+
31 anchors {
32 left: contentItem ? (leadingPanel ? undefined : contentItem.right) : undefined
33 right: contentItem ? (leadingPanel ? contentItem.left : undefined) : undefined
34@@ -78,7 +94,13 @@
35 top: parent.top
36 bottom: parent.bottom
37 }
38- onTriggered: panel.selected()
39+
40+ function trigger() {
41+ // save the action as we trigger when the rebound animation is over
42+ // to make sure we properly clean up the blockade of teh Flickables
43+ panel.selectedAction = action;
44+ panel.selected();
45+ }
46
47 Loader {
48 id: delegateLoader
49
50=== modified file 'modules/Ubuntu/Components/plugin/uclistitem.cpp'
51--- modules/Ubuntu/Components/plugin/uclistitem.cpp 2014-09-15 08:45:40 +0000
52+++ modules/Ubuntu/Components/plugin/uclistitem.cpp 2014-09-15 08:45:41 +0000
53@@ -279,6 +279,7 @@
54 , pressed(false)
55 , moved(false)
56 , ready(false)
57+ , index(-1)
58 , xAxisMoveThresholdGU(1.5)
59 , reboundAnimation(0)
60 , flickableInteractive(0)
61@@ -372,6 +373,7 @@
62 reboundAnimation->restart();
63 }
64
65+// set pressed flag and update background
66 // called when units size changes
67 void UCListItemPrivate::_q_updateSize()
68 {
69@@ -570,7 +572,14 @@
70 void UCListItem::componentComplete()
71 {
72 UCStyledItemBase::componentComplete();
73- d_func()->ready = true;
74+ Q_D(UCListItem);
75+ d->ready = true;
76+ // is there an index context property?
77+ QQmlContext *context = qmlContext(this);
78+ QVariant index = context->contextProperty("index");
79+ if (index.isValid()) {
80+ d->index = index.toInt();
81+ }
82 }
83
84 void UCListItem::itemChange(ItemChange change, const ItemChangeData &data)
85
86=== modified file 'modules/Ubuntu/Components/plugin/uclistitem_p.h'
87--- modules/Ubuntu/Components/plugin/uclistitem_p.h 2014-09-15 08:45:40 +0000
88+++ modules/Ubuntu/Components/plugin/uclistitem_p.h 2014-09-15 08:45:41 +0000
89@@ -62,6 +62,7 @@
90 bool moved:1;
91 bool suppressClick:1;
92 bool ready:1;
93+ int index;
94 qreal xAxisMoveThresholdGU;
95 QPointF lastPos;
96 QPointF pressedPos;
97
98=== modified file 'modules/Ubuntu/Components/plugin/uclistitemoptions.cpp'
99--- modules/Ubuntu/Components/plugin/uclistitemoptions.cpp 2014-09-15 08:45:40 +0000
100+++ modules/Ubuntu/Components/plugin/uclistitemoptions.cpp 2014-09-15 08:45:41 +0000
101@@ -111,6 +111,7 @@
102 return false;
103 }
104 _this->leading = leading;
105+ _this->panelItem->setProperty("listItemIndex", UCListItemPrivate::get(listItem)->index);
106 _this->panelItem->setProperty("leadingPanel", leading);
107 _this->panelItem->setParentItem(listItem);
108 _this->offsetDragged = 0.0;
109@@ -127,9 +128,9 @@
110 }
111
112 QObject::disconnect(_this->panelItem, SIGNAL(selected()), _this->panelItem->parentItem(), SLOT(_q_rebound()));
113- _this->panelItem->setParentItem(0);
114 _this->connected = false;
115 _this->leading = false;
116+ _this->panelItem->setParentItem(0);
117 // if there was a queuedItem, make it grab the options list
118 if (_this->queuedItem) {
119 UCListItemPrivate::get(_this->queuedItem.data())->grabPanel(options, true);
120
121=== modified file 'tests/resources/listitems/ListItemTest.qml'
122--- tests/resources/listitems/ListItemTest.qml 2014-09-15 08:45:40 +0000
123+++ tests/resources/listitems/ListItemTest.qml 2014-09-15 08:45:41 +0000
124@@ -29,7 +29,7 @@
125 id: stock
126 iconName: "starred"
127 text: "Staaaar"
128- onTriggered: print(iconName, "triggered")
129+ onTriggered: print(iconName, "triggered", value)
130 }
131
132 ListItemOptions {
133@@ -37,7 +37,7 @@
134 objectName: "StockLeading"
135 Action {
136 iconName: "delete"
137- onTriggered: print(iconName, "triggered")
138+ onTriggered: print(iconName, "triggered", value)
139 }
140 Action {
141 iconName: "alarm-clock"
142@@ -46,11 +46,11 @@
143 }
144 Action {
145 iconName: "camcorder"
146- onTriggered: print(iconName, "triggered")
147+ onTriggered: print(iconName, "triggered", value)
148 }
149 Action {
150 iconName: "stock_website"
151- onTriggered: print(iconName, "triggered")
152+ onTriggered: print(iconName, "triggered", value)
153 }
154 }
155
156@@ -63,7 +63,6 @@
157 ListItem {
158 id: testItem
159 objectName: "single"
160- contentItem.color: "lime"
161 onClicked: {
162 print("click")
163 main.override = !main.override
164@@ -135,11 +134,11 @@
165 leadingOptions: ListItemOptions {
166 Action {
167 iconName: "edit"
168- onTriggered: print(iconName, "clicked")
169+ onTriggered: print(iconName, "triggered", value)
170 }
171 Action {
172 iconName: "delete"
173- onTriggered: print(iconName, "clicked")
174+ onTriggered: print(iconName, "triggered", value)
175 }
176 }
177 trailingOptions: ListItemOptions {
178
179=== modified file 'tests/unit_x11/tst_components/tst_listitem.qml'
180--- tests/unit_x11/tst_components/tst_listitem.qml 2014-09-15 08:45:40 +0000
181+++ tests/unit_x11/tst_components/tst_listitem.qml 2014-09-15 08:45:41 +0000
182@@ -27,17 +27,25 @@
183 Action {
184 id: stockAction
185 iconName: "starred"
186+ property var param
187+ onTriggered: param = value
188 }
189 ListItemOptions {
190 id: leading
191 Action {
192- iconName: "starred"
193- }
194- Action {
195- iconName: "starred"
196- }
197- Action {
198- iconName: "starred"
199+ iconName: "delete"
200+ property var param
201+ onTriggered: param = value
202+ }
203+ Action {
204+ iconName: "edit"
205+ property var param
206+ onTriggered: param = value
207+ }
208+ Action {
209+ iconName: "camcorder"
210+ property var param
211+ onTriggered: param = value
212 }
213 }
214 ListItemOptions {
215@@ -118,6 +126,11 @@
216 target: testItem;
217 }
218
219+ SignalSpy {
220+ id: actionSpy
221+ signalName: "triggered"
222+ }
223+
224 function centerOf(item) {
225 return Qt.point(item.width / 2, item.height / 2);
226 }
227@@ -130,6 +143,7 @@
228 function cleanup() {
229 pressedSpy.clear();
230 clickSpy.clear();
231+ actionSpy.clear();
232 listView.interactive = true;
233 // tap on the first item to make sure we are rebounding all
234 mouseClick(defaults, 0, 0);
235@@ -406,5 +420,35 @@
236 }
237 waitForRendering(data.item, 800);
238 }
239+
240+ function test_verify_action_value_data() {
241+ return [
242+ {tag: "Undefined", item: testItem, result: undefined},
243+ {tag: "Index 0", item: findChild(listView, "listItem0"), result: 0},
244+ {tag: "Index 1", item: findChild(listView, "listItem1"), result: 1},
245+ {tag: "Index 2", item: findChild(listView, "listItem2"), result: 2},
246+ {tag: "Index 3", item: findChild(listView, "listItem3"), result: 3},
247+ ];
248+ }
249+ function test_verify_action_value(data) {
250+ var option = findChild(data.item.leadingOptions.panelItem, "list_option_0");
251+ verify(option, "Options panel cannot be reached");
252+ // we test the last action, as we tug the first action on leading, which means teh alst will be accessible
253+ var len = data.item.leadingOptions.options.length;
254+ var action = data.item.leadingOptions.options[len - 1];
255+ actionSpy.target = action;
256+ actionSpy.clear();
257+ // tug options in
258+ flick(data.item.contentItem, centerOf(data.item.contentItem).x, centerOf(data.item.contentItem).y, option.width, 0);
259+ waitForRendering(data.item.contentItem, 800);
260+
261+ // select the option
262+ mouseClick(data.item, centerOf(option).x, centerOf(option).y);
263+ waitForRendering(data.item.contentItem, 800);
264+
265+ // check the action param
266+ actionSpy.wait();
267+ compare(action.param, data.result, "Action parameter differs");
268+ }
269 }
270 }

Subscribers

People subscribed via source and target branches

to all changes: