import QtQuick 2.9
import QtQuick.Controls 2.3
import QtGraphicalEffects 1.0
ApplicationWindow {
id: window
width: 800
height: 600
visible: true
ListView {
id: listView
anchors.fill: parent
ButtonGroup {
buttons: listView.contentItem.children
}
delegate: SwipeDelegate {
id: delegate
checkable: true
text: modelData
width: parent.width
checked: swipe.complete
onCheckedChanged: if (!checked) swipe.close()
ListView.onRemove: SequentialAnimation {
PropertyAction {
target: delegate
property: "ListView.delayRemove"
value: true
}
NumberAnimation {
target: delegate
property: "height"
to: 0
easing.type: Easing.InOutQuad
}
PropertyAction {
target: delegate
property: "ListView.delayRemove"
value: false
}
}
swipe.right: Label {
id: deleteLabel
text: qsTr("Delete")
color: "white"
verticalAlignment: Label.AlignVCenter
padding: 12
height: parent.height
anchors.right: parent.right
SwipeDelegate.onClicked: listView.model.remove(index)
background: Rectangle {
color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
}
}
}
model: ListModel {
id: listModel
ListElement { text: "Lorem ipsum dolor sit amet" }
ListElement { text: "Curabitur sit amet risus" }
ListElement { text: "Suspendisse vehicula nisi" }
ListElement { text: "Mauris imperdiet libero" }
ListElement { text: "Sed vitae dui aliquet augue" }
ListElement { text: "Praesent in elit eu nulla" }
ListElement { text: "Etiam vitae magna" }
ListElement { text: "Pellentesque eget elit euismod" }
ListElement { text: "Nulla at enim porta" }
ListElement { text: "Fusce tincidunt odio" }
ListElement { text: "Ut non ex a ligula molestie" }
ListElement { text: "Nam vitae justo scelerisque" }
ListElement { text: "Vestibulum pulvinar tellus" }
ListElement { text: "Quisque dignissim leo sed gravida" }
}
ScrollIndicator.vertical: ScrollIndicator { }
}
}