Skip to main content

TreeListViewState

Struct TreeListViewState 

Source
pub struct TreeListViewState<Id> { /* private fields */ }
Expand description

Persistent view state and its derived caches.

Implementations§

Source§

impl<Id: Copy + Eq + Hash> TreeListViewState<Id>

Source

pub fn handle_action<T, F, S, C, Custom>( &mut self, model: &T, query: &TreeQuery<F, S>, columns: &C, action: TreeAction<Custom>, ) -> TreeEvent<Id, Custom>
where T: TreeModel<Id = Id>, F: TreeFilter<T>, S: TreeSort<T>, C: TreeColumns<T>,

Handles an action against the current projection.

Source

pub fn apply_edit<T, F, S>( &mut self, model: &mut T, query: &TreeQuery<F, S>, command: TreeEditCommand<Id>, ) -> Result<TreeChangeSet<Id>, T::Error>
where T: TreeEditor<Id = Id>, F: TreeFilter<T>, S: TreeSort<T>,

Applies a command through the model, reconciles persistent state, and rebuilds the projection.

§Errors

Returns the model-specific error from TreeEditor::apply without changing view state.

Source

pub fn reconcile_changes(&mut self, changes: &TreeChangeSet<Id>)

Reconciles marks, expansion, and selection with an exact model change set.

Source§

impl<Id: Copy + Eq + Hash> TreeListViewState<Id>

Source

pub fn hit_test(&self, position: Position) -> Option<TreeHit<Id>>

Resolves a row and column from coordinates in the latest render call.

Source§

impl<Id: Copy + Eq + Hash> TreeListViewState<Id>

Source

pub fn ensure_mark_states<T: TreeModel<Id = Id>>(&mut self, model: &T)

Rebuilds tri-state marks after the model or manual marks change.

Source

pub fn mark_state(&self, id: Id) -> TreeMarkState

Returns an aggregated mark from the most recently computed cache.

Source

pub fn is_manually_marked(&self, id: Id) -> bool

Source

pub fn set_marked(&mut self, id: Id, marked: bool) -> bool

Sets a node’s manual mark.

Source

pub fn toggle_marked(&mut self, id: Id) -> bool

Toggles a node’s manual mark.

Source

pub fn clear_marks(&mut self) -> bool

Removes every manual mark.

Source

pub fn manual_marked_ids(&self) -> impl Iterator<Item = Id> + '_

Source§

impl<Id: Copy + Eq + Hash> TreeListViewState<Id>

Source

pub const fn selected_id(&self) -> Option<Id>

Возвращает идентификатор выбранной строки.

Source

pub const fn selected_index(&self) -> Option<usize>

Возвращает индекс выбранного вхождения в текущей проекции.

Source

pub fn select_id(&mut self, selected: Option<Id>) -> bool

Выбирает первое видимое вхождение узла по идентификатору.

Source

pub fn select_index(&mut self, index: Option<usize>) -> bool

Selects a row in the current projection.

Source

pub fn select_first(&mut self) -> bool

Selects the first row.

Source

pub fn select_last(&mut self) -> bool

Selects the last row.

Source

pub fn select_prev(&mut self) -> bool

Selects the previous row, starting at the last row when nothing is selected.

Source

pub fn select_next(&mut self) -> bool

Selects the next row, starting at the first row when nothing is selected.

Source

pub fn select_parent(&mut self) -> bool

Selects the visible parent.

Source

pub fn select_first_child(&mut self) -> bool

Selects the first visible direct child.

Source

pub fn selected_parent_id(&self) -> Option<Id>

Returns the selected node’s parent even when a synthetic parent is hidden.

Source

pub fn selected_level(&self) -> Option<usize>

Source

