Merge lp:~renatofilho/address-book-app/fix-1585791 into lp:address-book-app

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 592
Merged at revision: 590
Proposed branch: lp:~renatofilho/address-book-app/fix-1585791
Merge into: lp:address-book-app
Diff against target: 162 lines (+86/-5)
3 files modified
src/imports/Ubuntu/Contacts/ListItemWithActions.qml (+2/-3)
src/imports/Ubuntu/Contacts/ListItemWithActionsCheckBox.qml (+14/-2)
tests/qml/tst_ListWithActions.qml (+70/-0)
To merge this branch: bzr merge lp:~renatofilho/address-book-app/fix-1585791
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+295772@code.launchpad.net

Commit message

Propagate mouse click on ListItemWithActions.

To post a comment you must log in.
591. By Renato Araujo Oliveira Filho

Upate tests.

592. By Renato Araujo Oliveira Filho

Propagate events from checkbox to list item.

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/imports/Ubuntu/Contacts/ListItemWithActions.qml'
2--- src/imports/Ubuntu/Contacts/ListItemWithActions.qml 2016-05-17 16:25:50 +0000
3+++ src/imports/Ubuntu/Contacts/ListItemWithActions.qml 2016-05-26 18:52:30 +0000
4@@ -257,8 +257,6 @@
5 id: main
6 objectName: "mainItem"
7
8- // make sure that this item is behind the mouse area
9- z: -1
10 anchors {
11 top: parent.top
12 bottom: parent.bottom
13@@ -273,6 +271,7 @@
14
15 Loader {
16 id: selectionIcon
17+ objectName: "selectionIcon"
18
19 anchors {
20 left: main.left
21@@ -394,6 +393,7 @@
22 property real lastX: -1
23
24 anchors.fill: parent
25+ z: -1
26 drag {
27 target: locked ? null : main
28 axis: Drag.XAxis
29@@ -474,6 +474,5 @@
30 root.itemPressAndHold(mouse)
31 }
32 }
33- z: -1
34 }
35 }
36
37=== modified file 'src/imports/Ubuntu/Contacts/ListItemWithActionsCheckBox.qml'
38--- src/imports/Ubuntu/Contacts/ListItemWithActionsCheckBox.qml 2015-10-26 13:18:11 +0000
39+++ src/imports/Ubuntu/Contacts/ListItemWithActionsCheckBox.qml 2016-05-26 18:52:30 +0000
40@@ -18,8 +18,20 @@
41 import Ubuntu.Components 1.3
42
43 CheckBox {
44- checked: root.selected
45+ id: checkBoxk
46+ objectName: "listItemWithActionsCheckBox"
47 width: implicitWidth
48 // disable item mouse area to avoid conflicts with parent mouse area
49- __mouseArea.enabled: false
50+ __mouseArea {
51+ propagateComposedEvents: true
52+ onClicked: {
53+ mouse.accepted = false
54+ }
55+ }
56+
57+ Binding {
58+ target: checkBoxk
59+ property: "checked"
60+ value: root.selected
61+ }
62 }
63
64=== modified file 'tests/qml/tst_ListWithActions.qml'
65--- tests/qml/tst_ListWithActions.qml 2015-10-26 13:18:11 +0000
66+++ tests/qml/tst_ListWithActions.qml 2016-05-26 18:52:30 +0000
67@@ -52,12 +52,14 @@
68 id: listWithActions
69 objectName: "listWithActions" + index
70
71+
72 anchors {
73 left: parent.left
74 right: parent.right
75 }
76 height: units.gu(8)
77 triggerActionOnMouseRelease: true
78+
79 Rectangle {
80 anchors.fill: parent
81 color: "green"
82@@ -217,6 +219,45 @@
83 }
84 }
85
86+ ListItemWithActions {
87+ id: itemWithMouseArea
88+ objectName: "itemWithMouseArea"
89+
90+ property int clickCount: 0
91+
92+ anchors {
93+ left: parent.left
94+ right: parent.right
95+ }
96+
97+ Rectangle {
98+ anchors.fill: parent
99+ color: "black"
100+
101+ MouseArea {
102+ objectName: "itemMouseArea"
103+ anchors {
104+ left: parent.left
105+ top: parent.top
106+ bottom: parent.bottom
107+ }
108+ width: units.gu(6)
109+ onClicked: {
110+ itemWithMouseArea.clickCount++
111+ }
112+ }
113+ }
114+
115+ onItemPressAndHold: {
116+ selectionMode = true
117+ }
118+ onItemClicked: {
119+ if (selectionMode) {
120+ selected = !selected
121+ }
122+ }
123+ }
124+
125 }
126 }
127
128@@ -445,5 +486,34 @@
129 mouseRelease(itemData.item, finalX, itemData.y)
130 tryCompare(itemData.item, "swipeState", "Normal")
131 }
132+
133+ function test_enterSelectionMode()
134+ {
135+ var item = findChild(itemList, "itemWithMouseArea")
136+ mousePress(item, item.width / 2, item.height / 2, Qt.LeftButton, Qt.NoModifier, 3000)
137+ tryCompare(item, "selectionMode", true)
138+ }
139+
140+
141+ function test_selectAnItem()
142+ {
143+ var item = findChild(itemList, "itemWithMouseArea")
144+ mousePress(item, item.width / 2, item.height / 2, Qt.LeftButton, Qt.NoModifier, 2000)
145+ tryCompare(item, "selectionMode", true)
146+
147+ var checkBox = findChild(item, "selectionIcon")
148+ // wait checkbox to be fully visible
149+ mouseClick(checkBox)
150+ tryCompare(item, "selected", true)
151+ }
152+
153+ function test_clickInsideOfAnItem()
154+ {
155+ var item = findChild(itemList, "itemWithMouseArea")
156+ waitForRendering(item)
157+ var mouseArea = findChild(item, "itemMouseArea")
158+ mouseClick(mouseArea, mouseArea.width / 2, mouseArea.height /2)
159+ tryCompare(item, "clickCount", 1)
160+ }
161 }
162 }

Subscribers

People subscribed via source and target branches