Changeset View
Changeset View
Standalone View
Standalone View
src/controls/templates/SwipeListItem.qml
Show First 20 Lines • Show All 219 Lines • ▼ Show 20 Line(s) | 59 | //BEGIN properties | |||
---|---|---|---|---|---|
220 | } | 220 | } | ||
221 | 221 | | |||
222 | implicitWidth: parent ? parent.width : contentItem.width + paddingItem.anchors.margins * 2 | 222 | implicitWidth: parent ? parent.width : contentItem.width + paddingItem.anchors.margins * 2 | ||
223 | implicitHeight: contentItem.height + Units.smallSpacing * 5 | 223 | implicitHeight: contentItem.height + Units.smallSpacing * 5 | ||
224 | //END properties | 224 | //END properties | ||
225 | 225 | | |||
226 | //BEGIN signal handlers | 226 | //BEGIN signal handlers | ||
227 | onBackgroundChanged: { | 227 | onBackgroundChanged: { | ||
228 | if (background) { | ||||
228 | background.parent = itemMouse; | 229 | background.parent = itemMouse; | ||
229 | background.anchors.fill = itemMouse; | 230 | background.anchors.fill = itemMouse; | ||
230 | background.z = 0; | 231 | background.z = -1; | ||
232 | } | ||||
231 | } | 233 | } | ||
232 | 234 | | |||
233 | onContentItemChanged: { | 235 | onContentItemChanged: { | ||
234 | contentItem.parent = paddingItem | 236 | contentItem.parent = paddingItem | ||
235 | contentItem.z = 0; | 237 | contentItem.z = 1; | ||
236 | } | 238 | } | ||
237 | 239 | | |||
238 | Component.onCompleted: { | 240 | Component.onCompleted: { | ||
239 | 241 | backgroundChanged(); | |||
240 | if (background) { | 242 | contentItemChanged(); | ||
241 | background.parent = itemMouse; | | |||
242 | background.z = 0; | | |||
243 | } | | |||
244 | | ||||
245 | contentItem.parent = itemMouse | | |||
246 | contentItem.z = 1; | | |||
247 | } | 243 | } | ||
248 | 244 | | |||
249 | onPositionChanged: { | 245 | onPositionChanged: { | ||
250 | if (!mainFlickable.loopCheck && !handleMouse.pressed && !mainFlickable.flicking && | 246 | if (!mainFlickable.loopCheck && !handleMouse.pressed && !mainFlickable.flicking && | ||
251 | !mainFlickable.dragging && !positionAnimation.running) { | 247 | !mainFlickable.dragging && !positionAnimation.running) { | ||
252 | mainFlickable.contentX = (listItem.width-listItem.height) * mainFlickable.internalPosition; | 248 | mainFlickable.contentX = (listItem.width-listItem.height) * mainFlickable.internalPosition; | ||
253 | } | 249 | } | ||
254 | } | 250 | } | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 334 | if (!loopCheck) { | |||
339 | loopCheck = true; | 335 | loopCheck = true; | ||
340 | listItem.position = internalPosition; | 336 | listItem.position = internalPosition; | ||
341 | loopCheck = false; | 337 | loopCheck = false; | ||
342 | } | 338 | } | ||
343 | } | 339 | } | ||
344 | 340 | | |||
345 | Item { | 341 | Item { | ||
346 | id: mainItem | 342 | id: mainItem | ||
347 | width: (mainFlickable.width * 2) - height | 343 | width: (mainFlickable.width * 2) - handleMouse.width | ||
348 | height: mainFlickable.height | 344 | height: mainFlickable.height | ||
349 | MouseArea { | 345 | MouseArea { | ||
350 | id: itemMouse | 346 | id: itemMouse | ||
351 | anchors { | 347 | anchors { | ||
352 | left: parent.left | 348 | left: parent.left | ||
353 | top: parent.top | 349 | top: parent.top | ||
354 | bottom: parent.bottom | 350 | bottom: parent.bottom | ||
355 | } | 351 | } | ||
356 | hoverEnabled: !Settings.isMobile | 352 | hoverEnabled: !Settings.isMobile | ||
357 | width: mainFlickable.width | 353 | width: mainFlickable.width | ||
358 | onClicked: listItem.clicked() | 354 | onClicked: listItem.clicked() | ||
359 | onPressAndHold: listItem.pressAndHold() | 355 | onPressAndHold: listItem.pressAndHold() | ||
360 | 356 | | |||
361 | Item { | 357 | Item { | ||
362 | id: paddingItem | 358 | id: paddingItem | ||
363 | anchors { | 359 | anchors { | ||
364 | fill: parent | 360 | fill: parent | ||
365 | margins: Units.smallSpacing | 361 | margins: Units.smallSpacing | ||
362 | rightMargin: handleIcon.width + Units.smallSpacing | ||||
mart: what's the rationale for this? | |||||
apol: Good point, fixed. | |||||
366 | } | 363 | } | ||
367 | } | 364 | } | ||
368 | } | 365 | } | ||
369 | 366 | | |||
370 | MouseArea { | 367 | MouseArea { | ||
371 | id: handleMouse | 368 | id: handleMouse | ||
372 | anchors { | 369 | anchors { | ||
373 | left: itemMouse.right | 370 | left: itemMouse.right | ||
371 | right: itemMouse.right | ||||
374 | top: parent.top | 372 | top: parent.top | ||
375 | bottom: parent.bottom | 373 | bottom: parent.bottom | ||
376 | leftMargin: -height | 374 | leftMargin: -height | ||
377 | } | 375 | } | ||
378 | preventStealing: true | 376 | preventStealing: true | ||
379 | width: mainFlickable.width - actionsLayout.width - actionsLayout.anchors.rightMargin | | |||
380 | property var downTimestamp; | 377 | property var downTimestamp; | ||
381 | property int startX | 378 | property int startX | ||
382 | property int startMouseX | 379 | property int startMouseX | ||
383 | 380 | | |||
384 | onClicked: { | 381 | onClicked: { | ||
385 | if (Math.abs(startX - mainFlickable.contentX) > Units.gridUnit || | 382 | if (Math.abs(startX - mainFlickable.contentX) > Units.gridUnit || | ||
386 | Math.abs(startMouseX - mouse.x) > Units.gridUnit) { | 383 | Math.abs(startMouseX - mouse.x) > Units.gridUnit) { | ||
387 | return; | 384 | return; | ||
Show All 14 Lines | 398 | onPositionChanged: { | |||
402 | mainFlickable.contentX = Math.max(0, Math.min(mainFlickable.width - height, mainFlickable.contentX + (startMouseX - mouse.x))) | 399 | mainFlickable.contentX = Math.max(0, Math.min(mainFlickable.width - height, mainFlickable.contentX + (startMouseX - mouse.x))) | ||
403 | } | 400 | } | ||
404 | onReleased: { | 401 | onReleased: { | ||
405 | var speed = ((startX - mainFlickable.contentX) / ((new Date()).getTime() - downTimestamp) * 1000); | 402 | var speed = ((startX - mainFlickable.contentX) / ((new Date()).getTime() - downTimestamp) * 1000); | ||
406 | mainFlickable.flick(speed, 0); | 403 | mainFlickable.flick(speed, 0); | ||
407 | } | 404 | } | ||
408 | Icon { | 405 | Icon { | ||
409 | id: handleIcon | 406 | id: handleIcon | ||
410 | anchors.verticalCenter: parent.verticalCenter | 407 | anchors.centerIn: parent | ||
411 | selected: listItem.checked || (listItem.pressed && !listItem.checked && !listItem.sectionDelegate) | 408 | selected: listItem.checked || (listItem.pressed && !listItem.checked && !listItem.sectionDelegate) | ||
412 | width: Units.iconSizes.smallMedium | 409 | width: Units.iconSizes.smallMedium | ||
413 | height: width | 410 | height: width | ||
414 | x: y | | |||
415 | source: (mainFlickable.contentX > mainFlickable.width / 2) ? "handle-right" : "handle-left" | 411 | source: (mainFlickable.contentX > mainFlickable.width / 2) ? "handle-right" : "handle-left" | ||
416 | } | 412 | } | ||
417 | } | 413 | } | ||
418 | } | 414 | } | ||
419 | } | 415 | } | ||
420 | //END UI implementation | 416 | //END UI implementation | ||
421 | 417 | | |||
422 | Accessible.role: Accessible.ListItem | 418 | Accessible.role: Accessible.ListItem | ||
423 | } | 419 | } |
what's the rationale for this?