1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3
4import { Button, ListView, LineEdit } from "std-widgets.slint";
5
6struct Protocol { name: string, uuid: string, }
7
8export component TestCases inherits Window {
9 if true : Button {
10 text: "Yes";
11 clicked => {
12 ProtocolManagerLogic.delete-protocol-by-type-uuid(root.current-selected-protocol-type, protocol.uuid);
13 if root.current-selected-protocol-name-uuid[1] == protocol.uuid {
14 root.current-selected-protocol-name-uuid = ["", ""]
15 };
16 /////// When I comment out the next line, the program compiles fine.
17 root.current-selected-protocol-type == "unit" ? btn-show-unit-protocols.clicked() : btn-show-global-protocols.clicked();
18 ///////
19 search-field.text = "";
20 root.is_confirm_delete_open = false;
21 }
22 }
23
24 btn-show-unit-protocols := Button {
25 text: "Show Unit Protocols";
26 checked: root.current-selected-protocol-type == "unit";
27 clicked => {
28 root.get-all-unit-protocols();
29 }
30 }
31
32 btn-show-global-protocols := Button {
33 text: "Show Global Protocols";
34 checked: root.current-selected-protocol-type == "global";
35 clicked => {
36 root.get-all-global-protocols();
37 }
38 }
39
40 function get-all-unit-protocols() {
41 ProtocolManagerLogic.get-all-unit-protocols();
42 root.current-selected-protocol-type = "unit";
43 root.current-selected-protocol-name-uuid = [current-displayed-protocols[0].name, current-displayed-protocols[0].uuid];
44 root.is_confirm_delete_open = false;
45 if current-displayed-protocols[0].uuid != "" {
46 ProtocolManagerLogic.get-protocol-by-type-uuid(root.current-selected-protocol-type, current-displayed-protocols[0].uuid)
47 }
48 search-field.text = "";
49 root.current-searched-protocols = root.current-displayed-protocols;
50 protocol-list.viewport-y = 0px;
51 }
52
53 protocol-list := ListView {}
54 search-field := LineEdit { }
55
56 in-out property <string> current-selected-protocol-type;
57 in-out property <bool> is_confirm_delete_open;
58 function get-all-global-protocols() {}
59 in-out property <[Protocol]> current-displayed-protocols;
60 in-out property <[Protocol]> current-searched-protocols;
61 in-out property <[string]> current-selected-protocol-name-uuid;
62 in-out property <Protocol> protocol;
63
64}
65
66global ProtocolManagerLogic {
67 callback get-protocol-by-type-uuid(string , string );
68 callback delete-protocol-by-type-uuid(string , string );
69 callback get-all-unit-protocols();
70 callback get-all-global-protocols();
71}
72