Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativelanguage / data / listItemDeleteSelf.qml
1 import QtQuick 1.0
2
3 Item {
4     ListModel {
5         id: fruitModel
6         ListElement {
7             name: "Apple"
8             cost: 2.45
9         }
10         ListElement {
11             name: "Orange"
12             cost: 3.25
13         }
14         ListElement {
15             name: "Banana"
16             cost: 1.95
17         }
18     }
19
20     Component {
21         id: fruitDelegate
22         Item {
23             width: 200; height: 50
24             Text { text: name }
25             Text { text: '$'+cost; anchors.right: parent.right }
26             MouseArea {
27                 anchors.fill: parent
28                 onClicked: fruitModel.remove(index)
29             }
30         }
31     }
32
33     ListView {
34         model: fruitModel
35         delegate: fruitDelegate
36         anchors.fill: parent
37     }
38 }