Skip to main content

TableViewSource

Struct TableViewSource 

Source
pub struct TableViewSource<T> { /* private fields */ }
Expand description

XAML TableViewSource: the items a TableView shows and the shape it shows them in.

The application makes one with TableViewSource::from, hands it to one TableView, and disposes it after the view.

Implementations§

Source§

impl<T: 'static> TableViewSource<T>

Source

pub fn from(app: &mut App, items: Vec<T>) -> Ref<Self>

TableViewSource.From: a source over items, unshaped, its view populated by the time it returns.

Source

pub fn dispose(self: Handle<Self>, app: &mut App)

Releases the listeners; the source is not used after.

Source

pub fn item_count(self: Handle<Self>, app: &App) -> usize

How many items there are.

Source

pub fn item(self: Handle<Self>, app: &App, index: usize) -> &T

The item at index, in source order.

Source

pub fn set_items(self: Handle<Self>, app: &mut App, items: Vec<T>)

Replaces the items, as the collection the source wraps raising a reset: the filter and the sorts stay, the view is rebuilt from the new items, and a TableView showing the source clears its selection (SelectionNode::OnSourceListChanged, Reset).

Source

pub fn insert(self: Handle<Self>, app: &mut App, index: usize, item: T)

Inserts item at index of the items, as the collection raising Add: its row goes to its place in the view, unless the filter leaves it out.

Source

pub fn remove(self: Handle<Self>, app: &mut App, index: usize)

Removes the item at index, as the collection raising Remove: its row, if shown, is removed.

Source

pub fn replace(self: Handle<Self>, app: &mut App, index: usize, item: T)

Replaces the item at index with item, as the collection raising Replace: without a sort its row shows the new item; with one the row is removed and the new item inserted at its place. A row replaced is no longer selected, as SelectionNode treats a replacement as a removal and an insertion; update keeps it.

Source

pub fn update( self: Handle<Self>, app: &mut App, index: usize, change: impl FnOnce(&mut T), )

Changes the item at index in place, as an item raising PropertyChanged: its row shows the new values and stays selected, and moves to its new place if a sort key changed, or leaves or joins the view if the filter’s answer did.

Source

pub fn view(self: Handle<Self>, app: &App) -> &[usize]

View: each row of the projection, as its index in the items.

Source

pub fn filter( self: Handle<Self>, app: &mut App, predicate: impl Fn(&T) -> bool + 'static, ) -> Handle<Self>

Filter: the only items shown are those predicate keeps, in source order before any sort. Each call replaces the previous predicate.

Source

pub fn clear_filter(self: Handle<Self>, app: &mut App) -> Handle<Self>

ClearFilter: nothing at all when no filter is set, not even a rebuild.

Source

pub fn sort<K: Ord>( self: Handle<Self>, app: &mut App, key: impl Fn(&T) -> K + 'static, direction: SortDirection, ) -> Handle<Self>

Sort: adds a sort axis ordering the rows by key in direction, after the axes already declared, which it breaks ties within. SortDirection::None adds nothing.

Source

pub fn clear_sort(self: Handle<Self>, app: &mut App) -> Handle<Self>

ClearSort: every axis, the ones a TableView installed included; nothing when there are none.

Trait Implementations§

Source§

impl<T: 'static> ChangeNotifier for TableViewSource<T>

Source§

fn change_notifier_data(&self) -> &ChangeNotifierData

Source§

fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData

Source§

fn will_add_listener(self: Handle<Self>, app: &mut App)

Runs before the listener is stored. Dart overrides of addListener that work before super.addListener go here.
Source§

fn did_remove_listener(self: Handle<Self>, app: &mut App)

Runs after the listener is removed. Dart overrides of removeListener that work after super.removeListener go here.
Source§

impl<T> Debug for TableViewSource<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for TableViewSource<T>

§

impl<T> !Send for TableViewSource<T>

§

impl<T> !Sync for TableViewSource<T>

§

impl<T> !UnwindSafe for TableViewSource<T>

§

impl<T> Forget for TableViewSource<T>

§

impl<T> Freeze for TableViewSource<T>
where *const u8 is !null: Freeze, PhantomData<Option<Listener>>: Freeze, *const RcInner<Cell<usize>> is !null: Freeze, PhantomData<RcInner<Cell<usize>>>: Freeze, PhantomData<Rc<T>>: Freeze, *const RcInner<dyn Fn(&T) -> bool> is !null: Freeze, PhantomData<RcInner<dyn Fn(&T) -> bool>>: Freeze, PhantomData<SortAxis<T>>: Freeze, PhantomData<usize>: Freeze, NonZero<u32>: Freeze, PhantomData<ViewChange>: Freeze,

§

impl<T> Move for TableViewSource<T>

§

impl<T> Unpin for TableViewSource<T>
where *const u8 is !null: Unpin, Rc<dyn Fn(&mut App)>: Unpin, NonZero<u32>: Unpin, *const (): Unpin, Rc<Cell<usize>>: Unpin, Rc<T>: Unpin, Rc<dyn Fn(&T) -> bool>: Unpin, Rc<dyn Fn(&T, &T) -> Ordering>: Unpin,

§

impl<T> UnsafeUnpin for TableViewSource<T>
where *const u8 is !null: UnsafeUnpin, PhantomData<Option<Listener>>: UnsafeUnpin, *const RcInner<Cell<usize>> is !null: UnsafeUnpin, PhantomData<RcInner<Cell<usize>>>: UnsafeUnpin, PhantomData<Rc<T>>: UnsafeUnpin, *const RcInner<dyn Fn(&T) -> bool> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&T) -> bool>>: UnsafeUnpin, PhantomData<SortAxis<T>>: UnsafeUnpin, PhantomData<usize>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, PhantomData<ViewChange>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> ListenableObject for T
where T: ChangeNotifier,

Source§

fn add_listener(self: Handle<T>, app: &mut App, listener: Listener)

Register a closure to be called when the object notifies its listeners.
Source§

fn remove_listener(self: Handle<T>, app: &mut App, listener: &Listener)

Remove a previously registered closure from the list of closures that the object notifies.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>