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

Proposed by Zsombor Egri
Status: Merged
Approved by: Tim Peeters
Approved revision: no longer in the source branch.
Merged at revision: 1562
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/listitem_selectmode
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 378 lines (+250/-1)
9 files modified
components.api (+1/-0)
modules/Ubuntu/Components/Themes/Ambiance/1.2/ListItemStyle.qml (+7/-0)
modules/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml (+5/-0)
modules/Ubuntu/Components/plugin/plugin.cpp (+1/-0)
modules/Ubuntu/Components/plugin/uclistitem.cpp (+17/-0)
modules/Ubuntu/Components/plugin/uclistitem.h (+10/-1)
modules/Ubuntu/Components/plugin/uclistitem_p.h (+1/-0)
tests/unit_x11/tst_components/tst_listitem_selectmode.qml (+104/-0)
tests/unit_x11/tst_components/tst_listitem_selectmode13.qml (+104/-0)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/listitem_selectmode
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu SDK team Pending
Review via email: mp+264123@code.launchpad.net

Commit message

Fixing selected connection with the ListItem's select mode checkbox state.

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

trunk sync

1556. By Cris Dywan

Initialize defaultTypes later to avoid bogus types.

Approved by Zsombor Egri, PS Jenkins bot.

1557. By Cris Dywan

Remove "do cleanup" comments. Fixes: https://bugs.launchpad.net/bugs/1369874.

Approved by Zsombor Egri, PS Jenkins bot.

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: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1558. By Cris Dywan

Add apicheck unit test for QML and Javascript.

Approved by PS Jenkins bot, Zsombor Egri.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1559. By Cris Dywan

Avoid hard-coded skipping of members by name

"type" can be a property name regardless of also
being a field in the JSON description of a property.

Approved by Zsombor Egri, PS Jenkins bot.

1560. By Timo Jyrinki

Add PageHeadStyle 1.3 reference to fix install_plugins_qmltypes failure with Qt 5.5. Fixes: https://bugs.launchpad.net/bugs/1466484.

Approved by PS Jenkins bot, Zsombor Egri.

1561. By Timo Jyrinki

Fix ucstylehints.cpp compilation with Qt 5.5. Fixes: https://bugs.launchpad.net/bugs/1473873.

Approved by Zsombor Egri, PS Jenkins bot.

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

