1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
3 | |
4 | import { ListView } from "std-widgets.slint" ; |
5 | |
6 | FileLine := Rectangle { |
7 | property <string> filename; |
8 | HorizontalLayout { |
9 | t_filename := Text { |
10 | text: root.filename; |
11 | } |
12 | } |
13 | } |
14 | |
15 | export struct FileItem := { |
16 | filename: string, |
17 | } |
18 | |
19 | MainWindow := Window { |
20 | property <[FileItem]> file-model: [ ]; |
21 | height: 500px; |
22 | width: 500px; |
23 | |
24 | vb := VerticalLayout { |
25 | list-view := ListView { |
26 | for file in file-model: FileLine { |
27 | filename: file.filename; |
28 | } |
29 | } |
30 | } |
31 | |
32 | |
33 | } |
34 | |
35 | |
36 | /* |
37 | |
38 | ```rust |
39 | let ui = MainWindow::new().unwrap(); |
40 | let file_model = vec![ |
41 | FileItem { filename: "one".into() }, |
42 | FileItem { filename: "two".into() }, |
43 | ]; |
44 | let file_model = std::rc::Rc::new(slint::VecModel::from(file_model)); |
45 | // this should not panic |
46 | ui.set_file_model(file_model.into()); |
47 | slint_testing::send_mouse_click(&ui, 10., 10.); |
48 | ``` |
49 | |
50 | */ |
51 | |