Skip to main content

TreeSource

Trait TreeSource 

Source
pub trait TreeSource<K: Key> {
    // Required method
    fn load(&self, parent: Option<&K>, sink: Sink<K>);

    // Provided methods
    fn can_drop(
        &self,
        keys: &[K],
        target: &K,
        position: Position,
    ) -> Result<(), String> { ... }
    fn match_text(&self, node: &Node<K>) -> String { ... }
    fn item(&self, key: &K) -> SelectionItem { ... }
}
Expand description

What the application implements: a branch’s children, on demand.

Required Methods§

Source

fn load(&self, parent: Option<&K>, sink: Sink<K>)

Asks for the children of parent (None: the roots). Answer through sink now or later, from any thread. Not called again for that branch until it is reloaded.

Provided Methods§

Source

fn can_drop( &self, keys: &[K], target: &K, position: Position, ) -> Result<(), String>

Whether keys may be dropped position of target: Err with the reason refuses it. Asked while dragging (a refused target is marked so) and by tree.drop’s default, after the step’s hooks; the view’s own veto (TreeView::can_drop) is asked too. By default every drop is allowed.

Source

fn match_text(&self, node: &Node<K>) -> String

What the filter searches for a node (TreeState::set_filter): by default its plain name (Node::name). Add words the label does not show (a description, tags, a path) after the name; the row highlights what matches in its label only.

Source

fn item(&self, key: &K) -> SelectionItem

A node’s item in the application-wide selection (TreeView::shared): by default its key’s (SelectionItem::from_key). Give the id other widgets showing the same thing use.

Implementors§