Looks good, only one comment: can you add the bug id in the test function name? See
$ grep test tests/unit_x11/tst_components/* | grep bug

1562. By Zsombor Egri

Fixing selected connection with the ListItem's select mode checkbox state. Fixes: https://bugs.launchpad.net/bugs/1461501, https://bugs.launchpad.net/bugs/1469471.

Approved by PS Jenkins bot.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2015-07-13 18:26:32 +0000
3+++ components.api 2015-07-14 09:15:55 +0000
4@@ -465,6 +465,7 @@
5 property bool selectMode
6 property bool selected
7 property ListItemActions trailingActions
8+Ubuntu.Components.ListItem 1.3: ListItem
9 Ubuntu.Components.ListItemActions 1.2: QtObject
10 readonly property Action actions
11 default readonly property QtObject data
12
13=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/1.2/ListItemStyle.qml'
14--- modules/Ubuntu/Components/Themes/Ambiance/1.2/ListItemStyle.qml 2015-04-24 14:43:08 +0000
15+++ modules/Ubuntu/Components/Themes/Ambiance/1.2/ListItemStyle.qml 2015-07-14 09:15:55 +0000
16@@ -29,6 +29,8 @@
17
18 // anchoring
19 anchors {
20+ // do not anchor fill
21+ fill: undefined
22 top: parent ? parent.top : undefined
23 bottom: parent ? parent.bottom : undefined
24 bottomMargin: styledItem.divider.visible ? styledItem.divider.height : 0
25@@ -141,6 +143,11 @@
26 // for the initial value
27 checked: styledItem.selected
28 onCheckedChanged: styledItem.selected = checked;
29+ Binding {
30+ target: checkbox
31+ property: "checked"
32+ value: styledItem.selected
33+ }
34 }
35
36 states: State {
37
38=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml'
39--- modules/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml 2015-04-24 14:07:02 +0000
40+++ modules/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml 2015-07-14 09:15:55 +0000
41@@ -138,6 +138,11 @@
42 // for the initial value
43 checked: styledItem.selected
44 onCheckedChanged: styledItem.selected = checked;
45+ Binding {
46+ target: checkbox
47+ property: "checked"
48+ value: styledItem.selected
49+ }
50 }
51
52 states: State {
53
54=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
55--- modules/Ubuntu/Components/plugin/plugin.cpp 2015-07-07 13:57:50 +0000
56+++ modules/Ubuntu/Components/plugin/plugin.cpp 2015-07-14 09:15:55 +0000
57@@ -208,6 +208,7 @@
58 qmlRegisterType<UCUbuntuShapeOverlay>(uri, 1, 2, "UbuntuShapeOverlay");
59
60 // register 1.3 API
61+ qmlRegisterType<UCListItem13>(uri, 1, 3, "ListItem");
62 qmlRegisterType<UCTheme>(uri, 1, 3, "ThemeSettings");
63 qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem");
64 qmlRegisterSingletonType<UCNamespaceV13>(uri, 1, 3, "Ubuntu", registerUbuntuNamespace13);
65
66=== modified file 'modules/Ubuntu/Components/plugin/uclistitem.cpp'
67--- modules/Ubuntu/Components/plugin/uclistitem.cpp 2015-05-26 08:33:49 +0000
68+++ modules/Ubuntu/Components/plugin/uclistitem.cpp 2015-07-14 09:15:55 +0000
69@@ -25,6 +25,7 @@
70 #include "i18n.h"
71 #include "quickutils.h"
72 #include "ucaction.h"
73+#include "ucnamespace.h"
74 #include <QtQml/QQmlInfo>
75 #include <QtQuick/private/qquickitem_p.h>
76 #include <QtQuick/private/qquickflickable_p.h>
77@@ -179,6 +180,7 @@
78 */
79 UCListItemPrivate::UCListItemPrivate()
80 : UCStyledItemBasePrivate()
81+ , defaultThemeVersion(0)
82 , highlighted(false)
83 , contentMoved(false)
84 , swiped(false)
85@@ -901,6 +903,7 @@
86 {
87 Q_D(UCListItem);
88 d->init();
89+ d->defaultThemeVersion = BUILD_VERSION(1, 2);
90 }
91
92 UCListItem::~UCListItem()
93@@ -912,6 +915,10 @@
94 UCStyledItemBase::classBegin();
95 Q_D(UCListItem);
96 // initialize theme
97+ UCTheme *theme = d->getTheme();
98+ if (theme == &UCTheme::defaultTheme()) {
99+ theme->setVersion(d->defaultThemeVersion);
100+ }
101 d->_q_themeChanged();
102 d->divider->paletteChanged();
103 }
104@@ -1551,4 +1558,14 @@
105 return QQuickItemPrivate::get(contentItem)->children();
106 }
107
108+/******************************************************************************
109+ * Versioning
110+ */
111+UCListItem13::UCListItem13(QQuickItem *parent)
112+ : UCListItem(parent)
113+{
114+ Q_D(UCListItem);
115+ d->defaultThemeVersion = BUILD_VERSION(1, 3);
116+}
117+
118 #include "moc_uclistitem.cpp"
119
120=== modified file 'modules/Ubuntu/Components/plugin/uclistitem.h'
121--- modules/Ubuntu/Components/plugin/uclistitem.h 2015-04-14 08:31:20 +0000
122+++ modules/Ubuntu/Components/plugin/uclistitem.h 2015-07-14 09:15:55 +0000
123@@ -95,8 +95,10 @@
124
125 public Q_SLOTS:
126
127-private:
128+protected:
129 Q_DECLARE_PRIVATE(UCListItem)
130+
131+private:
132 Q_PRIVATE_SLOT(d_func(), void _q_themeChanged())
133 Q_PRIVATE_SLOT(d_func(), void _q_relayout())
134 Q_PRIVATE_SLOT(d_func(), void _q_updateSwiping())
135@@ -107,6 +109,13 @@
136 Q_PRIVATE_SLOT(d_func(), void _q_syncDragMode())
137 };
138
139+class UCListItem13 : public UCListItem
140+{
141+ Q_OBJECT
142+public:
143+ explicit UCListItem13(QQuickItem *parent = 0);
144+};
145+
146 class UCListItemDividerPrivate;
147 class UCListItemDivider : public QQuickItem
148 {
149
150=== modified file 'modules/Ubuntu/Components/plugin/uclistitem_p.h'
151--- modules/Ubuntu/Components/plugin/uclistitem_p.h 2015-05-21 10:50:35 +0000
152+++ modules/Ubuntu/Components/plugin/uclistitem_p.h 2015-07-14 09:15:55 +0000
153@@ -68,6 +68,7 @@
154 void snapOut();
155 void swipeEvent(const QPointF &localPos, UCSwipeEvent::Status status);
156
157+ quint16 defaultThemeVersion;
158 bool highlighted:1;
159 bool contentMoved:1;
160 bool swiped:1;
161
162=== added file 'tests/unit_x11/tst_components/tst_listitem_selectmode.qml'
163--- tests/unit_x11/tst_components/tst_listitem_selectmode.qml 1970-01-01 00:00:00 +0000
164+++ tests/unit_x11/tst_components/tst_listitem_selectmode.qml 2015-07-14 09:15:55 +0000
165@@ -0,0 +1,104 @@
166+/*
167+ * Copyright 2015 Canonical Ltd.
168+ *
169+ * This program is free software; you can redistribute it and/or modify
170+ * it under the terms of the GNU Lesser General Public License as published by
171+ * the Free Software Foundation; version 3.
172+ *
173+ * This program is distributed in the hope that it will be useful,
174+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
175+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
176+ * GNU Lesser General Public License for more details.
177+ *
178+ * You should have received a copy of the GNU Lesser General Public License
179+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
180+ */
181+
182+import QtQuick 2.4
183+import Ubuntu.Components 1.2
184+import QtTest 1.0
185+import Ubuntu.Test 1.0
186+
187+MainView {
188+ applicationName: "testapp.nik90"
189+
190+ width: units.gu(100)
191+ height: units.gu(75)
192+
193+ Page {
194+ title: i18n.tr("ListView Bug")
195+
196+ UbuntuListView {
197+ id: listView
198+
199+ ListModel {
200+ id: instructionModel
201+ ListElement { text: "Let's try to reproduce this listview bug ;)" }
202+ ListElement { text: "Step 1: Long press to active multiselect mode" }
203+ ListElement { text: "Step 2: Press on any checkbox to select that listitem" }
204+ ListElement { text: "Step 3: Now press on the list item of the checkbox you chose in the previous step." }
205+ ListElement { text: "Notice how it doesn't select/unselect it despite pressing it" }
206+ ListElement { text: "Also notice how when pressing on the listitem in step 3, the selected indice still changes!" }
207+ }
208+
209+ anchors.fill: parent
210+ model: instructionModel
211+
212+ delegate: ListItem {
213+ objectName: "listItem" + index
214+ height: units.gu(8)
215+ contentItem.anchors { leftMargin: units.gu(2); rightMargin: units.gu(2) }
216+
217+ Label {
218+ id: label
219+ text: modelData
220+ anchors.fill: parent
221+ wrapMode: Text.WordWrap
222+ verticalAlignment: Text.AlignVCenter
223+ }
224+
225+ onPressAndHold: {
226+ ListView.view.ViewItems.selectMode = !ListView.view.ViewItems.selectMode
227+ }
228+
229+ onClicked: {
230+ if (selectMode) {
231+ selected = !selected
232+ }
233+ }
234+ }
235+
236+ footer: Label {
237+ anchors { left: parent.left; leftMargin: units.gu(2) }
238+ width: parent.width
239+ text: "Selected Indices: " + listView.ViewItems.selectedIndices
240+ }
241+ }
242+ }
243+
244+ UbuntuTestCase {
245+ when: windowShown
246+
247+ function test_select_toggle_breaks_property_binding_bug1469471() {
248+ listView.ViewItems.selectMode = true;
249+ wait(400);
250+
251+ // select through checkbox
252+ var listItem = findChild(listView, "listItem0");
253+ verify(listItem);
254+ var panel = findChild(listItem, "selection_panel0");
255+ verify(panel);
256+ var checkBox = findChild(panel, "listitem_select");
257+ verify(checkBox);
258+
259+ // check the box
260+ mouseClick(checkBox, 0, 0);
261+ compare(checkBox.checked, true);
262+
263+ // now toggle selected
264+ listItem.selected = !listItem.selected;
265+ compare(checkBox.checked, false);
266+ }
267+ }
268+}
269+
270
271=== added file 'tests/unit_x11/tst_components/tst_listitem_selectmode13.qml'
272--- tests/unit_x11/tst_components/tst_listitem_selectmode13.qml 1970-01-01 00:00:00 +0000
273+++ tests/unit_x11/tst_components/tst_listitem_selectmode13.qml 2015-07-14 09:15:55 +0000
274@@ -0,0 +1,104 @@
275+/*
276+ * Copyright 2015 Canonical Ltd.
277+ *
278+ * This program is free software; you can redistribute it and/or modify
279+ * it under the terms of the GNU Lesser General Public License as published by
280+ * the Free Software Foundation; version 3.
281+ *
282+ * This program is distributed in the hope that it will be useful,
283+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
284+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
285+ * GNU Lesser General Public License for more details.
286+ *
287+ * You should have received a copy of the GNU Lesser General Public License
288+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
289+ */
290+
291+import QtQuick 2.4
292+import Ubuntu.Components 1.3
293+import QtTest 1.0
294+import Ubuntu.Test 1.0
295+
296+MainView {
297+ applicationName: "testapp.nik90"
298+
299+ width: units.gu(100)
300+ height: units.gu(75)
301+
302+ Page {
303+ title: i18n.tr("ListView Bug")
304+
305+ UbuntuListView {
306+ id: listView
307+
308+ ListModel {
309+ id: instructionModel
310+ ListElement { text: "Let's try to reproduce this listview bug ;)" }
311+ ListElement { text: "Step 1: Long press to active multiselect mode" }
312+ ListElement { text: "Step 2: Press on any checkbox to select that listitem" }
313+ ListElement { text: "Step 3: Now press on the list item of the checkbox you chose in the previous step." }
314+ ListElement { text: "Notice how it doesn't select/unselect it despite pressing it" }
315+ ListElement { text: "Also notice how when pressing on the listitem in step 3, the selected indice still changes!" }
316+ }
317+
318+ anchors.fill: parent
319+ model: instructionModel
320+
321+ delegate: ListItem {
322+ objectName: "listItem" + index
323+ height: units.gu(8)
324+ contentItem.anchors { leftMargin: units.gu(2); rightMargin: units.gu(2) }
325+
326+ Label {
327+ id: label
328+ text: modelData
329+ anchors.fill: parent
330+ wrapMode: Text.WordWrap
331+ verticalAlignment: Text.AlignVCenter
332+ }
333+
334+ onPressAndHold: {
335+ ListView.view.ViewItems.selectMode = !ListView.view.ViewItems.selectMode
336+ }
337+
338+ onClicked: {
339+ if (selectMode) {
340+ selected = !selected
341+ }
342+ }
343+ }
344+
345+ footer: Label {
346+ anchors { left: parent.left; leftMargin: units.gu(2) }
347+ width: parent.width
348+ text: "Selected Indices: " + listView.ViewItems.selectedIndices
349+ }
350+ }
351+ }
352+
353+ UbuntuTestCase {
354+ when: windowShown
355+
356+ function test_select_toggle_breaks_property_binding_bug1469471() {
357+ listView.ViewItems.selectMode = true;
358+ wait(400);
359+
360+ // select through checkbox
361+ var listItem = findChild(listView, "listItem0");
362+ verify(listItem);
363+ var panel = findChild(listItem, "selection_panel0");
364+ verify(panel);
365+ var checkBox = findChild(panel, "listitem_select");
366+ verify(checkBox);
367+
368+ // check the box
369+ mouseClick(checkBox, 0, 0);
370+ compare(checkBox.checked, true);
371+
372+ // now toggle selected
373+ listItem.selected = !listItem.selected;
374+ compare(checkBox.checked, false);
375+ }
376+ }
377+}
378+

Subscribers

People subscribed via source and target branches