slint/tests/cases/widgets/tableview.slint
Aurindam Jana 3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00

49 lines
No EOL
1.3 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
import { StandardTableView } from "std-widgets.slint";
TestCase := Rectangle {
callback set-current-row(int);
out property <int> row-count: list.rows.length;
out property <int> callback-current-row: -1;
in-out property<[[StandardListViewItem]]> rows: [
[{ text: "Item 1" }, { text: "Description"} ],
[{ text: "Item 1" }, { text: "Description"}],
[{ text: "Item 1" }, { text: "Description"}],
];
in-out property <int> current-row <=> list.current-row;
list := StandardTableView {
rows: root.rows;
columns: [
{ title: "Items" },
{ title: "Descriptions" },
];
current-row-changed(index) => {
root.callback-current-row = index;
}
}
set-current-row(index) => {
list.set-current-row(index);
}
}
/*
```rust
let instance = TestCase::new().unwrap();
assert_eq!(instance.get_row_count(), 3);
assert_eq!(instance.get_current_row(), -1);
assert_eq!(instance.get_callback_current_row(), -1);
instance.invoke_set_current_row(1);
assert_eq!(instance.get_callback_current_row(), 1);
assert_eq!(instance.get_current_row(), 1);
```
*/