cosmic/widget/table/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! A widget allowing the user to display tables of information with optional sorting by category
//!

pub mod model;
pub use model::{
    Entity, Model,
    category::ItemCategory,
    category::ItemInterface,
    selection::{MultiSelect, SingleSelect},
};
pub mod widget;
pub use widget::compact::CompactTableView;
pub use widget::standard::TableView;

pub type SingleSelectTableView<'a, Item, Category, Message> =
    TableView<'a, SingleSelect, Item, Category, Message>;
pub type SingleSelectModel<Item, Category> = Model<SingleSelect, Item, Category>;

pub type MultiSelectTableView<'a, Item, Category, Message> =
    TableView<'a, MultiSelect, Item, Category, Message>;
pub type MultiSelectModel<Item, Category> = Model<MultiSelect, Item, Category>;

pub fn table<'a, SelectionMode, Item, Category, Message>(
    model: &'a Model<SelectionMode, Item, Category>,
) -> TableView<'a, SelectionMode, Item, Category, Message>
where
    Message: Clone,
    SelectionMode: Default,
    Category: ItemCategory,
    Item: ItemInterface<Category>,
    Model<SelectionMode, Item, Category>: model::selection::Selectable,
{
    TableView::new(model)
}

pub fn compact_table<'a, SelectionMode, Item, Category, Message>(
    model: &'a Model<SelectionMode, Item, Category>,
) -> CompactTableView<'a, SelectionMode, Item, Category, Message>
where
    Message: Clone,
    SelectionMode: Default,
    Category: ItemCategory,
    Item: ItemInterface<Category>,
    Model<SelectionMode, Item, Category>: model::selection::Selectable,
{
    CompactTableView::new(model)
}