Merge lp:~zsombi/ubuntu-ui-toolkit/listItemExpandContent into lp:ubuntu-ui-toolkit/staging
- listItemExpandContent
- Merge into staging
Status: | Work in progress |
---|---|
Proposed branch: | lp:~zsombi/ubuntu-ui-toolkit/listItemExpandContent |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Prerequisite: | lp:~zsombi/ubuntu-ui-toolkit/listitem_expansion |
Diff against target: |
832 lines (+476/-34) 10 files modified
components.api (+4/-0) examples/ubuntu-ui-toolkit-gallery/ListItemWithLabel.qml (+0/-1) examples/ubuntu-ui-toolkit-gallery/NewListItems.qml (+117/-1) src/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml (+159/-10) src/Ubuntu/Components/plugin/privates/listitemexpansion.cpp (+72/-0) src/Ubuntu/Components/plugin/uclistitem.cpp (+69/-5) src/Ubuntu/Components/plugin/uclistitem.h (+14/-0) src/Ubuntu/Components/plugin/uclistitem_p.h (+2/-0) src/Ubuntu/Components/plugin/ucviewitemsattached.cpp (+8/-1) tests/resources/listitems/ListItemExpansion.qml (+31/-16) |
To merge this branch: | bzr merge lp:~zsombi/ubuntu-ui-toolkit/listItemExpandContent |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu SDK team | Pending | ||
Review via email: mp+269910@code.launchpad.net |
Commit message
Description of the change
- 1626. By Zsombor Egri
-
API added
- 1627. By Zsombor Egri
-
preparing states
- 1628. By Zsombor Egri
-
transition management
- 1629. By Zsombor Egri
-
style transitions on the go
- 1630. By Zsombor Egri
-
reverting custom transitions
- 1631. By Zsombor Egri
-
contentItem added, expansion under ListItem.
contentItem implemented - 1632. By Zsombor Egri
-
rename hideCollapsedCo
ntent with overlapListItem - 1633. By Zsombor Egri
-
API updated
- 1634. By Zsombor Egri
-
overlapping content support
- 1635. By Zsombor Egri
-
docs updated
- 1636. By Zsombor Egri
-
few examples in gallery
- 1637. By Zsombor Egri
-
sync
- 1638. By Zsombor Egri
-
simplifying transitions
- 1639. By Zsombor Egri
-
small tweaks to avoid expanded being highlighted when the expanded content is scrollable
- 1640. By Zsombor Egri
-
lock expanded when content is Flickable
Unmerged revisions
- 1640. By Zsombor Egri
-
lock expanded when content is Flickable
- 1639. By Zsombor Egri
-
small tweaks to avoid expanded being highlighted when the expanded content is scrollable
- 1638. By Zsombor Egri
-
simplifying transitions
- 1637. By Zsombor Egri
-
sync
- 1636. By Zsombor Egri
-
few examples in gallery
- 1635. By Zsombor Egri
-
docs updated
- 1634. By Zsombor Egri
-
overlapping content support
- 1633. By Zsombor Egri
-
API updated
- 1632. By Zsombor Egri
-
rename hideCollapsedCo
ntent with overlapListItem - 1631. By Zsombor Egri
-
contentItem added, expansion under ListItem.
contentItem implemented
Preview Diff
1 | === modified file 'components.api' | |||
2 | --- components.api 2015-09-04 12:35:16 +0000 | |||
3 | +++ components.api 2015-09-09 10:37:17 +0000 | |||
4 | @@ -472,6 +472,7 @@ | |||
5 | 472 | Started | 472 | Started |
6 | 473 | Ubuntu.Components.Styles.ListItemStyle 1.3 1.2: Item | 473 | Ubuntu.Components.Styles.ListItemStyle 1.3 1.2: Item |
7 | 474 | readonly property bool animatePanels | 474 | readonly property bool animatePanels |
8 | 475 | readonly property bool completed 1.3 | ||
9 | 475 | property Item dragPanel | 476 | property Item dragPanel |
10 | 476 | property PropertyAnimation dropAnimation | 477 | property PropertyAnimation dropAnimation |
11 | 477 | readonly property Flickable flickable 1.3 | 478 | readonly property Flickable flickable 1.3 |
12 | @@ -1248,8 +1249,11 @@ | |||
13 | 1248 | property color colorFrom | 1249 | property color colorFrom |
14 | 1249 | property color colorTo | 1250 | property color colorTo |
15 | 1250 | UCListItemExpansion: QtObject | 1251 | UCListItemExpansion: QtObject |
16 | 1252 | property Component content | ||
17 | 1253 | readonly property Item contentItem | ||
18 | 1251 | property bool expanded | 1254 | property bool expanded |
19 | 1252 | property double height | 1255 | property double height |
20 | 1256 | property bool overlapListItem | ||
21 | 1253 | UCStateSaverAttached: QtObject | 1257 | UCStateSaverAttached: QtObject |
22 | 1254 | property bool enabled | 1258 | property bool enabled |
23 | 1255 | property string properties | 1259 | property string properties |
24 | 1256 | 1260 | ||
25 | === modified file 'examples/ubuntu-ui-toolkit-gallery/ListItemWithLabel.qml' | |||
26 | --- examples/ubuntu-ui-toolkit-gallery/ListItemWithLabel.qml 2015-07-03 16:52:20 +0000 | |||
27 | +++ examples/ubuntu-ui-toolkit-gallery/ListItemWithLabel.qml 2015-09-09 10:37:17 +0000 | |||
28 | @@ -27,5 +27,4 @@ | |||
29 | 27 | verticalCenter: parent.verticalCenter | 27 | verticalCenter: parent.verticalCenter |
30 | 28 | } | 28 | } |
31 | 29 | } | 29 | } |
32 | 30 | onPressAndHold: selectMode = !selectMode | ||
33 | 31 | } | 30 | } |
34 | 32 | 31 | ||
35 | === modified file 'examples/ubuntu-ui-toolkit-gallery/NewListItems.qml' | |||
36 | --- examples/ubuntu-ui-toolkit-gallery/NewListItems.qml 2015-04-25 08:18:45 +0000 | |||
37 | +++ examples/ubuntu-ui-toolkit-gallery/NewListItems.qml 2015-09-09 10:37:17 +0000 | |||
38 | @@ -34,13 +34,15 @@ | |||
39 | 34 | // clip the action delegates while swiping left/right | 34 | // clip the action delegates while swiping left/right |
40 | 35 | clip: true | 35 | clip: true |
41 | 36 | 36 | ||
43 | 37 | ListItemWithLabel { | 37 | ListItemWithLabel { |
44 | 38 | color: UbuntuColors.blue | 38 | color: UbuntuColors.blue |
45 | 39 | text: i18n.tr("Colored") | 39 | text: i18n.tr("Colored") |
46 | 40 | onPressAndHold: selectMode = !selectMode | ||
47 | 40 | } | 41 | } |
48 | 41 | ListItemWithLabel { | 42 | ListItemWithLabel { |
49 | 42 | text: i18n.tr("Highlight color") | 43 | text: i18n.tr("Highlight color") |
50 | 43 | highlightColor: UbuntuColors.orange | 44 | highlightColor: UbuntuColors.orange |
51 | 45 | onPressAndHold: selectMode = !selectMode | ||
52 | 44 | // no highlight without clicked() or leading/trailing actions | 46 | // no highlight without clicked() or leading/trailing actions |
53 | 45 | } | 47 | } |
54 | 46 | 48 | ||
55 | @@ -70,18 +72,22 @@ | |||
56 | 70 | ListItemWithLabel { | 72 | ListItemWithLabel { |
57 | 71 | text: i18n.tr("Leading actions") | 73 | text: i18n.tr("Leading actions") |
58 | 72 | leadingActions: exampleLeadingActions | 74 | leadingActions: exampleLeadingActions |
59 | 75 | onPressAndHold: selectMode = !selectMode | ||
60 | 73 | } | 76 | } |
61 | 74 | ListItemWithLabel { | 77 | ListItemWithLabel { |
62 | 75 | text: i18n.tr("Trailing actions") | 78 | text: i18n.tr("Trailing actions") |
63 | 76 | trailingActions: exampleTrailingActions | 79 | trailingActions: exampleTrailingActions |
64 | 80 | onPressAndHold: selectMode = !selectMode | ||
65 | 77 | } | 81 | } |
66 | 78 | ListItemWithLabel { | 82 | ListItemWithLabel { |
67 | 79 | text: i18n.tr("Leading and trailing actions") | 83 | text: i18n.tr("Leading and trailing actions") |
68 | 80 | leadingActions: exampleLeadingActions | 84 | leadingActions: exampleLeadingActions |
69 | 81 | trailingActions: exampleTrailingActions | 85 | trailingActions: exampleTrailingActions |
70 | 86 | onPressAndHold: selectMode = !selectMode | ||
71 | 82 | } | 87 | } |
72 | 83 | ListItemWithLabel { | 88 | ListItemWithLabel { |
73 | 84 | text: i18n.tr("Custom action delegates") | 89 | text: i18n.tr("Custom action delegates") |
74 | 90 | onPressAndHold: selectMode = !selectMode | ||
75 | 85 | leadingActions: ListItemActions { | 91 | leadingActions: ListItemActions { |
76 | 86 | actions: [ | 92 | actions: [ |
77 | 87 | Action { | 93 | Action { |
78 | @@ -163,6 +169,7 @@ | |||
79 | 163 | model: [ i18n.tr("Basic"), i18n.tr("Colored divider"), i18n.tr("Immutable"), i18n.tr("No divider") ] | 169 | model: [ i18n.tr("Basic"), i18n.tr("Colored divider"), i18n.tr("Immutable"), i18n.tr("No divider") ] |
80 | 164 | delegate: ListItemWithLabel { | 170 | delegate: ListItemWithLabel { |
81 | 165 | text: modelData | 171 | text: modelData |
82 | 172 | onPressAndHold: selectMode = !selectMode | ||
83 | 166 | color: dragging ? "lightblue" : "transparent" | 173 | color: dragging ? "lightblue" : "transparent" |
84 | 167 | divider { | 174 | divider { |
85 | 168 | colorFrom: modelData == i18n.tr("Colored divider") ? UbuntuColors.red : Qt.rgba(0.0, 0.0, 0.0, 0.0) | 175 | colorFrom: modelData == i18n.tr("Colored divider") ? UbuntuColors.red : Qt.rgba(0.0, 0.0, 0.0, 0.0) |
86 | @@ -209,6 +216,7 @@ | |||
87 | 209 | delegate: ListItemWithLabel { | 216 | delegate: ListItemWithLabel { |
88 | 210 | text: modelData | 217 | text: modelData |
89 | 211 | color: dragMode ? "lightblue" : "lightgray" | 218 | color: dragMode ? "lightblue" : "lightgray" |
90 | 219 | onPressAndHold: selectMode = !selectMode | ||
91 | 212 | divider { | 220 | divider { |
92 | 213 | colorFrom: modelData == i18n.tr("Colored divider") ? UbuntuColors.red : Qt.rgba(0.0, 0.0, 0.0, 0.0) | 221 | colorFrom: modelData == i18n.tr("Colored divider") ? UbuntuColors.red : Qt.rgba(0.0, 0.0, 0.0, 0.0) |
93 | 214 | colorTo: modelData == i18n.tr("Colored divider") ? UbuntuColors.green : Qt.rgba(0.0, 0.0, 0.0, 0.0) | 222 | colorTo: modelData == i18n.tr("Colored divider") ? UbuntuColors.green : Qt.rgba(0.0, 0.0, 0.0, 0.0) |
94 | @@ -217,4 +225,112 @@ | |||
95 | 217 | } | 225 | } |
96 | 218 | } | 226 | } |
97 | 219 | } | 227 | } |
98 | 228 | |||
99 | 229 | TemplateSection { | ||
100 | 230 | className: "ListItem" | ||
101 | 231 | title: "Expansion - exclusive, unlocked, auto-collapsing" | ||
102 | 232 | |||
103 | 233 | UbuntuListView { | ||
104 | 234 | width: parent.width | ||
105 | 235 | height: units.gu(28) | ||
106 | 236 | clip: true | ||
107 | 237 | model: 5 | ||
108 | 238 | ViewItems.expansionFlags: ViewItems.CollapseOnOutsidePress | ViewItems.UnlockExpanded | ||
109 | 239 | delegate: ListItemWithLabel { | ||
110 | 240 | text: i18n.tr("Item #%1: pressAndHold to expand/collapse").arg(modelData) | ||
111 | 241 | leadingActions: exampleLeadingActions | ||
112 | 242 | trailingActions: exampleTrailingActions | ||
113 | 243 | expansion.height: units.gu(15) | ||
114 | 244 | onPressAndHold: expansion.expanded = !expansion.expanded | ||
115 | 245 | } | ||
116 | 246 | } | ||
117 | 247 | } | ||
118 | 248 | |||
119 | 249 | TemplateSection { | ||
120 | 250 | className: "ListItem" | ||
121 | 251 | title: "Expansion - content under collapsed layout" | ||
122 | 252 | |||
123 | 253 | UbuntuListView { | ||
124 | 254 | id: view | ||
125 | 255 | width: parent.width | ||
126 | 256 | height: units.gu(28) | ||
127 | 257 | clip: true | ||
128 | 258 | model: ListModel { | ||
129 | 259 | Component.onCompleted: { | ||
130 | 260 | for (var i = 0; i < 5; i++) { | ||
131 | 261 | append({label: i18n.tr("Item #%1: pressAndHold to expand/collapse").arg(i)}) | ||
132 | 262 | } | ||
133 | 263 | } | ||
134 | 264 | } | ||
135 | 265 | |||
136 | 266 | delegate: ListItemWithLabel { | ||
137 | 267 | id: mainItem | ||
138 | 268 | property int itemIndex: index | ||
139 | 269 | text: label | ||
140 | 270 | onPressAndHold: expansion.expanded = !expansion.expanded | ||
141 | 271 | expansion { | ||
142 | 272 | height: units.gu(21) | ||
143 | 273 | content: UbuntuListView { | ||
144 | 274 | clip: true | ||
145 | 275 | anchors.right: parent.right | ||
146 | 276 | width: parent.width - units.gu(4) | ||
147 | 277 | height: units.gu(14) | ||
148 | 278 | model: 5 | ||
149 | 279 | delegate: ListItemWithLabel { | ||
150 | 280 | text: i18n.tr("Sub-item #%1").arg(modelData) | ||
151 | 281 | onClicked: { | ||
152 | 282 | view.model.get(mainItem.itemIndex).label = "Replaced with " + text; | ||
153 | 283 | mainItem.expansion.expanded = false; | ||
154 | 284 | } | ||
155 | 285 | } | ||
156 | 286 | } | ||
157 | 287 | } | ||
158 | 288 | } | ||
159 | 289 | } | ||
160 | 290 | } | ||
161 | 291 | |||
162 | 292 | TemplateSection { | ||
163 | 293 | className: "ListItem" | ||
164 | 294 | title: "Expansion - content over ListItem" | ||
165 | 295 | |||
166 | 296 | UbuntuListView { | ||
167 | 297 | id: view2 | ||
168 | 298 | width: parent.width | ||
169 | 299 | height: units.gu(28) | ||
170 | 300 | clip: true | ||
171 | 301 | model: ListModel { | ||
172 | 302 | Component.onCompleted: { | ||
173 | 303 | for (var i = 0; i < 5; i++) { | ||
174 | 304 | append({label: i18n.tr("Item #%1: pressAndHold to expand/collapse").arg(i)}) | ||
175 | 305 | } | ||
176 | 306 | } | ||
177 | 307 | } | ||
178 | 308 | ViewItems.expansionFlags: ViewItems.CollapseOnOutsidePress | ||
179 | 309 | |||
180 | 310 | delegate: ListItemWithLabel { | ||
181 | 311 | id: mainItem2 | ||
182 | 312 | property int itemIndex: index | ||
183 | 313 | text: label | ||
184 | 314 | onPressAndHold: { print(1); expansion.expanded = !expansion.expanded} | ||
185 | 315 | expansion { | ||
186 | 316 | height: units.gu(21) | ||
187 | 317 | overlapListItem: true | ||
188 | 318 | content: UbuntuListView { | ||
189 | 319 | clip: true | ||
190 | 320 | anchors.right: parent.right | ||
191 | 321 | width: parent.width - units.gu(4) | ||
192 | 322 | height: units.gu(14) | ||
193 | 323 | model: 5 | ||
194 | 324 | delegate: ListItemWithLabel { | ||
195 | 325 | text: i18n.tr("Sub-item #%1").arg(modelData) | ||
196 | 326 | onClicked: { | ||
197 | 327 | view2.model.get(mainItem2.itemIndex).label = "Replaced with " + text; | ||
198 | 328 | mainItem2.expansion.expanded = false; | ||
199 | 329 | } | ||
200 | 330 | } | ||
201 | 331 | } | ||
202 | 332 | } | ||
203 | 333 | } | ||
204 | 334 | } | ||
205 | 335 | } | ||
206 | 220 | } | 336 | } |
207 | 221 | 337 | ||
208 | === modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml' | |||
209 | --- src/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml 2015-09-04 09:32:31 +0000 | |||
210 | +++ src/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml 2015-09-09 10:37:17 +0000 | |||
211 | @@ -423,7 +423,24 @@ | |||
212 | 423 | 423 | ||
213 | 424 | // expansion | 424 | // expansion |
214 | 425 | Component.onCompleted: internals.completed = true | 425 | Component.onCompleted: internals.completed = true |
216 | 426 | state: (internals.completed && styledItem.expansion.expanded) ? (listItemStyle.flickable ? "expandedWithFlickable" : "expandedNoFlickable") : "" | 426 | state: { |
217 | 427 | if (!internals.completed || !styledItem.expansion.expanded) { | ||
218 | 428 | return ""; | ||
219 | 429 | } | ||
220 | 430 | // states are: | ||
221 | 431 | // expandedWithFlickable, expandedNoFlickable | ||
222 | 432 | // expandedOverContentWithFlickable, expandedOverContentNoFlickable | ||
223 | 433 | // expandedUnderContentWithFlickable, expandedUnderContentNoFlickable | ||
224 | 434 | var result = "expanded"; | ||
225 | 435 | |||
226 | 436 | if (styledItem.expansion.content) { | ||
227 | 437 | result += styledItem.expansion.overlapListItem ? "OverContent" : "UnderContent"; | ||
228 | 438 | } | ||
229 | 439 | |||
230 | 440 | result += (listItemStyle.flickable) ? "WithFlickable" : "NoFlickable"; | ||
231 | 441 | |||
232 | 442 | return result; | ||
233 | 443 | } | ||
234 | 427 | states: [ | 444 | states: [ |
235 | 428 | State { | 445 | State { |
236 | 429 | name: "expandedNoFlickable" | 446 | name: "expandedNoFlickable" |
237 | @@ -454,6 +471,104 @@ | |||
238 | 454 | } | 471 | } |
239 | 455 | } | 472 | } |
240 | 456 | } | 473 | } |
241 | 474 | }, | ||
242 | 475 | State { | ||
243 | 476 | name: "expandedUnderContentNoFlickable" | ||
244 | 477 | AnchorChanges { | ||
245 | 478 | target: styledItem.contentItem | ||
246 | 479 | anchors.bottom: undefined | ||
247 | 480 | } | ||
248 | 481 | PropertyChanges { | ||
249 | 482 | target: styledItem.expansion.contentItem | ||
250 | 483 | opacity: 1.0 | ||
251 | 484 | z: 1 | ||
252 | 485 | } | ||
253 | 486 | PropertyChanges { | ||
254 | 487 | target: styledItem | ||
255 | 488 | height: styledItem.expansion.height | ||
256 | 489 | } | ||
257 | 490 | }, | ||
258 | 491 | State { | ||
259 | 492 | name: "expandedUnderContentWithFlickable" | ||
260 | 493 | AnchorChanges { | ||
261 | 494 | target: styledItem.contentItem | ||
262 | 495 | anchors.bottom: undefined | ||
263 | 496 | } | ||
264 | 497 | PropertyChanges { | ||
265 | 498 | target: styledItem.expansion.contentItem | ||
266 | 499 | opacity: 1.0 | ||
267 | 500 | z: 1 | ||
268 | 501 | } | ||
269 | 502 | PropertyChanges { | ||
270 | 503 | target: styledItem | ||
271 | 504 | height: styledItem.expansion.height | ||
272 | 505 | } | ||
273 | 506 | PropertyChanges { | ||
274 | 507 | target: listItemStyle.flickable | ||
275 | 508 | // we do not need to restore the original values | ||
276 | 509 | restoreEntryValues: false | ||
277 | 510 | // and we should not get any binding updates even | ||
278 | 511 | explicit: true | ||
279 | 512 | contentY: { | ||
280 | 513 | var bottom = styledItem.y + styledItem.expansion.height - listItemStyle.flickable.contentY + listItemStyle.flickable.originY; | ||
281 | 514 | var dy = bottom - listItemStyle.flickable.height; | ||
282 | 515 | if (dy > 0) { | ||
283 | 516 | return listItemStyle.flickable.contentY + dy - listItemStyle.flickable.originY; | ||
284 | 517 | } else { | ||
285 | 518 | return listItemStyle.flickable.contentY; | ||
286 | 519 | } | ||
287 | 520 | } | ||
288 | 521 | } | ||
289 | 522 | }, | ||
290 | 523 | State { | ||
291 | 524 | name: "expandedOverContentNoFlickable" | ||
292 | 525 | PropertyChanges { | ||
293 | 526 | target: styledItem.contentItem | ||
294 | 527 | opacity: 0.0 | ||
295 | 528 | enabled: false | ||
296 | 529 | } | ||
297 | 530 | PropertyChanges { | ||
298 | 531 | target: styledItem.expansion.contentItem | ||
299 | 532 | opacity: 1.0 | ||
300 | 533 | z: 1 | ||
301 | 534 | } | ||
302 | 535 | PropertyChanges { | ||
303 | 536 | target: styledItem | ||
304 | 537 | height: styledItem.expansion.height | ||
305 | 538 | } | ||
306 | 539 | }, | ||
307 | 540 | State { | ||
308 | 541 | name: "expandedOverContentWithFlickable" | ||
309 | 542 | PropertyChanges { | ||
310 | 543 | target: styledItem.contentItem | ||
311 | 544 | opacity: 0.0 | ||
312 | 545 | enabled: false | ||
313 | 546 | } | ||
314 | 547 | PropertyChanges { | ||
315 | 548 | target: styledItem.expansion.contentItem | ||
316 | 549 | opacity: 1.0 | ||
317 | 550 | z: 1 | ||
318 | 551 | } | ||
319 | 552 | PropertyChanges { | ||
320 | 553 | target: styledItem | ||
321 | 554 | height: styledItem.expansion.height | ||
322 | 555 | } | ||
323 | 556 | PropertyChanges { | ||
324 | 557 | target: listItemStyle.flickable | ||
325 | 558 | // we do not need to restore the original values | ||
326 | 559 | restoreEntryValues: false | ||
327 | 560 | // and we should not get any binding updates even | ||
328 | 561 | explicit: true | ||
329 | 562 | contentY: { | ||
330 | 563 | var bottom = styledItem.y + styledItem.expansion.height - listItemStyle.flickable.contentY + listItemStyle.flickable.originY; | ||
331 | 564 | var dy = bottom - listItemStyle.flickable.height; | ||
332 | 565 | if (dy > 0) { | ||
333 | 566 | return listItemStyle.flickable.contentY + dy - listItemStyle.flickable.originY; | ||
334 | 567 | } else { | ||
335 | 568 | return listItemStyle.flickable.contentY; | ||
336 | 569 | } | ||
337 | 570 | } | ||
338 | 571 | } | ||
339 | 457 | } | 572 | } |
340 | 458 | ] | 573 | ] |
341 | 459 | transitions: [ | 574 | transitions: [ |
342 | @@ -462,15 +577,29 @@ | |||
343 | 462 | to: "expandedWithFlickable" | 577 | to: "expandedWithFlickable" |
344 | 463 | reversible: true | 578 | reversible: true |
345 | 464 | enabled: listItemStyle.animatePanels | 579 | enabled: listItemStyle.animatePanels |
355 | 465 | ParallelAnimation { | 580 | UbuntuNumberAnimation { |
356 | 466 | UbuntuNumberAnimation { | 581 | targets: [listItemStyle.flickable, styledItem] |
357 | 467 | target: listItemStyle.flickable | 582 | properties: "contentY, height" |
358 | 468 | property: "contentY" | 583 | } |
359 | 469 | } | 584 | }, |
360 | 470 | UbuntuNumberAnimation { | 585 | Transition { |
361 | 471 | target: styledItem | 586 | from: "" |
362 | 472 | property: "height" | 587 | to: "expandedUnderContentWithFlickable" |
363 | 473 | } | 588 | reversible: true |
364 | 589 | enabled: listItemStyle.animatePanels | ||
365 | 590 | UbuntuNumberAnimation { | ||
366 | 591 | targets: [styledItem.expansion.contentItem, listItemStyle.flickable, styledItem] | ||
367 | 592 | properties: "opacity, contentY, height" | ||
368 | 593 | } | ||
369 | 594 | }, | ||
370 | 595 | Transition { | ||
371 | 596 | from: "" | ||
372 | 597 | to: "expandedOverContentWithFlickable" | ||
373 | 598 | reversible: true | ||
374 | 599 | enabled: listItemStyle.animatePanels | ||
375 | 600 | UbuntuNumberAnimation { | ||
376 | 601 | targets: [styledItem.contentItem, styledItem.expansion.contentItem, listItemStyle.flickable, styledItem] | ||
377 | 602 | properties: "opacity, contentY, height" | ||
378 | 474 | } | 603 | } |
379 | 475 | }, | 604 | }, |
380 | 476 | Transition { | 605 | Transition { |
381 | @@ -482,6 +611,26 @@ | |||
382 | 482 | target: styledItem | 611 | target: styledItem |
383 | 483 | property: "height" | 612 | property: "height" |
384 | 484 | } | 613 | } |
385 | 614 | }, | ||
386 | 615 | Transition { | ||
387 | 616 | from: "" | ||
388 | 617 | to: "expandedUnderContentNoFlickable" | ||
389 | 618 | reversible: true | ||
390 | 619 | enabled: listItemStyle.animatePanels | ||
391 | 620 | UbuntuNumberAnimation { | ||
392 | 621 | targets: [styledItem.expansion.contentItem, styledItem] | ||
393 | 622 | properties: "opacity, height" | ||
394 | 623 | } | ||
395 | 624 | }, | ||
396 | 625 | Transition { | ||
397 | 626 | from: "" | ||
398 | 627 | to: "expandedOverContentNoFlickable" | ||
399 | 628 | reversible: true | ||
400 | 629 | enabled: listItemStyle.animatePanels | ||
401 | 630 | UbuntuNumberAnimation { | ||
402 | 631 | targets: [styledItem.expansion.contentItem, styledItem.contentItem, styledItem] | ||
403 | 632 | properties: "opacity, height" | ||
404 | 633 | } | ||
405 | 485 | } | 634 | } |
406 | 486 | ] | 635 | ] |
407 | 487 | } | 636 | } |
408 | 488 | 637 | ||
409 | === modified file 'src/Ubuntu/Components/plugin/privates/listitemexpansion.cpp' | |||
410 | --- src/Ubuntu/Components/plugin/privates/listitemexpansion.cpp 2015-09-04 09:32:31 +0000 | |||
411 | +++ src/Ubuntu/Components/plugin/privates/listitemexpansion.cpp 2015-09-09 10:37:17 +0000 | |||
412 | @@ -16,15 +16,45 @@ | |||
413 | 16 | 16 | ||
414 | 17 | #include "uclistitem.h" | 17 | #include "uclistitem.h" |
415 | 18 | #include "uclistitem_p.h" | 18 | #include "uclistitem_p.h" |
416 | 19 | #include <QtQuick/private/qquickflickable_p.h> | ||
417 | 19 | 20 | ||
418 | 20 | UCListItemExpansion::UCListItemExpansion(QObject *parent) | 21 | UCListItemExpansion::UCListItemExpansion(QObject *parent) |
419 | 21 | : QObject(parent) | 22 | : QObject(parent) |
420 | 22 | , m_listItem(static_cast<UCListItem13*>(parent)) | 23 | , m_listItem(static_cast<UCListItem13*>(parent)) |
421 | 24 | , m_content(Q_NULLPTR) | ||
422 | 25 | , m_contentItem(Q_NULLPTR) | ||
423 | 23 | , m_height(0.0) | 26 | , m_height(0.0) |
424 | 27 | , m_overlapListItem(false) | ||
425 | 24 | , m_filtering(false) | 28 | , m_filtering(false) |
426 | 25 | { | 29 | { |
427 | 26 | } | 30 | } |
428 | 27 | 31 | ||
429 | 32 | void UCListItemExpansion::createOrUpdateContentItem() | ||
430 | 33 | { | ||
431 | 34 | if (!m_contentItem && m_content && expanded()) { | ||
432 | 35 | m_contentItem = static_cast<QQuickItem*>(m_content->create(qmlContext(m_listItem))); | ||
433 | 36 | m_contentItem->setParentItem(m_listItem); | ||
434 | 37 | m_contentItem->setOpacity(0.0); | ||
435 | 38 | m_listItem->setClip(true); | ||
436 | 39 | // cal update to handle ListItem restrictions | ||
437 | 40 | updateContent(expanded()); | ||
438 | 41 | } | ||
439 | 42 | |||
440 | 43 | // adjust expanded contentItem anchoring | ||
441 | 44 | if (m_contentItem) { | ||
442 | 45 | QQuickAnchors *contentAnchors = QQuickItemPrivate::get(m_contentItem)->anchors(); | ||
443 | 46 | QQuickItemPrivate *contentItem = QQuickItemPrivate::get(m_listItem->contentItem()); | ||
444 | 47 | if (m_overlapListItem) { | ||
445 | 48 | contentAnchors->resetTop(); | ||
446 | 49 | contentAnchors->setFill(m_listItem->contentItem()); | ||
447 | 50 | } else { | ||
448 | 51 | // make sure we remove the fill | ||
449 | 52 | contentAnchors->resetFill(); | ||
450 | 53 | contentAnchors->setTop(contentItem->bottom()); | ||
451 | 54 | } | ||
452 | 55 | } | ||
453 | 56 | } | ||
454 | 57 | |||
455 | 28 | bool UCListItemExpansion::expandedLocked() | 58 | bool UCListItemExpansion::expandedLocked() |
456 | 29 | { | 59 | { |
457 | 30 | UCListItemPrivate *listItem = UCListItemPrivate::get(m_listItem); | 60 | UCListItemPrivate *listItem = UCListItemPrivate::get(m_listItem); |
458 | @@ -45,6 +75,21 @@ | |||
459 | 45 | } | 75 | } |
460 | 46 | } | 76 | } |
461 | 47 | 77 | ||
462 | 78 | // called when ViewItems expands/collapses the content | ||
463 | 79 | void UCListItemExpansion::updateContent(bool expanded) | ||
464 | 80 | { | ||
465 | 81 | if (!m_contentItem) { | ||
466 | 82 | return; | ||
467 | 83 | } | ||
468 | 84 | m_contentItem->setEnabled(expanded); | ||
469 | 85 | // if contentItem is a Flickable, lock ListItem from being highlighted | ||
470 | 86 | if (qobject_cast<QQuickFlickable*>(m_contentItem)) { | ||
471 | 87 | UCListItemPrivate *listItem = UCListItemPrivate::get(m_listItem); | ||
472 | 88 | listItem->blockHighlighting(expanded); | ||
473 | 89 | } | ||
474 | 90 | } | ||
475 | 91 | |||
476 | 92 | |||
477 | 48 | // event filter for external mouse presses to collapse when pressed outside | 93 | // event filter for external mouse presses to collapse when pressed outside |
478 | 49 | bool UCListItemExpansion::eventFilter(QObject *target, QEvent *event) | 94 | bool UCListItemExpansion::eventFilter(QObject *target, QEvent *event) |
479 | 50 | { | 95 | { |
480 | @@ -104,3 +149,30 @@ | |||
481 | 104 | m_height = height; | 149 | m_height = height; |
482 | 105 | Q_EMIT heightChanged(); | 150 | Q_EMIT heightChanged(); |
483 | 106 | } | 151 | } |
484 | 152 | |||
485 | 153 | void UCListItemExpansion::setContent(QQmlComponent *component) | ||
486 | 154 | { | ||
487 | 155 | if (component == m_content) { | ||
488 | 156 | return; | ||
489 | 157 | } | ||
490 | 158 | m_content = component; | ||
491 | 159 | Q_EMIT contentChanged(); | ||
492 | 160 | Q_EMIT contentItemChanged(); | ||
493 | 161 | } | ||
494 | 162 | |||
495 | 163 | QQuickItem *UCListItemExpansion::contentItem() | ||
496 | 164 | { | ||
497 | 165 | createOrUpdateContentItem(); | ||
498 | 166 | return m_contentItem; | ||
499 | 167 | } | ||
500 | 168 | |||
501 | 169 | |||
502 | 170 | void UCListItemExpansion::setOverlapListItem(bool overlap) | ||
503 | 171 | { | ||
504 | 172 | if (m_overlapListItem == overlap) { | ||
505 | 173 | return; | ||
506 | 174 | } | ||
507 | 175 | m_overlapListItem = overlap; | ||
508 | 176 | Q_EMIT overlapListItemChanged(); | ||
509 | 177 | createOrUpdateContentItem(); | ||
510 | 178 | } | ||
511 | 107 | 179 | ||
512 | === modified file 'src/Ubuntu/Components/plugin/uclistitem.cpp' | |||
513 | --- src/Ubuntu/Components/plugin/uclistitem.cpp 2015-09-04 09:32:31 +0000 | |||
514 | +++ src/Ubuntu/Components/plugin/uclistitem.cpp 2015-09-09 10:37:17 +0000 | |||
515 | @@ -186,6 +186,7 @@ | |||
516 | 186 | : UCStyledItemBasePrivate() | 186 | : UCStyledItemBasePrivate() |
517 | 187 | , defaultThemeVersion(0) | 187 | , defaultThemeVersion(0) |
518 | 188 | , highlighted(false) | 188 | , highlighted(false) |
519 | 189 | , highlightBlocked(false) | ||
520 | 189 | , contentMoved(false) | 190 | , contentMoved(false) |
521 | 190 | , swiped(false) | 191 | , swiped(false) |
522 | 191 | , suppressClick(false) | 192 | , suppressClick(false) |
523 | @@ -383,10 +384,21 @@ | |||
524 | 383 | return (isClickedConnected() || isPressAndHoldConnected() || mainAction || leadingActions || trailingActions); | 384 | return (isClickedConnected() || isPressAndHoldConnected() || mainAction || leadingActions || trailingActions); |
525 | 384 | } | 385 | } |
526 | 385 | 386 | ||
527 | 387 | // block the highlight mechanism (and swiping) on the ListItem; called when the ListItem | ||
528 | 388 | // is expanded and the content specified is a Flickable | ||
529 | 389 | void UCListItemPrivate::blockHighlighting(bool block) | ||
530 | 390 | { | ||
531 | 391 | if (block) { | ||
532 | 392 | setHighlighted(false); | ||
533 | 393 | listenToRebind(false); | ||
534 | 394 | } | ||
535 | 395 | highlightBlocked = block; | ||
536 | 396 | } | ||
537 | 397 | |||
538 | 386 | // set highlighted flag and update contentItem | 398 | // set highlighted flag and update contentItem |
539 | 387 | void UCListItemPrivate::setHighlighted(bool highlighted) | 399 | void UCListItemPrivate::setHighlighted(bool highlighted) |
540 | 388 | { | 400 | { |
542 | 389 | if (this->highlighted != highlighted) { | 401 | if (this->highlighted != highlighted && !highlightBlocked) { |
543 | 390 | this->highlighted = highlighted; | 402 | this->highlighted = highlighted; |
544 | 391 | suppressClick = false; | 403 | suppressClick = false; |
545 | 392 | Q_Q(UCListItem); | 404 | Q_Q(UCListItem); |
546 | @@ -1125,6 +1137,9 @@ | |||
547 | 1125 | // swipe events; child items should no longer get mouse events | 1137 | // swipe events; child items should no longer get mouse events |
548 | 1126 | void UCListItemPrivate::grabLeftButtonEvents(QMouseEvent *event) | 1138 | void UCListItemPrivate::grabLeftButtonEvents(QMouseEvent *event) |
549 | 1127 | { | 1139 | { |
550 | 1140 | if (highlightBlocked) { | ||
551 | 1141 | return; | ||
552 | 1142 | } | ||
553 | 1128 | Q_Q(UCListItem); | 1143 | Q_Q(UCListItem); |
554 | 1129 | button = event->button(); | 1144 | button = event->button(); |
555 | 1130 | // create style instance | 1145 | // create style instance |
556 | @@ -1239,7 +1254,7 @@ | |||
557 | 1239 | Q_D(UCListItem); | 1254 | Q_D(UCListItem); |
558 | 1240 | d->ungrabLeftButtonEvents(event); | 1255 | d->ungrabLeftButtonEvents(event); |
559 | 1241 | // make sure we ungrab the mouse! | 1256 | // make sure we ungrab the mouse! |
561 | 1242 | ungrabMouse(); | 1257 | setKeepMouseGrab(false); |
562 | 1243 | } | 1258 | } |
563 | 1244 | 1259 | ||
564 | 1245 | void UCListItem13::mouseReleaseEvent(QMouseEvent *event) | 1260 | void UCListItem13::mouseReleaseEvent(QMouseEvent *event) |
565 | @@ -1323,7 +1338,7 @@ | |||
566 | 1323 | } else if (type == QEvent::MouseMove) { | 1338 | } else if (type == QEvent::MouseMove) { |
567 | 1324 | QMouseEvent *mouse = static_cast<QMouseEvent*>(event); | 1339 | QMouseEvent *mouse = static_cast<QMouseEvent*>(event); |
568 | 1325 | const QPointF localPos = mapFromItem(child, mouse->localPos()); | 1340 | const QPointF localPos = mapFromItem(child, mouse->localPos()); |
570 | 1326 | if ((mouse->buttons() & Qt::LeftButton) && d->swipedOverThreshold(localPos, d->pressedPos) && !d->highlighted) { | 1341 | if ((mouse->buttons() & Qt::LeftButton) && d->swipedOverThreshold(localPos, d->pressedPos) && !d->highlighted && !d->highlightBlocked) { |
571 | 1327 | // grab the event from the child, so the click doesn't happen anymore, and initiate swiping | 1342 | // grab the event from the child, so the click doesn't happen anymore, and initiate swiping |
572 | 1328 | QMouseEvent pressed(QEvent::MouseButtonPress, localPos, mouse->windowPos(), mouse->screenPos(), | 1343 | QMouseEvent pressed(QEvent::MouseButtonPress, localPos, mouse->windowPos(), mouse->screenPos(), |
573 | 1329 | Qt::LeftButton, mouse->buttons(), mouse->modifiers()); | 1344 | Qt::LeftButton, mouse->buttons(), mouse->modifiers()); |
574 | @@ -1331,7 +1346,7 @@ | |||
575 | 1331 | // stop click and pressAndHold, then grab the mouse so children do not get the mouse events anymore | 1346 | // stop click and pressAndHold, then grab the mouse so children do not get the mouse events anymore |
576 | 1332 | d->suppressClick = true; | 1347 | d->suppressClick = true; |
577 | 1333 | d->pressAndHoldTimer.stop(); | 1348 | d->pressAndHoldTimer.stop(); |
579 | 1334 | grabMouse(); | 1349 | setKeepMouseGrab(true); |
580 | 1335 | } | 1350 | } |
581 | 1336 | } | 1351 | } |
582 | 1337 | return UCStyledItemBase::childMouseEventFilter(child, event); | 1352 | return UCStyledItemBase::childMouseEventFilter(child, event); |
583 | @@ -1761,8 +1776,57 @@ | |||
584 | 1761 | * \qmlpropertygroup ::ListItem::expansion | 1776 | * \qmlpropertygroup ::ListItem::expansion |
585 | 1762 | * \qmlproperty bool ListItem::expansion.expanded | 1777 | * \qmlproperty bool ListItem::expansion.expanded |
586 | 1763 | * \qmlproperty real ListItem::expansion.height | 1778 | * \qmlproperty real ListItem::expansion.height |
587 | 1779 | * \qmlproperty Component ListItem::expansion.content | ||
588 | 1780 | * \qmlproperty Item ListItem::expansion.contentItem | ||
589 | 1781 | * \qmlproperty bool ListItem::expansion.overlapListItem | ||
590 | 1764 | * \since Ubuntu.Components 1.3 | 1782 | * \since Ubuntu.Components 1.3 |
592 | 1765 | * The group drefines the expansion state of the ListItem. | 1783 | * The group drefines the expansion state of the ListItem. \c expanded drives |
593 | 1784 | * the expansion of the ListItem, \c height specifies the height of the expanded | ||
594 | 1785 | * ListItem. By default the ListItem's content is expanded together with the | ||
595 | 1786 | * ListItem. There may be use cases where the expanded content may have slightly | ||
596 | 1787 | * different content. This can be achieved by specifying a component in \c content | ||
597 | 1788 | * property. When content is specified, it will be anchored to the bottom of the | ||
598 | 1789 | * \l ListItem::contentItem, which in turn will not resize together with the | ||
599 | 1790 | * ListItem. Setting \c overlapListItem will hide the \l ListItem::contentItem | ||
600 | 1791 | * and will fill the entire ListItem with the \c content. Setting \c overlapListItem | ||
601 | 1792 | * without a valid \c content component will have no effect. | ||
602 | 1793 | * /note Setting \e ViewItems.UnlockExpanded flag to a view of ListItems where the | ||
603 | 1794 | * expanded content is a Flickable derivate will have no effect. | ||
604 | 1795 | * Example: | ||
605 | 1796 | * \qml | ||
606 | 1797 | * import QtQuick 2.4 | ||
607 | 1798 | * import Ubuntu.Components 1.3 | ||
608 | 1799 | * | ||
609 | 1800 | * UbuntuListView { | ||
610 | 1801 | * width: units.gu(40) | ||
611 | 1802 | * height: units.gu(71) | ||
612 | 1803 | * ViewItems.expansionFlags: ViewItems.CollapseOnOutsidePress | ||
613 | 1804 | * | ||
614 | 1805 | * model: 50 | ||
615 | 1806 | * delegate: ListItem { | ||
616 | 1807 | * id: listItem | ||
617 | 1808 | * contentItem.anchors.margins: units.gu(1.5) | ||
618 | 1809 | * Label { text: "List Item #" + modelData } | ||
619 | 1810 | * onPressAndHold: expansion.expanded = true | ||
620 | 1811 | * expansion { | ||
621 | 1812 | * height: units.gu(21) | ||
622 | 1813 | * overlapListItem: true | ||
623 | 1814 | * content: UbuntuListView { | ||
624 | 1815 | * anchors { | ||
625 | 1816 | * leftMargin: units.gu(2) | ||
626 | 1817 | * rightMargin: units.gu(2) | ||
627 | 1818 | * } | ||
628 | 1819 | * model: 5 | ||
629 | 1820 | * delegate: ListItem { | ||
630 | 1821 | * contentItem.anchors.margins: units.gu(1.5) | ||
631 | 1822 | * Label { text: "Expanded item # + modelData } | ||
632 | 1823 | * onClicked: listItem.expansion.expanded = false | ||
633 | 1824 | * } | ||
634 | 1825 | * } | ||
635 | 1826 | * } | ||
636 | 1827 | * } | ||
637 | 1828 | * } | ||
638 | 1829 | * \endqml | ||
639 | 1766 | */ | 1830 | */ |
640 | 1767 | UCListItemExpansion *UCListItem13::expansion() | 1831 | UCListItemExpansion *UCListItem13::expansion() |
641 | 1768 | { | 1832 | { |
642 | 1769 | 1833 | ||
643 | === modified file 'src/Ubuntu/Components/plugin/uclistitem.h' | |||
644 | --- src/Ubuntu/Components/plugin/uclistitem.h 2015-09-04 09:32:31 +0000 | |||
645 | +++ src/Ubuntu/Components/plugin/uclistitem.h 2015-09-09 10:37:17 +0000 | |||
646 | @@ -241,26 +241,40 @@ | |||
647 | 241 | Q_OBJECT | 241 | Q_OBJECT |
648 | 242 | Q_PROPERTY(bool expanded READ expanded WRITE setExpanded NOTIFY expandedChanged) | 242 | Q_PROPERTY(bool expanded READ expanded WRITE setExpanded NOTIFY expandedChanged) |
649 | 243 | Q_PROPERTY(qreal height MEMBER m_height WRITE setHeight NOTIFY heightChanged) | 243 | Q_PROPERTY(qreal height MEMBER m_height WRITE setHeight NOTIFY heightChanged) |
650 | 244 | Q_PROPERTY(QQmlComponent *content MEMBER m_content WRITE setContent NOTIFY contentChanged) | ||
651 | 245 | Q_PROPERTY(QQuickItem *contentItem READ contentItem NOTIFY contentItemChanged) | ||
652 | 246 | Q_PROPERTY(bool overlapListItem MEMBER m_overlapListItem WRITE setOverlapListItem NOTIFY overlapListItemChanged) | ||
653 | 244 | public: | 247 | public: |
654 | 245 | explicit UCListItemExpansion(QObject *parent = 0); | 248 | explicit UCListItemExpansion(QObject *parent = 0); |
655 | 246 | 249 | ||
656 | 247 | bool expandedLocked(); | 250 | bool expandedLocked(); |
657 | 248 | void enableClickFiltering(bool enable); | 251 | void enableClickFiltering(bool enable); |
658 | 252 | void updateContent(bool expanded); | ||
659 | 249 | 253 | ||
660 | 250 | bool expanded(); | 254 | bool expanded(); |
661 | 251 | void setExpanded(bool expanded); | 255 | void setExpanded(bool expanded); |
662 | 252 | void setHeight(qreal height); | 256 | void setHeight(qreal height); |
663 | 257 | void setContent(QQmlComponent *component); | ||
664 | 258 | QQuickItem *contentItem(); | ||
665 | 259 | void setOverlapListItem(bool overlap); | ||
666 | 253 | 260 | ||
667 | 254 | Q_SIGNALS: | 261 | Q_SIGNALS: |
668 | 255 | void expandedChanged(); | 262 | void expandedChanged(); |
669 | 256 | void heightChanged(); | 263 | void heightChanged(); |
670 | 264 | void contentChanged(); | ||
671 | 265 | void contentItemChanged(); | ||
672 | 266 | void overlapListItemChanged(); | ||
673 | 257 | 267 | ||
674 | 258 | protected: | 268 | protected: |
675 | 259 | bool eventFilter(QObject *, QEvent *); | 269 | bool eventFilter(QObject *, QEvent *); |
676 | 270 | void createOrUpdateContentItem(); | ||
677 | 260 | 271 | ||
678 | 261 | private: | 272 | private: |
679 | 262 | UCListItem13 *m_listItem; | 273 | UCListItem13 *m_listItem; |
680 | 274 | QQmlComponent *m_content; | ||
681 | 275 | QQuickItem *m_contentItem; | ||
682 | 263 | qreal m_height; | 276 | qreal m_height; |
683 | 277 | bool m_overlapListItem:1; | ||
684 | 264 | bool m_filtering:1; | 278 | bool m_filtering:1; |
685 | 265 | 279 | ||
686 | 266 | friend class UCListItem; | 280 | friend class UCListItem; |
687 | 267 | 281 | ||
688 | === modified file 'src/Ubuntu/Components/plugin/uclistitem_p.h' | |||
689 | --- src/Ubuntu/Components/plugin/uclistitem_p.h 2015-09-01 07:16:59 +0000 | |||
690 | +++ src/Ubuntu/Components/plugin/uclistitem_p.h 2015-09-09 10:37:17 +0000 | |||
691 | @@ -61,6 +61,7 @@ | |||
692 | 61 | void _q_syncDragMode(); | 61 | void _q_syncDragMode(); |
693 | 62 | int index(); | 62 | int index(); |
694 | 63 | bool canHighlight(); | 63 | bool canHighlight(); |
695 | 64 | void blockHighlighting(bool block); | ||
696 | 64 | void setHighlighted(bool pressed); | 65 | void setHighlighted(bool pressed); |
697 | 65 | void listenToRebind(bool listen); | 66 | void listenToRebind(bool listen); |
698 | 66 | void lockContentItem(bool lock); | 67 | void lockContentItem(bool lock); |
699 | @@ -73,6 +74,7 @@ | |||
700 | 73 | 74 | ||
701 | 74 | quint16 defaultThemeVersion; | 75 | quint16 defaultThemeVersion; |
702 | 75 | bool highlighted:1; | 76 | bool highlighted:1; |
703 | 77 | bool highlightBlocked:1; | ||
704 | 76 | bool contentMoved:1; | 78 | bool contentMoved:1; |
705 | 77 | bool swiped:1; | 79 | bool swiped:1; |
706 | 78 | bool suppressClick:1; | 80 | bool suppressClick:1; |
707 | 79 | 81 | ||
708 | === modified file 'src/Ubuntu/Components/plugin/ucviewitemsattached.cpp' | |||
709 | --- src/Ubuntu/Components/plugin/ucviewitemsattached.cpp 2015-09-04 08:55:29 +0000 | |||
710 | +++ src/Ubuntu/Components/plugin/ucviewitemsattached.cpp 2015-09-09 10:37:17 +0000 | |||
711 | @@ -666,6 +666,9 @@ | |||
712 | 666 | if (listItem && ((expansionFlags & UCViewItemsAttached::CollapseOnOutsidePress) == UCViewItemsAttached::CollapseOnOutsidePress)) { | 666 | if (listItem && ((expansionFlags & UCViewItemsAttached::CollapseOnOutsidePress) == UCViewItemsAttached::CollapseOnOutsidePress)) { |
713 | 667 | listItem->expansion()->enableClickFiltering(true); | 667 | listItem->expansion()->enableClickFiltering(true); |
714 | 668 | } | 668 | } |
715 | 669 | if (listItem) { | ||
716 | 670 | listItem->expansion()->updateContent(true); | ||
717 | 671 | } | ||
718 | 669 | if (emitChangeSignal) { | 672 | if (emitChangeSignal) { |
719 | 670 | Q_EMIT static_cast<UCViewItemsAttached13*>(q_func())->expandedIndicesChanged(expansionList.keys()); | 673 | Q_EMIT static_cast<UCViewItemsAttached13*>(q_func())->expandedIndicesChanged(expansionList.keys()); |
720 | 671 | } | 674 | } |
721 | @@ -679,6 +682,9 @@ | |||
722 | 679 | if (item && ((expansionFlags & UCViewItemsAttached::CollapseOnOutsidePress) == UCViewItemsAttached::CollapseOnOutsidePress)) { | 682 | if (item && ((expansionFlags & UCViewItemsAttached::CollapseOnOutsidePress) == UCViewItemsAttached::CollapseOnOutsidePress)) { |
723 | 680 | item->expansion()->enableClickFiltering(false); | 683 | item->expansion()->enableClickFiltering(false); |
724 | 681 | } | 684 | } |
725 | 685 | if (item) { | ||
726 | 686 | item->expansion()->updateContent(false); | ||
727 | 687 | } | ||
728 | 682 | if (emitChangeSignal && wasExpanded) { | 688 | if (emitChangeSignal && wasExpanded) { |
729 | 683 | Q_EMIT static_cast<UCViewItemsAttached13*>(q_func())->expandedIndicesChanged(expansionList.keys()); | 689 | Q_EMIT static_cast<UCViewItemsAttached13*>(q_func())->expandedIndicesChanged(expansionList.keys()); |
730 | 684 | } | 690 | } |
731 | @@ -708,7 +714,8 @@ | |||
732 | 708 | * \li When set, only one ListItem can be expanded at a time. \b {Set by default}. | 714 | * \li When set, only one ListItem can be expanded at a time. \b {Set by default}. |
733 | 709 | * \row | 715 | * \row |
734 | 710 | * \li ViewItems.UnlockExpanded | 716 | * \li ViewItems.UnlockExpanded |
736 | 711 | * \li When set, the ListItem's leading/trailing actions can be swiped in. | 717 | * \li When set, the ListItem's leading/trailing actions can be swiped in. The |
737 | 718 | * flag has no effect when the expanded content is a Flickable. | ||
738 | 712 | * \row | 719 | * \row |
739 | 713 | * \li ViewItems.CollapseOnOutsidePress | 720 | * \li ViewItems.CollapseOnOutsidePress |
740 | 714 | * \li When set, the active expaned ListItem collapses automatically when clicked | 721 | * \li When set, the active expaned ListItem collapses automatically when clicked |
741 | 715 | 722 | ||
742 | === modified file 'tests/resources/listitems/ListItemExpansion.qml' | |||
743 | --- tests/resources/listitems/ListItemExpansion.qml 2015-09-02 06:47:25 +0000 | |||
744 | +++ tests/resources/listitems/ListItemExpansion.qml 2015-09-09 10:37:17 +0000 | |||
745 | @@ -38,6 +38,7 @@ | |||
746 | 38 | iconName: "stock_website" | 38 | iconName: "stock_website" |
747 | 39 | } | 39 | } |
748 | 40 | ] | 40 | ] |
749 | 41 | |||
750 | 41 | Page { | 42 | Page { |
751 | 42 | title: "Expansion" | 43 | title: "Expansion" |
752 | 43 | Column { | 44 | Column { |
753 | @@ -50,18 +51,12 @@ | |||
754 | 50 | height: parent.height / 2 | 51 | height: parent.height / 2 |
755 | 51 | clip: true | 52 | clip: true |
756 | 52 | ViewItems.onExpandedIndicesChanged: print(ViewItems.expandedIndices) | 53 | ViewItems.onExpandedIndicesChanged: print(ViewItems.expandedIndices) |
758 | 53 | ViewItems.expansionFlags: ViewItems.CollapseOnOutsidePress | 54 | ViewItems.expansionFlags: ViewItems.CollapseOnOutsidePress | ViewItems.UnlockExpanded |
759 | 54 | 55 | ||
760 | 55 | model: ListModel { | 56 | model: ListModel { |
761 | 56 | Component.onCompleted: { | 57 | Component.onCompleted: { |
770 | 57 | for (var i = 0; i < 3; i++) { | 58 | for (var i = 0; i < 25; i++) { |
771 | 58 | append({label: "List item #"+i, sectionData: "Locked"}); | 59 | append({label: "List item #"+i}); |
764 | 59 | } | ||
765 | 60 | for (i = 3; i < 11; i++) { | ||
766 | 61 | append({label: "List item #"+i, sectionData: "Limited, live move"}); | ||
767 | 62 | } | ||
768 | 63 | for (i = 11; i < 25; i++) { | ||
769 | 64 | append({label: "List item #"+i, sectionData: "Unlimited, drag'n'drop"}); | ||
772 | 65 | } | 60 | } |
773 | 66 | } | 61 | } |
774 | 67 | } | 62 | } |
775 | @@ -75,7 +70,20 @@ | |||
776 | 75 | trailingActions: ListItemActions { | 70 | trailingActions: ListItemActions { |
777 | 76 | actions: contextualActions | 71 | actions: contextualActions |
778 | 77 | } | 72 | } |
780 | 78 | expansion.height: units.gu(15) | 73 | expansion { |
781 | 74 | height: units.gu(15) | ||
782 | 75 | overlapListItem: true | ||
783 | 76 | content: UbuntuListView { | ||
784 | 77 | model: 5 | ||
785 | 78 | delegate: ListItem { | ||
786 | 79 | contentItem.anchors.margins: units.gu(1) | ||
787 | 80 | Label { text: i18n.tr("Sub-item #%1").arg(modelData) } | ||
788 | 81 | onClicked: { | ||
789 | 82 | item.expansion.expanded = false; | ||
790 | 83 | } | ||
791 | 84 | } | ||
792 | 85 | } | ||
793 | 86 | } | ||
794 | 79 | 87 | ||
795 | 80 | RowLayout { | 88 | RowLayout { |
796 | 81 | anchors { | 89 | anchors { |
797 | @@ -89,10 +97,6 @@ | |||
798 | 89 | title.text: label | 97 | title.text: label |
799 | 90 | subtitle.text: "from index #" + index | 98 | subtitle.text: "from index #" + index |
800 | 91 | } | 99 | } |
801 | 92 | Button { | ||
802 | 93 | text: "Enable drag mode" | ||
803 | 94 | onClicked: listView.ViewItems.dragMode = true | ||
804 | 95 | } | ||
805 | 96 | } | 100 | } |
806 | 97 | 101 | ||
807 | 98 | onPressAndHold: { | 102 | onPressAndHold: { |
808 | @@ -103,12 +107,23 @@ | |||
809 | 103 | } | 107 | } |
810 | 104 | ListItem { | 108 | ListItem { |
811 | 105 | Label { text: "Standalone ListItem" } | 109 | Label { text: "Standalone ListItem" } |
813 | 106 | expansion.height: units.gu(15) | 110 | expansion { |
814 | 111 | height: units.gu(15) | ||
815 | 112 | content: Rectangle { | ||
816 | 113 | color: UbuntuColors.darkGrey | ||
817 | 114 | width: parent.width | ||
818 | 115 | height: units.gu(8) | ||
819 | 116 | radius: units.gu(1) | ||
820 | 117 | } | ||
821 | 118 | } | ||
822 | 107 | onPressAndHold: expansion.expanded = !expansion.expanded; | 119 | onPressAndHold: expansion.expanded = !expansion.expanded; |
823 | 108 | } | 120 | } |
824 | 109 | ListItem { | 121 | ListItem { |
825 | 110 | Label { text: "Other Standalone ListItem" } | 122 | Label { text: "Other Standalone ListItem" } |
827 | 111 | expansion.height: units.gu(15) | 123 | expansion { |
828 | 124 | height: units.gu(15) | ||
829 | 125 | overlapListItem: true | ||
830 | 126 | } | ||
831 | 112 | onPressAndHold: expansion.expanded = !expansion.expanded; | 127 | onPressAndHold: expansion.expanded = !expansion.expanded; |
832 | 113 | } | 128 | } |
833 | 114 | 129 |