1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: MIT
3
4import { LineEdit, Button, Slider, StandardListView, GridBox, HorizontalBox } from "std-widgets.slint";
5
6export component MainWindow inherits Window {
7 in property <[StandardListViewItem]> names-list;
8 out property <int> current-item: list.current-item;
9 out property <string> name;
10 out property <string> surname;
11 out property <string> prefix;
12 callback prefixEdited();
13 callback createClicked();
14 callback updateClicked();
15 callback deleteClicked();
16
17 GridBox {
18 Text {
19 text: "Filter prefix:";
20 vertical-alignment: center;
21 horizontal-alignment: right;
22 }
23
24 LineEdit {
25 text <=> root.prefix;
26 edited => { root.prefixEdited() }
27 }
28
29 list := StandardListView {
30 row: 1;
31 rowspan: 3;
32 colspan: 2;
33 model: root.names-list;
34 }
35
36 Text {
37 col: 2;
38 row: 1;
39 text: "Name: ";
40 vertical-alignment: center;
41 horizontal-alignment: right;
42 }
43
44 LineEdit { text <=> root.name; }
45
46 Text {
47 col: 2;
48 row: 2;
49 text: "Surname: ";
50 vertical-alignment: center;
51 horizontal-alignment: right;
52 }
53
54 LineEdit { text <=> root.surname; }
55
56 HorizontalBox {
57 padding-left: 0;
58 padding-bottom: 0;
59 row: 4;
60 alignment: start;
61
62 Button {
63 clicked => { root.createClicked() }
64
65 text: "Create";
66 }
67 Button {
68 clicked => { root.updateClicked() }
69
70 text: "Update";
71 enabled: list.current-item != -1 && list.current-item < root.names-list.length;
72
73 }
74 Button {
75 clicked => { root.deleteClicked() }
76
77 text: "Delete";
78 enabled: list.current-item != -1 && list.current-item < root.names-list.length;
79 }
80 }
81 }
82}
83