mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-30 23:27:22 +00:00
Florian/sort todo (#1721)
Implement `set_row_data` for `SortModel` and `FilterModel` (rust and cpp). Add sort and filter example to the todo example.
This commit is contained in:
parent
7ec79fb324
commit
129ee0acae
5 changed files with 96 additions and 1 deletions
|
@ -44,5 +44,25 @@ int main()
|
|||
return slint::CloseRequestResponse::HideWindow;
|
||||
});
|
||||
|
||||
demo->set_show_header(true);
|
||||
|
||||
demo->on_apply_sorting_and_filtering([todo_model, demo = slint::ComponentWeakHandle(demo)] {
|
||||
auto demo_lock = demo.lock();
|
||||
(*demo_lock)->set_todo_model(todo_model);
|
||||
|
||||
if ((*demo_lock)->get_hide_done_items()) {
|
||||
(*demo_lock)
|
||||
->set_todo_model(std::make_shared<slint::FilterModel<TodoItem>>(
|
||||
(*demo_lock)->get_todo_model(), [](auto e) { return !e.checked; }));
|
||||
}
|
||||
|
||||
if ((*demo_lock)->get_is_sort_by_name()) {
|
||||
(*demo_lock)
|
||||
->set_todo_model(std::make_shared<slint::SortModel<TodoItem>>(
|
||||
(*demo_lock)->get_todo_model(),
|
||||
[](auto lhs, auto rhs) { return lhs.title < rhs.title; }));
|
||||
}
|
||||
});
|
||||
|
||||
demo->run();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue