cosmic/widget/table/
mod.rs

1//! A widget allowing the user to display tables of information with optional sorting by category
2//!
3
4pub mod model;
5pub use model::{
6    Entity, Model,
7    category::ItemCategory,
8    category::ItemInterface,
9    selection::{MultiSelect, SingleSelect},
10};
11pub mod widget;
12pub use widget::compact::CompactTableView;
13pub use widget::standard::TableView;
14
15pub type SingleSelectTableView<'a, Item, Category, Message> =
16    TableView<'a, SingleSelect, Item, Category, Message>;
17pub type SingleSelectModel<Item, Category> = Model<SingleSelect, Item, Category>;
18
19pub type MultiSelectTableView<'a, Item, Category, Message> =
20    TableView<'a, MultiSelect, Item, Category, Message>;
21pub type MultiSelectModel<Item, Category> = Model<MultiSelect, Item, Category>;
22
23pub fn table<SelectionMode, Item, Category, Message>(
24    model: &Model<SelectionMode, Item, Category>,
25) -> TableView<'_, SelectionMode, Item, Category, Message>
26where
27    Message: Clone,
28    SelectionMode: Default,
29    Category: ItemCategory,
30    Item: ItemInterface<Category>,
31    Model<SelectionMode, Item, Category>: model::selection::Selectable,
32{
33    TableView::new(model)
34}
35
36pub fn compact_table<SelectionMode, Item, Category, Message>(
37    model: &Model<SelectionMode, Item, Category>,
38) -> CompactTableView<'_, SelectionMode, Item, Category, Message>
39where
40    Message: Clone,
41    SelectionMode: Default,
42    Category: ItemCategory,
43    Item: ItemInterface<Category>,
44    Model<SelectionMode, Item, Category>: model::selection::Selectable,
45{
46    CompactTableView::new(model)
47}