Skip to main content

KeyedSelectionModel

Struct KeyedSelectionModel 

Source
pub struct KeyedSelectionModel<K: ItemKey> { /* private fields */ }
Expand description

Selection state keyed by source-defined identity rather than visible index.

The selection set is exposed as a Signal<HashSet<K>> (via selection_signal) so widgets observe it reactively without polling. Cloning the model shares the same selection and anchor across all handles. The Shift+click anchor is stored as a K so it survives lazy-window evictions and visible-order changes.

Implementations§

Source§

impl<K: ItemKey> KeyedSelectionModel<K>

Source

pub fn new(mode: SelectionMode) -> Self

Create a new keyed selection model with the given mode.

Source

pub fn mode(&self) -> SelectionMode

The selection mode.

Source

pub fn selection_signal(&self) -> Signal<HashSet<K>>

A clone of the selection signal for reactive binding.

Source

pub fn is_selected(&self, key: &K) -> bool

Whether key is currently selected (O(1)).

Source

pub fn selected_keys(&self) -> Vec<K>

The currently selected keys (unordered snapshot).

Source

pub fn count(&self) -> usize

Number of selected items.

Source

pub fn select(&self, key: K)

Select a single key, clearing previous selection and setting the anchor.

Source

pub fn toggle(&self, key: K)

Toggle a key (Ctrl+click in Multi mode; acts as select in Single).

Source

pub fn extend_to(&self, target: K, ordered_keys: &[K])

Extend the selection from the anchor to target over the current visible key order (Shift+click). ordered_keys is the projection’s visible order at click time. If the anchor isn’t currently visible (scrolled out / evicted), falls back to a single-key select.

Source

pub fn select_keys(&self, keys: impl IntoIterator<Item = K>, additive: bool)

Replace the selection with keys (or, when additive, union them in). Used by rubber-band selection. In Single mode an arbitrary one wins.

Source

pub fn clear(&self)

Clear the selection and anchor.

Source

pub fn prune_missing(&self, exists: impl Fn(&K) -> bool)

Drop any selected key (and the anchor) for which exists returns false. Call after a removal/reset to prune deleted rows — the index-based adjust_for_insert/adjust_for_remove are unnecessary here because keys are stable across inserts, moves, sorts and filters.

Source§

impl<K: ItemKey> KeyedSelectionModel<K>

Source

pub fn debug_named(self, _name: impl Into<String>) -> Self

Register this model with the debug inspector under name; no-op in release builds (!cfg(debug_assertions)). Returns self for chaining.

Trait Implementations§

Source§

impl<K: ItemKey> Clone for KeyedSelectionModel<K>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: ItemKey> Debug for KeyedSelectionModel<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.