pub struct ItemCollection(/* private fields */);Expand description
Holds the list of items that constitute the content of an
ItemsControl.
The value is a shared handle: clones refer to the same collection, and handles compare by identity.
Implementations§
Source§impl ItemCollection
impl ItemCollection
Sourcepub fn view(&self) -> &Rc<ItemsSourceView>
pub fn view(&self) -> &Rc<ItemsSourceView>
The read-only view of the collection.
Sourcepub fn set(&self, index: usize, value: Option<BoxedValue>)
pub fn set(&self, index: usize, value: Option<BoxedValue>)
Replaces the item at the specified index.
Panics if the collection is in items source mode.
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Whether the collection is in items source mode.
Sourcepub fn add(&self, value: Option<BoxedValue>) -> i32
pub fn add(&self, value: Option<BoxedValue>) -> i32
Adds an item to the items control.
Returns the position into which the new element was inserted. Panics if the collection is in items source mode.
Sourcepub fn clear(&self)
pub fn clear(&self)
Clears the collection and releases the references on all items currently in the collection.
Panics if the collection is in items source mode.
Sourcepub fn insert(&self, index: usize, value: Option<BoxedValue>)
pub fn insert(&self, index: usize, value: Option<BoxedValue>)
Inserts an element into the collection at the specified index.
Panics if the collection is in items source mode.
Sourcepub fn remove_at(&self, index: usize)
pub fn remove_at(&self, index: usize)
Removes the item at the specified index of the collection or view.
Panics if the collection is in items source mode.
Sourcepub fn remove(&self, value: &Option<BoxedValue>) -> bool
pub fn remove(&self, value: &Option<BoxedValue>) -> bool
Removes the specified item reference from the collection or view. Returns true if the item was removed.
Panics if the collection is in items source mode.
Methods from Deref<Target = ItemsSourceView>§
Sourcepub fn source(&self) -> ItemsSource
pub fn source(&self) -> ItemsSource
Gets the source collection.
Sourcepub fn add_collection_changed(&self, handler: Rc<ItemsChangedHandler>) -> u64
pub fn add_collection_changed(&self, handler: Rc<ItemsChangedHandler>) -> u64
Occurs when the collection has changed to indicate the reason for
the change and which items changed. Returns the token for
remove_collection_changed.
pub fn remove_collection_changed(&self, token: u64)
Sourcepub fn get_at(&self, index: usize) -> Option<BoxedValue>
pub fn get_at(&self, index: usize) -> Option<BoxedValue>
Retrieves the item at the specified index. Panics if out of range.
Sourcepub fn contains(&self, item: &Option<BoxedValue>) -> bool
pub fn contains(&self, item: &Option<BoxedValue>) -> bool
Whether the collection contains the item.
Sourcepub fn index_of(&self, item: &Option<BoxedValue>) -> i32
pub fn index_of(&self, item: &Option<BoxedValue>) -> i32
The index of the item, or -1.
Sourcepub fn iter(&self) -> impl Iterator<Item = Option<BoxedValue>>
pub fn iter(&self) -> impl Iterator<Item = Option<BoxedValue>>
The items, enumerated by index over the live collection.
Sourcepub fn to_vec(&self) -> Vec<Option<BoxedValue>>
pub fn to_vec(&self) -> Vec<Option<BoxedValue>>
A copy of the items.
Trait Implementations§
Source§impl Clone for ItemCollection
impl Clone for ItemCollection
Source§impl Debug for ItemCollection
impl Debug for ItemCollection
Source§impl Deref for ItemCollection
impl Deref for ItemCollection
Source§type Target = ItemsSourceView
type Target = ItemsSourceView
Source§fn deref(&self) -> &ItemsSourceView
fn deref(&self) -> &ItemsSourceView
Source§impl MarkupTyped for ItemCollection
impl MarkupTyped for ItemCollection
Source§const MARKUP: &'static MarkupType
const MARKUP: &'static MarkupType
Auto Trait Implementations§
impl !RefUnwindSafe for ItemCollection
impl !Send for ItemCollection
impl !Sync for ItemCollection
impl !UnwindSafe for ItemCollection
impl Freeze for ItemCollection
impl Unpin for ItemCollection
impl UnsafeUnpin for ItemCollection
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more