summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml
blob: 4cd74a74cb09a4edcca32084b765e7308673ca23 (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
Item {
    id: contactField
    clip: true
    height: 30
    property var label: "Name"
    property var icon: "../../shared/pics/phone.png"
    property var value: ""
    RemoveButton {
        id: removeButton
        anchors.right: parent.right
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        expandedWidth: contactField.width
        onConfirmed: { fieldText.text='' }
    }
    FieldText {
        id: fieldText
        width: contactField.width-70
        anchors.right: removeButton.left
        anchors.rightMargin: 5
        anchors.verticalCenter: parent.verticalCenter
        label: contactField.label
        text: contactField.value
    }
    Image {
        anchors.right: fieldText.left
        anchors.rightMargin: 5
        anchors.verticalCenter: parent.verticalCenter
        source: contactField.icon
    }
    states: [
        State {
            name: "editingText"
            when: fieldText.state == 'editing'
            SetProperties {
                target: removeButton.anchors
                rightMargin: -35
            }
            SetProperties {
                target: fieldText
                width: contactField.width
            }
        }
    ]
    transitions: [
        Transition {
            fromState: ""
            toState: "*"
            reversible: true
            NumberAnimation {
                properties: "width,rightMargin"
                duration: 200
            }
        }
    ]
}