diff options
Diffstat (limited to 'src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate.qml')
-rw-r--r-- | src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate.qml | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate.qml index db077057..46b2809f 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate.qml @@ -25,39 +25,56 @@ ** ****************************************************************************/ -import QtQuick 2.7 -import QtQuick.Controls 2.0 +import QtQuick 2.8 +import QtQuick.Controls 2.1 //! [1] ListView { - width: 200 - height: 300 - clip: true + id: listView + anchors.fill: parent model: ListModel { - id: listModel - ListElement { title: "Electricity bill" } - ListElement { title: "Happy Birthday!" } - ListElement { title: "FW: Cat pictures" } - ListElement { title: "Hotel visit receipt" } - ListElement { title: "Customer service" } + ListElement { sender: "Bob Bobbleton"; title: "How are you going?" } + ListElement { sender: "Rug Emporium"; title: "SALE! All rugs MUST go!" } + ListElement { sender: "Electric Co."; title: "Electricity bill 15/07/2016 overdue" } + ListElement { sender: "Tips"; title: "Five ways this tip will save your life" } } delegate: SwipeDelegate { id: swipeDelegate - text: title + text: model.sender + " - " + model.title width: parent.width - onClicked: if (swipe.complete) listModel.remove(index) + ListView.onRemove: SequentialAnimation { + PropertyAction { + target: swipeDelegate + property: "ListView.delayRemove" + value: true + } + NumberAnimation { + target: swipeDelegate + property: "height" + to: 0 + easing.type: Easing.InOutQuad + } + PropertyAction { + target: swipeDelegate; + property: "ListView.delayRemove"; + value: false + } + } - swipe.right: Rectangle { - color: swipeDelegate.swipe.complete && swipeDelegate.pressed ? "#333" : "#444" - width: parent.width + 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) - Label { - font.pixelSize: swipeDelegate.font.pixelSize - text: qsTr("Remove") - color: "white" - anchors.centerIn: parent + background: Rectangle { + color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato" } } } |