pub const fn visible_len(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Source

pub fn visible_ids(&self) -> impl Iterator<Item = Id> + '_

Source

pub fn visible_index_of(&self, id: Id) -> Option<usize>

Source

pub fn visible_contains(&self, id: Id) -> bool

Source

pub const fn offset(&self) -> usize

Returns the index of the first viewport row.

Source

pub fn set_offset(&mut self, offset: usize) -> bool

Sets the first viewport row independently of selection.

Source

pub fn scroll_view_by(&mut self, amount: isize) -> bool

Scrolls the viewport without changing selection.

Source

pub const fn horizontal_offset(&self) -> u16

Source

pub const fn set_horizontal_offset(&mut self, offset: u16) -> bool

Source

pub const fn scroll_horizontal_by(&mut self, amount: i16) -> bool

Source

pub const fn selected_column(&self) -> Option<usize>

Source

pub fn select_column( &mut self, column: Option<usize>, column_count: usize, ) -> bool

Source

pub fn select_column_left(&mut self, column_count: usize) -> bool

Source

pub fn select_column_right(&mut self, column_count: usize) -> bool

Source§

impl<Id: Copy + Eq + Hash> TreeListViewState<Id>

Source

pub fn ensure_projection<T, F, S>( &mut self, model: &T, query: &TreeQuery<F, S>, ) -> bool
where T: TreeModel<Id = Id>, F: TreeFilter<T>, S: TreeSort<T>,

Synchronizes the projection with model, query, and expansion revisions.

Returns true when the projection was rebuilt.

Source

pub fn select_by_id<T, F, S>( &mut self, model: &T, query: &TreeQuery<F, S>, id: Id, ) -> bool
where T: TreeModel<Id = Id>, F: TreeFilter<T>, S: TreeSort<T>,

Expands the path to a node and selects it when it is present in the projection.

Source

pub fn expand_to<T: TreeModel<Id = Id>>( &mut self, model: &T, target: Id, ) -> bool

Expands every loaded ancestor of a node.

Source

pub fn expand_all<T: TreeModel<Id = Id>>(&mut self, model: &T) -> bool

Expands every loaded branch in the forest.

Source

pub fn collapse_all(&mut self) -> bool

Collapses every branch.

Source

pub fn set_expanded( &mut self, id: Id, parent: Option<Id>, expanded: bool, ) -> bool

Sets the expansion state of a specific path.

Source

pub fn node_is_expanded(&self, id: Id, parent: Option<Id>) -> bool

Returns persisted expansion state rather than filter-forced state.

Source

pub fn effective_expansion(&self, id: Id) -> Option<TreeExpansionState>

Returns the effective expansion state of a visible node.

Source

pub fn expanded_paths(&self) -> impl Iterator<Item = (Option<Id>, Id)> + '_

Iterates over persisted expanded paths in unspecified order.

Source§

impl<Id: Copy + Eq + Hash> TreeListViewState<Id>

Source

pub fn new() -> Self

Creates empty view state.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates view state with preallocated projection storage.

Source

pub fn from_snapshot(snapshot: TreeListViewSnapshot<Id>) -> Self

Restores state from a snapshot.

Source

pub const fn projection(&self) -> &TreeProjection<Id>

Returns the current projection. Before reading it, the application must call TreeListViewState::ensure_projection or render the widget.

Source

pub fn snapshot(&self) -> TreeListViewSnapshot<Id>

Captures the persistent part of the state.

Source

pub fn restore(&mut self, snapshot: TreeListViewSnapshot<Id>)

Restores persistent state and resets derived caches.

Source

pub const fn draw_lines(&self) -> bool

Source

pub const fn set_draw_lines(&mut self, draw: bool)

Trait Implementations§

Source§

impl<Id: Copy + Eq + Hash> Default for TreeListViewState<Id>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Id> Freeze for TreeListViewState<Id>
where Id: Freeze,

§

impl<Id> RefUnwindSafe for TreeListViewState<Id>
where Id: RefUnwindSafe,

§

impl<Id> Send for TreeListViewState<Id>
where Id: Send,

§

impl<Id> Sync for TreeListViewState<Id>
where Id: Sync,

§

impl<Id> Unpin for TreeListViewState<Id>
where Id: Unpin,

§

impl<Id> UnsafeUnpin for TreeListViewState<Id>
where Id: UnsafeUnpin,

§

impl<Id> UnwindSafe for TreeListViewState<Id>
where Id: UnwindSafe,

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.