blob: 679f4a8ee5f9a795e73b5dc6f9e5ced3ac7da1dd (
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
|
<Item id="contactDetails"
anchors.fill="{parent}">
<properties>
<Property name="contactid" value=""/>
<Property name="label" onValueChanged="labelField.value = label"/>
<Property name="phone" onValueChanged="phoneField.value = phone"/>
<Property name="email" onValueChanged="emailField.value = email"/>
</properties>
<signals>
<Signal name="update"/>
<Signal name="insert"/>
</signals>
<resources>
<SqlQuery id="updateContactQuery" connection="{contactDatabase}">
<query>UPDATE contacts SET label = :l, email = :e, phone = :p WHERE recid = :r</query>
<bindings>
<SqlBind name=":r" value="{contactid}"/>
<SqlBind name=":l" value="{labelField.value}"/>
<SqlBind name=":e" value="{emailField.value}"/>
<SqlBind name=":p" value="{phoneField.value}"/>
</bindings>
</SqlQuery>
<SqlQuery id="insertContactQuery" connection="{contactDatabase}">
<query>INSERT INTO contacts (label, email, phone) VALUES(:l, :e, :p)</query>
<bindings>
<SqlBind name=":l" value="{labelField.value}"/>
<SqlBind name=":e" value="{emailField.value}"/>
<SqlBind name=":p" value="{phoneField.value}"/>
</bindings>
</SqlQuery>
</resources>
<Connection sender="{contactDetails}" signal="update()">
updateContactQuery.exec();
</Connection>
<Connection sender="{contactDetails}" signal="insert()">
insertContactQuery.exec();
</Connection>
<VerticalLayout id="layout"
anchors.fill="{parent}"
spacing="5"
margin="5">
<ContactField id="labelField"
anchors.left="{layout.left}" anchors.leftMargin="5"
anchors.right="{layout.right}" anchors.rightMargin="5"
label="Name"/>
<ContactField id="phoneField"
anchors.left="{layout.left}" anchors.leftMargin="5"
anchors.right="{layout.right}" anchors.rightMargin="5"
icon="../shared/pics/phone.png"
label="Phone"/>
<ContactField id="emailField"
anchors.left="{layout.left}" anchors.leftMargin="5"
anchors.right="{layout.right}" anchors.rightMargin="5"
icon="../shared/pics/email.png"
label="Email"/>
</VerticalLayout>
</Item>
|