blob: 7a44a3f66d8a936f44128957730979b76171fba7 (
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
134
135
136
137
138
139
|
import "../lib"
Item {
id: contacts
width: 240
height: 230
property var mouseGrabbed: false
resources: [
SqlConnection {
id: contactDatabase
name: "qmlConnection"
driver: "QSQLITE"
databaseName: "../../shared/contacts.sqlite"
},
SqlQuery {
id: contactList
connection: contactDatabase
query: "SELECT recid, label, email, phone FROM contacts ORDER BY label, recid"
}
]
Button {
id: cancelEditButton
anchors.top: parent.top
anchors.topMargin: 5
anchors.right: parent.right
anchors.rightMargin: 5
icon: "../../shared/pics/cancel.png"
opacity: mouseGrabbed ? 0 : 1
}
ListView {
id: contactListView
anchors.left: parent.left
anchors.right: parent.right
anchors.top: cancelEditButton.bottom
anchors.bottom: parent.bottom
clip: true
model: contactList
focus: true
delegate: [
Item {
id: wrapper
x: 0
width: ListView.view.width
height: 34
Text {
id: label
x: 45
y: 12
width: parent.width-45
color: "black"
font.bold: true
text: model.label
}
//! [setting qml]
MouseRegion {
anchors.fill: label
onClicked: {
Details.qml = 'Contact.qml';
wrapper.state='opened';
}
}
Item {
id: Details
anchors.fill: parent
opacity: 0
//! [setting qml]
//! [binding]
Bind {
target: Details.qmlItem
property: "contactId"
value: model.recid
}
Bind {
target: Details.qmlItem
property: "label"
value: model.label
}
Bind {
target: Details.qmlItem
property: "phone"
value: model.phone
}
Bind {
target: Details.qmlItem
property: "email"
value: model.email
}
//! [binding]
}
states: [
State {
name: "opened"
SetProperty {
target: wrapper
property: "height"
value: contactListView.height
}
SetProperty {
target: contactListView
property: "yPosition"
value: wrapper.y
}
SetProperty {
target: contactListView
property: "locked"
value: 1
}
SetProperty {
target: label
property: "opacity"
value: 0
}
SetProperty {
target: Details
property: "opacity"
value: 1
}
}
]
transitions: [
Transition {
NumericAnimation {
duration: 500
properties: "yPosition,height,opacity"
}
}
]
Connection {
sender: cancelEditButton
signal: "clicked()"
script: {
if (wrapper.state == 'opened') {
wrapper.state = '';
}
}
}
}
]
}
}
|