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

Proposed by Zsombor Egri
Status: Merged
Approved by: Zsombor Egri
Approved revision: 1889
Merged at revision: 1893
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/listViewProxyBug
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 74 lines (+40/-2)
2 files modified
src/Ubuntu/Components/plugin/privates/listviewextensions.cpp (+4/-2)
tests/unit_x11/tst_components/tst_listitem_focus.qml (+36/-0)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/listViewProxyBug
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Tim Peeters Approve
Olivier Tilloy (community) Approve
Review via email: mp+288383@code.launchpad.net

Commit message

ListView proxy should not consume up/down key events.

To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

LGTM.

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

The code looks good, but can you add some comments to make it easier to understand?

For example:
// override up/down key presses for ListView
bool ListViewProxy::keyPressEvent(QKeyEvent *event)

suggests that this overrides the keyPressEvent() function of ListView(), which inherits that function from QQuickItem, but that function has a void return value. Mentioning the value of the return value, and that the returned value will be returned by eventFilter() is probably enough.

review: Needs Fixing
1888. By Zsombor Egri

add more comments

1889. By Zsombor Egri

staging sync

Revision history for this message
Zsombor Egri (zsombi) wrote :

> The code looks good, but can you add some comments to make it easier to
> understand?
>
> For example:
> // override up/down key presses for ListView
> bool ListViewProxy::keyPressEvent(QKeyEvent *event)
>
> suggests that this overrides the keyPressEvent() function of ListView(), which
> inherits that function from QQuickItem, but that function has a void return
> value. Mentioning the value of the return value, and that the returned value
> will be returned by eventFilter() is probably enough.
Updated.

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

Looks good, thanks.

The jenkins failure above looks unrelated.

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

E: failed to extract /home/phablet/pbuilder/vivid-armhf.tgz to /home/phablet/pbuilder/tmp/23637
1

Storage full, or /home failed to mount?

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

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/listviewextensions.cpp'
2--- src/Ubuntu/Components/plugin/privates/listviewextensions.cpp 2016-03-01 15:08:08 +0000
3+++ src/Ubuntu/Components/plugin/privates/listviewextensions.cpp 2016-03-14 17:30:57 +0000
4@@ -125,7 +125,8 @@
5 return false;
6 }
7
8-// override up/down key presses for ListView
9+// override up/down key presses for ListView; returns true if the key event is consumed
10+// in which case ListView won't get it.
11 bool ListViewProxy::keyPressEvent(QKeyEvent *event)
12 {
13 int key = event->key();
14@@ -138,6 +139,7 @@
15 // for horizontal moves take into account the layout mirroring
16 bool isRtl = QQuickItemPrivate::get(listView)->effectiveLayoutMirror;
17 bool forwards = (key == Qt::Key_Up || (isRtl ? key == Qt::Key_Left : key == Qt::Key_Right));
18+ int oldIndex = this->currentIndex();
19 int currentIndex = this->currentIndex();
20 int count = this->count();
21
22@@ -147,5 +149,5 @@
23 setKeyNavigationForListView(true);
24 }
25
26- return true;
27+ return (oldIndex != currentIndex);
28 }
29
30=== modified file 'tests/unit_x11/tst_components/tst_listitem_focus.qml'
31--- tests/unit_x11/tst_components/tst_listitem_focus.qml 2016-03-01 14:53:44 +0000
32+++ tests/unit_x11/tst_components/tst_listitem_focus.qml 2016-03-14 17:30:57 +0000
33@@ -412,6 +412,42 @@
34 tryCompare(main.activeFocusItem, "objectName", data.focus[i]);
35 }
36 }
37+
38+ SignalSpy {
39+ id: upKeySpy
40+ signalName: "upPressed"
41+ }
42+ SignalSpy {
43+ id: downKeySpy
44+ signalName: "downPressed"
45+ }
46+ function test_do_not_eat_up_down_key_events_in_listview_bug1554447() {
47+ var test = loadTest(listView);
48+ test.delegate = listItemWithContent;
49+ waitForRendering(test, 500);
50+ upKeySpy.target = test.Keys;
51+ downKeySpy.target = test.Keys;
52+ test.forceActiveFocus();
53+
54+ // test up
55+ test.positionViewAtBeginning();
56+ keyClick(Qt.Key_Up);
57+
58+ upKeySpy.wait(500);
59+
60+ // test down
61+ test.positionViewAtEnd();
62+ keyClick(Qt.Key_Down);
63+ downKeySpy.wait(500);
64+
65+ // test both up and down in the middle
66+ upKeySpy.clear(); downKeySpy.clear();
67+ test.positionViewAtIndex(test.count / 2, ListView.Center);
68+ keyClick(Qt.Key_Up);
69+ upKeySpy.wait(500);
70+ keyClick(Qt.Key_Down);
71+ downKeySpy.wait(500);
72+ }
73 }
74 }
75

Subscribers

People subscribed via source and target branches