aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmldesigner/data/merging/ListViewTemplate.qml
blob: 6c59ca4d3953b8925cd34813140f6ac967305a0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import QtQuick 2.10

ListView {
    id: view
    width: listViewBackground.width
    height: listViewBackground.height

    highlightMoveDuration: 0

    children: [
        Item {
             z: -1
             anchors.fill: parent

            Rectangle {
                id: listViewBackground
                width: 420
                height: 420

                color: "#d80e0e"
                anchors.fill: parent // hsa to be preserved
            }
        }
    ]

    model: ListModel {
        ListElement {
            name: "Music"
        }
        ListElement {
            name: "Movies"
        }
        ListElement {
            name: "Camera"
        }
        ListElement {
            name: "Map"
        }
        ListElement {
            name: "Calendar"
        }
        ListElement {
            name: "Messaging"
        }
        ListElement {
            name: "Todo List"
        }
        ListElement {
            name: "Contacts"
        }
        ListElement {
            name: "Settings"
        }
    }

    highlight: Rectangle {
        id: listViewHighLight
        width: view.width // has to be preserved
        height: 120
        color: "#343434"
        radius: 4
        border.color: "#0d52a4"
        border.width: 8
    }

    delegate: Item {
        id: delegate
        width: ListView.view.width
        height: delegateNormal.height

        Rectangle {
            id: delegateNormal
            color: "#bdbdbd"
            anchors.fill: parent
            height: 140
            anchors.margins: 12
            visible: true
            radius: 4
            Text {
                id: labelNormal //id required for binding preservation
                color: "#343434"
                anchors.top: parent.top
                anchors.horizontalCenter: parent.horizontalCenter

                text: name
                anchors.margins: 24
            }
        }

        Rectangle {
            id: delegateHighlighted
            color: "#36bdbdbd"
            anchors.fill: parent
            anchors.margins: 12
            visible: false
            radius: 4
            Text {
                id: labelHighlighted //id required for binding preservation
                color: "#efefef"
                anchors.top: parent.top
                anchors.horizontalCenter: parent.horizontalCenter

                text: name
                anchors.margins: 32
            }
        }


        MouseArea {
            anchors.fill: parent
            onClicked: delegate.ListView.view.currentIndex = index
        }
        states: [
            State {
                name: "Highlighted"

                when: delegate.ListView.isCurrentItem
                PropertyChanges {
                    target: delegateHighlighted
                    visible: true
                }

                PropertyChanges {
                    target: delegateNormal
                    visible: false
                }


            }
        ]
    }

}