summaryrefslogtreecommitdiffstats
path: root/examples/interfaceframework/addressbook/Main.qml
blob: 308c3047f29cba9e397e6ca4d0c042d1a2004528 (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
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Window
import Example.If.AddressBookModule

Window {
    id: root
    visible: true
    width: 640
    height: 480
    title: qsTr("Interface Framework Address Book")

    UiAddressBook {
        id: addressBook
    }
    GroupBox {
        anchors.fill: parent
        anchors.margins: 10
        title: "Contacts"

        ColumnLayout {
            anchors.fill: parent
            //! [0]
            ListView {
                Layout.fillWidth: true
                Layout.fillHeight: true
                model: addressBook.contacts
                clip: true

                delegate: ItemDelegate {
                    width: parent.width
                    height: 100
                    text: model.item.forename + " " + model.item.name
                }
            }
            //! [0]
            Button {
                Layout.fillWidth: true
                text: "New Contact"
                onClicked: addressBook.insertContact(0, AddressBookModule.contact("Foo", "Bar", "12234"))
            }
        }
    }
}