Expand description
CheckedModel — per-row checkbox state for flat collection widgets.
Tracks which rows in a list view are marked (checked), independently of which row is selected. Selection (cursor position) and checked-ness (persistent marks) are orthogonal axes — the Outlook / Files-app convention where you can check many items and then act on them all.
The model issues one writable Signal<bool> per row index via
CheckedModel::signal_for; repeated calls for the same index return the
same cached handle. A Checkbox widget writes to that signal on click;
the model observes every per-index signal and keeps a central
Signal<BTreeSet<usize>> in sync so consumers can react to the complete
checked set without subscribing to each row individually.
CheckedModel is a share-by-clone handle (Rc<RefCell<…>> internally);
cloning produces a second handle to the same state. When rows are inserted,
removed, or reordered, call the corresponding adjust_for_* method so that
checked state follows the moved items rather than sticking to stale indices.
For hierarchical lists with descendant→ancestor tristate aggregation, see
crate::TreeCheckedModel instead.
let model = CheckedModel::new();
model.check(1);
model.check(3);
assert!(model.is_checked(1));
assert_eq!(model.checked_count(), 2);
model.toggle(1);
assert!(!model.is_checked(1));Structs§
- Checked
Model - Per-row checkbox state for a flat list, with a reactive aggregate checked-set.