Changeset View
Changeset View
Standalone View
Standalone View
src/controls/templates/SwipeListItem.qml
Show First 20 Lines • Show All 143 Lines • ▼ Show 20 Line(s) | 143 | //END properties | |||
---|---|---|---|---|---|
144 | 144 | | |||
145 | Item { | 145 | Item { | ||
146 | id: behindItem | 146 | id: behindItem | ||
147 | parent: listItem | 147 | parent: listItem | ||
148 | z: -1 | 148 | z: -1 | ||
149 | //TODO: a global "open" state | 149 | //TODO: a global "open" state | ||
150 | enabled: background.x !== 0 | 150 | enabled: background.x !== 0 | ||
151 | property bool indicateActiveFocus: listItem.pressed || Settings.tabletMode || listItem.activeFocus || (view ? view.activeFocus : false) | 151 | property bool indicateActiveFocus: listItem.pressed || Settings.tabletMode || listItem.activeFocus || (view ? view.activeFocus : false) | ||
152 | property Flickable view: listItem.ListView.view || listItem.parent.ListView.view | 152 | property Flickable view: listItem.ListView.view || (listItem.parent ? (listItem.parent.ListView.view || listItem.parent) : null) | ||
153 | onViewChanged: { | ||||
154 | if (view && Settings.tabletMode && !behindItem.view.parent.parent._swipeFilter) { | ||||
155 | var component = Qt.createComponent(Qt.resolvedUrl("../private/SwipeItemEventFilter.qml")); | ||||
156 | behindItem.view.parent.parent._swipeFilter = component.createObject(behindItem.view.parent.parent); | ||||
157 | print("SSS"+behindItem.view.parent.parent._swipeFilter+internal.swipeFilterItem+" "+(behindItem.view && behindItem.view.parent && behindItem.view.parent.parent)) | ||||
158 | } | ||||
159 | } | ||||
160 | | ||||
153 | anchors { | 161 | anchors { | ||
154 | fill: parent | 162 | fill: parent | ||
155 | } | 163 | } | ||
156 | Rectangle { | 164 | Rectangle { | ||
157 | id: shadowHolder | 165 | id: shadowHolder | ||
158 | color: Qt.darker(Theme.backgroundColor, 1.05); | 166 | color: Qt.darker(Theme.backgroundColor, 1.05); | ||
159 | anchors.fill: parent | 167 | anchors.fill: parent | ||
160 | } | 168 | } | ||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Line(s) | 335 | onContentItemChanged: { | |||
334 | contentItem.anchors.right = background.right; | 342 | contentItem.anchors.right = background.right; | ||
335 | contentItem.anchors.leftMargin = Qt.binding(function() {return listItem.leftPadding}); | 343 | contentItem.anchors.leftMargin = Qt.binding(function() {return listItem.leftPadding}); | ||
336 | contentItem.anchors.rightMargin = Qt.binding(function() {return listItem.rightPadding}); | 344 | contentItem.anchors.rightMargin = Qt.binding(function() {return listItem.rightPadding}); | ||
337 | contentItem.anchors.topMargin = Qt.binding(function() {return listItem.topPadding}); | 345 | contentItem.anchors.topMargin = Qt.binding(function() {return listItem.topPadding}); | ||
338 | contentItem.z = 0; | 346 | contentItem.z = 0; | ||
339 | } | 347 | } | ||
340 | Component.onCompleted: { | 348 | Component.onCompleted: { | ||
341 | //this will happen only once | 349 | //this will happen only once | ||
342 | if (Settings.tabletMode && !swipeFilterConnection.swipeFilterItem) { | | |||
343 | var component = Qt.createComponent(Qt.resolvedUrl("../private/SwipeItemEventFilter.qml")); | | |||
344 | behindItem.view.parent.parent._swipeFilter = component.createObject(behindItem.view.parent.parent); | | |||
345 | } | | |||
346 | listItem.contentItemChanged(); | 350 | listItem.contentItemChanged(); | ||
347 | } | 351 | } | ||
348 | Connections { | 352 | Connections { | ||
349 | target: Settings | 353 | target: Settings | ||
350 | onTabletModeChanged: { | 354 | onTabletModeChanged: { | ||
351 | if (Settings.tabletMode) { | 355 | if (Settings.tabletMode) { | ||
352 | if (!swipeFilterConnection.swipeFilterItem) { | 356 | if (!internal.swipeFilterItem) { | ||
353 | var component = Qt.createComponent(Qt.resolvedUrl("../private/SwipeItemEventFilter.qml")); | 357 | var component = Qt.createComponent(Qt.resolvedUrl("../private/SwipeItemEventFilter.qml")); | ||
354 | listItem.ListView.view.parent.parent._swipeFilter = component.createObject(listItem.ListView.view.parent.parent); | 358 | listItem.ListView.view.parent.parent._swipeFilter = component.createObject(listItem.ListView.view.parent.parent); | ||
355 | } | 359 | } | ||
356 | } else { | 360 | } else { | ||
357 | if (listItem.ListView.view.parent.parent._swipeFilter) { | 361 | if (listItem.ListView.view.parent.parent._swipeFilter) { | ||
358 | listItem.ListView.view.parent.parent._swipeFilter.destroy(); | 362 | listItem.ListView.view.parent.parent._swipeFilter.destroy(); | ||
359 | positionAnimation.to = 0; | 363 | positionAnimation.to = 0; | ||
360 | positionAnimation.from = background.x; | 364 | positionAnimation.from = background.x; | ||
361 | positionAnimation.running = true; | 365 | positionAnimation.running = true; | ||
362 | } | 366 | } | ||
363 | } | 367 | } | ||
364 | } | 368 | } | ||
365 | } | 369 | } | ||
370 | QtObject { | ||||
371 | id: internal | ||||
372 | readonly property QtObject swipeFilterItem: (behindItem.view && behindItem.view.parent && behindItem.view.parent.parent) ? behindItem.view.parent.parent._swipeFilter : null | ||||
373 | | ||||
374 | readonly property bool edgeEnabled: swipeFilterItem ? swipeFilterItem.currentItem === listItem || swipeFilterItem.currentItem === listItem.parent : false | ||||
375 | } | ||||
376 | | ||||
366 | Connections { | 377 | Connections { | ||
367 | id: swipeFilterConnection | 378 | id: swipeFilterConnection | ||
368 | readonly property QtObject swipeFilterItem: (behindItem.view && behindItem.view && behindItem.view.parent && behindItem.view.parent.parent) ? behindItem.view.parent.parent._swipeFilter : null | 379 | | ||
369 | readonly property bool enabled: swipeFilterItem ? swipeFilterItem.currentItem === listItem : false | 380 | target: internal.edgeEnabled ? internal.swipeFilterItem : null | ||
370 | target: enabled ? swipeFilterItem : null | 381 | onPeekChanged: listItem.background.x = -(listItem.background.width - listItem.background.height) * internal.swipeFilterItem.peek | ||
371 | onPeekChanged: listItem.background.x = -(listItem.background.width - listItem.background.height) * swipeFilterItem.peek | | |||
372 | onCurrentItemChanged: { | 382 | onCurrentItemChanged: { | ||
373 | if (!enabled) { | 383 | if (!internal.edgeEnabled) { | ||
374 | positionAnimation.to = 0; | 384 | positionAnimation.to = 0; | ||
375 | positionAnimation.from = background.x; | 385 | positionAnimation.from = background.x; | ||
376 | positionAnimation.running = true; | 386 | positionAnimation.running = true; | ||
377 | } | 387 | } | ||
378 | } | 388 | } | ||
379 | } | 389 | } | ||
390 | | ||||
380 | //END signal handlers | 391 | //END signal handlers | ||
381 | 392 | | |||
382 | Accessible.role: Accessible.ListItem | 393 | Accessible.role: Accessible.ListItem | ||
383 | } | 394 | } |