Merge lp:~zsombi/ubuntu-ui-toolkit/listItemDropEvent into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Merged
Approved by: Cris Dywan
Approved revision: 1663
Merged at revision: 1680
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/listItemDropEvent
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 184 lines (+63/-43)
3 files modified
src/Ubuntu/Components/plugin/privates/listitemdragarea.cpp (+1/-1)
tests/unit_x11/tst_components/tst_listitem.qml (+31/-21)
tests/unit_x11/tst_components/tst_listitem13.qml (+31/-21)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/listItemDropEvent
Reviewer Review Type Date Requested Status
Cris Dywan Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+273014@code.launchpad.net

Commit message

Emit Dropped event for live ListItem drag'n'drop.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

Makes sense.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/privates/listitemdragarea.cpp'
2--- src/Ubuntu/Components/plugin/privates/listitemdragarea.cpp 2015-09-17 06:29:36 +0000
3+++ src/Ubuntu/Components/plugin/privates/listitemdragarea.cpp 2015-10-01 06:42:57 +0000
4@@ -144,7 +144,7 @@
5 // stop scroll timer
6 scrollTimer.stop();
7 UCViewItemsAttachedPrivate *pViewAttached = UCViewItemsAttachedPrivate::get(viewAttached);
8- if (pViewAttached->isDragUpdatedConnected() && (fromIndex != toIndex)) {
9+ if (pViewAttached->isDragUpdatedConnected()) {
10 UCDragEvent drag(UCDragEvent::Dropped, fromIndex, toIndex, min, max);
11 Q_EMIT viewAttached->dragUpdated(&drag);
12 updateDraggedItem();
13
14=== modified file 'tests/unit_x11/tst_components/tst_listitem.qml'
15--- tests/unit_x11/tst_components/tst_listitem.qml 2015-09-17 06:29:36 +0000
16+++ tests/unit_x11/tst_components/tst_listitem.qml 2015-10-01 06:42:57 +0000
17@@ -902,43 +902,52 @@
18
19 function test_drag_data() {
20 return [
21- {tag: "Live 0->1 OK", live: true, from: 0, to: 1, count: 1, accept: true, indices:[1,0,2,3,4]},
22- {tag: "Live 0->2 OK", live: true, from: 0, to: 2, count: 2, accept: true, indices:[1,2,0,3,4]},
23- {tag: "Live 0->3 OK", live: true, from: 0, to: 3, count: 3, accept: true, indices:[1,2,3,0,4]},
24- {tag: "Live 3->0 OK", live: true, from: 3, to: 0, count: 3, accept: true, indices:[3,0,1,2,4]},
25+ // note: Live mode adds an extra drop event when the mouse/touch is released
26+ {tag: "Live 0->1 OK", live: true, from: 0, to: 1, count: 1, dropCount: 1, accept: true, indices:[1,0,2,3,4]},
27+ {tag: "Live 0->2 OK", live: true, from: 0, to: 2, count: 2, dropCount: 1, accept: true, indices:[1,2,0,3,4]},
28+ {tag: "Live 0->3 OK", live: true, from: 0, to: 3, count: 3, dropCount: 1, accept: true, indices:[1,2,3,0,4]},
29+ {tag: "Live 3->0 OK", live: true, from: 3, to: 0, count: 3, dropCount: 1, accept: true, indices:[3,0,1,2,4]},
30 // do not accept moves
31- {tag: "Live 0->1 NOK", live: true, from: 0, to: 1, count: 0, accept: false, indices:[0,1,2,3,4]},
32- {tag: "Live 0->2 NOK", live: true, from: 0, to: 2, count: 0, accept: false, indices:[0,1,2,3,4]},
33- {tag: "Live 0->3 NOK", live: true, from: 0, to: 3, count: 0, accept: false, indices:[0,1,2,3,4]},
34- {tag: "Live 3->0 NOK", live: true, from: 3, to: 0, count: 0, accept: false, indices:[0,1,2,3,4]},
35+ {tag: "Live 0->1 NOK", live: true, from: 0, to: 1, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
36+ {tag: "Live 0->2 NOK", live: true, from: 0, to: 2, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
37+ {tag: "Live 0->3 NOK", live: true, from: 0, to: 3, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
38+ {tag: "Live 3->0 NOK", live: true, from: 3, to: 0, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
39
40 // non-live updates
41- {tag: "Drop 0->1 OK", live: false, from: 0, to: 1, count: 1, accept: true, indices:[1,0,2,3,4]},
42- {tag: "Drop 0->2 OK", live: false, from: 0, to: 2, count: 1, accept: true, indices:[1,2,0,3,4]},
43- {tag: "Drop 0->3 OK", live: false, from: 0, to: 3, count: 1, accept: true, indices:[1,2,3,0,4]},
44- {tag: "Drop 3->0 OK", live: false, from: 3, to: 0, count: 1, accept: true, indices:[3,0,1,2,4]},
45+ {tag: "Drop 0->1 OK", live: false, from: 0, to: 1, count: 1, dropCount: 1, accept: true, indices:[1,0,2,3,4]},
46+ {tag: "Drop 0->2 OK", live: false, from: 0, to: 2, count: 1, dropCount: 1, accept: true, indices:[1,2,0,3,4]},
47+ {tag: "Drop 0->3 OK", live: false, from: 0, to: 3, count: 1, dropCount: 1, accept: true, indices:[1,2,3,0,4]},
48+ {tag: "Drop 3->0 OK", live: false, from: 3, to: 0, count: 1, dropCount: 1, accept: true, indices:[3,0,1,2,4]},
49 // do not accept moves
50- {tag: "Drop 0->1 NOK", live: false, from: 0, to: 1, count: 0, accept: false, indices:[0,1,2,3,4]},
51- {tag: "Drop 0->2 NOK", live: false, from: 0, to: 2, count: 0, accept: false, indices:[0,1,2,3,4]},
52- {tag: "Drop 0->3 NOK", live: false, from: 0, to: 3, count: 0, accept: false, indices:[0,1,2,3,4]},
53- {tag: "Drop 3->0 NOK", live: false, from: 3, to: 0, count: 0, accept: false, indices:[0,1,2,3,4]},
54+ {tag: "Drop 0->1 NOK", live: false, from: 0, to: 1, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
55+ {tag: "Drop 0->2 NOK", live: false, from: 0, to: 2, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
56+ {tag: "Drop 0->3 NOK", live: false, from: 0, to: 3, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
57+ {tag: "Drop 3->0 NOK", live: false, from: 3, to: 0, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
58 ];
59 }
60
61 function test_drag(data) {
62 var moveCount = 0;
63+ var dropCount = 0;
64 function liveUpdate(event) {
65 if (event.status == ListItemDrag.Started) {
66 return;
67 }
68- if (data.accept) {
69- moveCount++;
70- listView.model.move(event.from, event.to, 1);
71- }
72- event.accept = data.accept;
73+ if (event.status == ListItemDrag.Moving) {
74+ if (data.accept) {
75+ moveCount++;
76+ listView.model.move(event.from, event.to, 1);
77+ }
78+ event.accept = data.accept;
79+ }
80+ if (event.status == ListItemDrag.Dropped) {
81+ dropCount++;
82+ event.accept = data.accept;
83+ }
84 }
85 function singleDrop(event) {
86 if (event.status == ListItemDrag.Dropped) {
87+ dropCount++;
88 if (data.accept) {
89 moveCount++;
90 listView.model.move(event.from, event.to, 1);
91@@ -959,6 +968,7 @@
92 toggleDragMode(listView, true);
93 drag(listView, data.from, data.to);
94 compare(moveCount, data.count, "Move did not happen or more than one item was moved");
95+ compare(dropCount, data.dropCount, "Dropped amount differs");
96 // compare array indices
97 for (var i in data.indices) {
98 compare(listView.model.get(i).data, data.indices[i], "data at index " + i + " is not the expected one");
99
100=== modified file 'tests/unit_x11/tst_components/tst_listitem13.qml'
101--- tests/unit_x11/tst_components/tst_listitem13.qml 2015-09-17 06:29:36 +0000
102+++ tests/unit_x11/tst_components/tst_listitem13.qml 2015-10-01 06:42:57 +0000
103@@ -921,43 +921,52 @@
104
105 function test_drag_data() {
106 return [
107- {tag: "Live 0->1 OK", live: true, from: 0, to: 1, count: 1, accept: true, indices:[1,0,2,3,4]},
108- {tag: "Live 0->2 OK", live: true, from: 0, to: 2, count: 2, accept: true, indices:[1,2,0,3,4]},
109- {tag: "Live 0->3 OK", live: true, from: 0, to: 3, count: 3, accept: true, indices:[1,2,3,0,4]},
110- {tag: "Live 3->0 OK", live: true, from: 3, to: 0, count: 3, accept: true, indices:[3,0,1,2,4]},
111+ // note: Live mode adds an extra drop event when the mouse/touch is released
112+ {tag: "Live 0->1 OK", live: true, from: 0, to: 1, count: 1, dropCount: 1, accept: true, indices:[1,0,2,3,4]},
113+ {tag: "Live 0->2 OK", live: true, from: 0, to: 2, count: 2, dropCount: 1, accept: true, indices:[1,2,0,3,4]},
114+ {tag: "Live 0->3 OK", live: true, from: 0, to: 3, count: 3, dropCount: 1, accept: true, indices:[1,2,3,0,4]},
115+ {tag: "Live 3->0 OK", live: true, from: 3, to: 0, count: 3, dropCount: 1, accept: true, indices:[3,0,1,2,4]},
116 // do not accept moves
117- {tag: "Live 0->1 NOK", live: true, from: 0, to: 1, count: 0, accept: false, indices:[0,1,2,3,4]},
118- {tag: "Live 0->2 NOK", live: true, from: 0, to: 2, count: 0, accept: false, indices:[0,1,2,3,4]},
119- {tag: "Live 0->3 NOK", live: true, from: 0, to: 3, count: 0, accept: false, indices:[0,1,2,3,4]},
120- {tag: "Live 3->0 NOK", live: true, from: 3, to: 0, count: 0, accept: false, indices:[0,1,2,3,4]},
121+ {tag: "Live 0->1 NOK", live: true, from: 0, to: 1, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
122+ {tag: "Live 0->2 NOK", live: true, from: 0, to: 2, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
123+ {tag: "Live 0->3 NOK", live: true, from: 0, to: 3, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
124+ {tag: "Live 3->0 NOK", live: true, from: 3, to: 0, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
125
126 // non-live updates
127- {tag: "Drop 0->1 OK", live: false, from: 0, to: 1, count: 1, accept: true, indices:[1,0,2,3,4]},
128- {tag: "Drop 0->2 OK", live: false, from: 0, to: 2, count: 1, accept: true, indices:[1,2,0,3,4]},
129- {tag: "Drop 0->3 OK", live: false, from: 0, to: 3, count: 1, accept: true, indices:[1,2,3,0,4]},
130- {tag: "Drop 3->0 OK", live: false, from: 3, to: 0, count: 1, accept: true, indices:[3,0,1,2,4]},
131+ {tag: "Drop 0->1 OK", live: false, from: 0, to: 1, count: 1, dropCount: 1, accept: true, indices:[1,0,2,3,4]},
132+ {tag: "Drop 0->2 OK", live: false, from: 0, to: 2, count: 1, dropCount: 1, accept: true, indices:[1,2,0,3,4]},
133+ {tag: "Drop 0->3 OK", live: false, from: 0, to: 3, count: 1, dropCount: 1, accept: true, indices:[1,2,3,0,4]},
134+ {tag: "Drop 3->0 OK", live: false, from: 3, to: 0, count: 1, dropCount: 1, accept: true, indices:[3,0,1,2,4]},
135 // do not accept moves
136- {tag: "Drop 0->1 NOK", live: false, from: 0, to: 1, count: 0, accept: false, indices:[0,1,2,3,4]},
137- {tag: "Drop 0->2 NOK", live: false, from: 0, to: 2, count: 0, accept: false, indices:[0,1,2,3,4]},
138- {tag: "Drop 0->3 NOK", live: false, from: 0, to: 3, count: 0, accept: false, indices:[0,1,2,3,4]},
139- {tag: "Drop 3->0 NOK", live: false, from: 3, to: 0, count: 0, accept: false, indices:[0,1,2,3,4]},
140+ {tag: "Drop 0->1 NOK", live: false, from: 0, to: 1, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
141+ {tag: "Drop 0->2 NOK", live: false, from: 0, to: 2, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
142+ {tag: "Drop 0->3 NOK", live: false, from: 0, to: 3, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
143+ {tag: "Drop 3->0 NOK", live: false, from: 3, to: 0, count: 0, dropCount: 1, accept: false, indices:[0,1,2,3,4]},
144 ];
145 }
146
147 function test_drag(data) {
148 var moveCount = 0;
149+ var dropCount = 0;
150 function liveUpdate(event) {
151 if (event.status == ListItemDrag.Started) {
152 return;
153 }
154- if (data.accept) {
155- moveCount++;
156- listView.model.move(event.from, event.to, 1);
157- }
158- event.accept = data.accept;
159+ if (event.status == ListItemDrag.Moving) {
160+ if (data.accept) {
161+ moveCount++;
162+ listView.model.move(event.from, event.to, 1);
163+ }
164+ event.accept = data.accept;
165+ }
166+ if (event.status == ListItemDrag.Dropped) {
167+ dropCount++;
168+ event.accept = data.accept;
169+ }
170 }
171 function singleDrop(event) {
172 if (event.status == ListItemDrag.Dropped) {
173+ dropCount++;
174 if (data.accept) {
175 moveCount++;
176 listView.model.move(event.from, event.to, 1);
177@@ -978,6 +987,7 @@
178 toggleDragMode(listView, true);
179 drag(listView, data.from, data.to);
180 compare(moveCount, data.count, "Move did not happen or more than one item was moved");
181+ compare(dropCount, data.dropCount, "Dropped amount differs");
182 // compare array indices
183 for (var i in data.indices) {
184 compare(listView.model.get(i).data, data.indices[i], "data at index " + i + " is not the expected one");

Subscribers

People subscribed via source and target branches