glibmm 2.82.0
|
A simple implementation of Gio::ListModel that stores all items in memory. More...
#include <giomm/liststore.h>
Public Types | |
using | SlotCompare = sigc::slot< int(const Glib::RefPtr< const T_item > &, const Glib::RefPtr< const T_item > &)> |
A slot that will be called to compare two items. | |
using | SlotEqual = sigc::slot< bool(const Glib::RefPtr< const T_item > &, const Glib::RefPtr< const T_item > &)> |
A slot that will be called to compare two items. | |
Public Types inherited from Gio::ListStoreBase | |
using | SlotCompare = sigc::slot< int(const Glib::RefPtr< const Glib::ObjectBase > &, const Glib::RefPtr< const Glib::ObjectBase > &)> |
A slot that will be called to compare two items. | |
using | SlotEqual = sigc::slot< bool(const Glib::RefPtr< const Glib::ObjectBase > &, const Glib::RefPtr< const Glib::ObjectBase > &)> |
A slot that will be called to compare two items. | |
Public Types inherited from Glib::Object | |
using | DestroyNotify = void(*)(gpointer data) |
Public Member Functions | |
Glib::RefPtr< T_item > | get_item (guint position) |
Get the item at position. | |
Glib::RefPtr< const T_item > | get_item (guint position) const |
Get the item at position. | |
void | insert (guint position, const Glib::RefPtr< T_item > &item) |
Inserts item at position. | |
guint | insert_sorted (const Glib::RefPtr< T_item > &item, const SlotCompare &slot) |
Inserts item at a position to be determined by the slot. | |
void | sort (const SlotCompare &slot) |
Sorts the items according to slot. | |
void | append (const Glib::RefPtr< T_item > &item) |
Appends item. | |
void | splice (guint position, guint n_removals, const std::vector< Glib::RefPtr< T_item > > &additions) |
Removes n_removals items and adds additions.size() items. | |
std::pair< bool, unsigned int > | find (const Glib::RefPtr< const T_item > &item) const |
Looks up the given item in the list store by looping over the items until the first occurrence of item. | |
std::pair< bool, unsigned int > | find (const Glib::RefPtr< const T_item > &item, const SlotEqual &slot) const |
Looks up the given item in the list store by looping over the items until the first occurrence of item. | |
Public Member Functions inherited from Gio::ListStoreBase | |
ListStoreBase (ListStoreBase &&src) noexcept | |
ListStoreBase & | operator= (ListStoreBase &&src) noexcept |
~ListStoreBase () noexcept override | |
GListStore * | gobj () |
Provides access to the underlying C GObject. | |
const GListStore * | gobj () const |
Provides access to the underlying C GObject. | |
GListStore * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
void | insert (guint position, const Glib::RefPtr< Glib::ObjectBase > &item) |
Inserts item into store at position. | |
guint | insert_sorted (const Glib::RefPtr< Glib::ObjectBase > &item, const SlotCompare &slot) |
Inserts item into store at a position to be determined by the slot. | |
void | sort (const SlotCompare &slot) |
Sort the items in store according to slot. | |
void | append (const Glib::RefPtr< Glib::ObjectBase > &item) |
Appends item to store. | |
void | remove (guint position) |
Removes the item from store that is at position. | |
void | remove_all () |
Removes all items from store. | |
void | splice (guint position, guint n_removals, const std::vector< Glib::RefPtr< Glib::ObjectBase > > &additions) |
Removes n_removals items and adds additions.size() items. | |
std::pair< bool, unsigned int > | find (const Glib::RefPtr< const Glib::ObjectBase > &item) const |
Looks up the given item in the list store by looping over the items until the first occurrence of item. | |
std::pair< bool, unsigned int > | find (const Glib::RefPtr< const Glib::ObjectBase > &item, const SlotEqual &slot) const |
Looks up the given item in the list store by looping over the items until the first occurrence of item. | |
Glib::PropertyProxy_ReadOnly< GType > | property_item_type () const |
The type of items contained in this list store. | |
Glib::PropertyProxy_ReadOnly< unsigned int > | property_n_items () const |
The number of items contained in this list store. | |
Public Member Functions inherited from Glib::Object | |
Object (const Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&src) noexcept | |
Object & | operator= (Object &&src) noexcept |
void * | get_data (const QueryQuark & key) |
void | set_data (const Quark & key, void *data) |
void | set_data_with_c_callback (const Quark & key, void *data, GDestroyNotify notify) |
void | set_data (const Quark & key, void *data, DestroyNotify notify) |
Prefer set_data_with_c_callback() with a callback with C linkage. | |
void | remove_data (const QueryQuark &quark) |
void * | steal_data (const QueryQuark &quark) |
Public Member Functions inherited from Glib::ObjectBase | |
ObjectBase (const ObjectBase &)=delete | |
ObjectBase & | operator= (const ObjectBase &)=delete |
void | set_property_value (const Glib::ustring & property_name, const Glib::ValueBase & value) |
You probably want to use a specific property_*() accessor method instead. | |
void | get_property_value (const Glib::ustring & property_name, Glib::ValueBase & value) const |
You probably want to use a specific property_*() accessor method instead. | |
template<class PropertyType > | |
void | set_property (const Glib::ustring & property_name, const PropertyType & value) |
You probably want to use a specific property_*() accessor method instead. | |
template<class PropertyType > | |
void | get_property (const Glib::ustring & property_name, PropertyType & value) const |
You probably want to use a specific property_*() accessor method instead. | |
template<class PropertyType > | |
PropertyType | get_property (const Glib::ustring & property_name) const |
You probably want to use a specific property_*() accessor method instead. | |
sigc::connection | connect_property_changed (const Glib::ustring & property_name, const sigc::slot< void()> &slot) |
You can use the signal_changed() signal of the property proxy instead. | |
sigc::connection | connect_property_changed (const Glib::ustring & property_name, sigc::slot< void()> &&slot) |
You can use the signal_changed() signal of the property proxy instead. | |
void | freeze_notify () |
Increases the freeze count on object. | |
void | thaw_notify () |
Reverts the effect of a previous call to freeze_notify(). | |
virtual void | reference () const |
Increment the reference count for this object. | |
virtual void | unreference () const |
Decrement the reference count for this object. | |
GObject * | gobj () |
Provides access to the underlying C GObject. | |
const GObject * | gobj () const |
Provides access to the underlying C GObject. | |
GObject * | gobj_copy () const |
Give a ref-ed copy to someone. Use for direct struct access. | |
Public Member Functions inherited from Gio::ListModel | |
ListModel (ListModel &&src) noexcept | |
ListModel & | operator= (ListModel &&src) noexcept |
~ListModel () noexcept override | |
GListModel * | gobj () |
Provides access to the underlying C GObject. | |
const GListModel * | gobj () const |
Provides access to the underlying C GObject. | |
GType | get_item_type () const |
Gets the type of the items in list. | |
guint | get_n_items () const |
Gets the number of items in list. | |
Glib::RefPtr< Glib::ObjectBase > | get_object (guint position) |
Get the item at position. | |
Glib::RefPtr< const Glib::ObjectBase > | get_object (guint position) const |
Get the item at position. | |
template<typename T_item > | |
Glib::RefPtr< T_item > | get_typed_object (guint position) |
Get the item at position. | |
template<typename T_item > | |
Glib::RefPtr< const T_item > | get_typed_object (guint position) const |
Get the item at position. | |
Glib::SignalProxy< void(guint, guint, guint)> | signal_items_changed () |
Public Member Functions inherited from Glib::Interface | |
Interface () | |
A Default constructor. | |
Interface (Interface &&src) noexcept | |
Interface & | operator= (Interface &&src) noexcept |
Interface (const Glib::Interface_Class &interface_class) | |
Called by constructors of derived classes. | |
Interface (GObject *castitem) | |
Called by constructors of derived classes. | |
~Interface () noexcept override | |
Interface (const Interface &)=delete | |
Interface & | operator= (const Interface &)=delete |
GObject * | gobj () |
const GObject * | gobj () const |
Static Public Member Functions | |
static Glib::RefPtr< ListStore > | create () |
Static Public Member Functions inherited from Gio::ListStoreBase | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
static Glib::RefPtr< ListStoreBase > | create (GType item_type) |
Static Public Member Functions inherited from Gio::ListModel | |
static void | add_interface (GType gtype_implementer) |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Protected Member Functions | |
ListStore () | |
Protected Member Functions inherited from Gio::ListStoreBase | |
ListStoreBase (GType item_type) | |
Protected Member Functions inherited from Glib::Object | |
Object () | |
Object (const Glib::ConstructParams &construct_params) | |
Object (GObject *castitem) | |
~Object () noexcept override | |
Protected Member Functions inherited from Glib::ObjectBase | |
ObjectBase () | |
This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. | |
ObjectBase (const char *custom_type_name) | |
A derived constructor always overrides this choice. | |
ObjectBase (const std::type_info &custom_type_info) | |
This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. | |
ObjectBase (ObjectBase &&src) noexcept | |
ObjectBase & | operator= (ObjectBase &&src) noexcept |
virtual | ~ObjectBase () noexcept=0 |
void | initialize (GObject *castitem) |
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper) |
Protected Member Functions inherited from Gio::ListModel | |
ListModel () | |
You should derive from this class to use it. | |
void | items_changed (guint position, guint removed, guint added) |
Emits the ListModel::signal_items_changed() signal on list. | |
virtual GType | get_item_type_vfunc () |
virtual guint | get_n_items_vfunc () |
virtual gpointer | get_item_vfunc (guint position) |
Additional Inherited Members | |
Related Symbols inherited from Glib::Object | |
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false) |
Related Symbols inherited from Gio::ListModel | |
Glib::RefPtr< Gio::ListModel > | wrap (GListModel *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
A simple implementation of Gio::ListModel that stores all items in memory.
It provides insertions, deletions, and lookups in logarithmic time with a fast path for the common case of iterating the list linearly.
T_item | Base class of the items in the ListStore. All items must be of type T_item or a type derived from T_item. T_item must be Glib::ObjectBase or a type derived from Glib::ObjectBase. |
using Gio::ListStore< T_item >::SlotCompare = sigc::slot<int(const Glib::RefPtr<const T_item>&, const Glib::RefPtr<const T_item>&)> |
A slot that will be called to compare two items.
The slot should return a negative integer if the first item comes before the second, 0 if they are equal, or a positive integer if the first value comes after the second. For instance,
using Gio::ListStore< T_item >::SlotEqual = sigc::slot<bool(const Glib::RefPtr<const T_item>&, const Glib::RefPtr<const T_item>&)> |
A slot that will be called to compare two items.
The slot should return true
if the items are equal, false
if they are not equal. For instance,
|
protected |
void Gio::ListStore< T_item >::append | ( | const Glib::RefPtr< T_item > & | item | ) |
Appends item.
item must be of type ListStoreBase::property_item_type() or derived from it.
Use splice() to append multiple items at the same time efficiently.
item | The new item. |
|
static |
std::pair< bool, unsigned int > Gio::ListStore< T_item >::find | ( | const Glib::RefPtr< const T_item > & | item | ) | const |
Looks up the given item in the list store by looping over the items until the first occurrence of item.
If you need to compare the two items with a custom comparison function, use find(const Glib::RefPtr<const T_item>& item, const SlotEqual& slot) const instead.
item | An item. |
std::pair< bool, unsigned int > Gio::ListStore< T_item >::find | ( | const Glib::RefPtr< const T_item > & | item, |
const SlotEqual & | slot | ||
) | const |
Looks up the given item in the list store by looping over the items until the first occurrence of item.
If you don't need to compare the two items with a custom comparison function, use find(const Glib::RefPtr<const T_item>& item) const instead.
item | An item. |
slot | A comparison function. |
Glib::RefPtr< T_item > Gio::ListStore< T_item >::get_item | ( | guint | position | ) |
Get the item at position.
If position is greater than or equal to the number of items in list, an empty Glib::RefPtr is returned.
An empty Glib::RefPtr is never returned for an index that is less than the length of the list. See ListModel::get_n_items().
position | The position of the item to fetch. |
Glib::RefPtr< const T_item > Gio::ListStore< T_item >::get_item | ( | guint | position | ) | const |
Get the item at position.
If position is greater than or equal to the number of items in list, an empty Glib::RefPtr is returned.
An empty Glib::RefPtr is never returned for an index that is less than the length of the list. See ListModel::get_n_items().
position | The position of the item to fetch. |
void Gio::ListStore< T_item >::insert | ( | guint | position, |
const Glib::RefPtr< T_item > & | item | ||
) |
Inserts item at position.
item must be of type ListStoreBase::property_item_type() or derived from it. position must be smaller than the length of the list, or equal to it to append.
Use splice() to insert multiple items at the same time efficiently.
position | The position at which to insert the new item. |
item | The new item. |
guint Gio::ListStore< T_item >::insert_sorted | ( | const Glib::RefPtr< T_item > & | item, |
const SlotCompare & | slot | ||
) |
Inserts item at a position to be determined by the slot.
The list must already be sorted before calling this function or the result is undefined. Usually you would approach this by only ever inserting items by way of this function.
item | The new item. |
slot | Pairwise comparison function for sorting. |
void Gio::ListStore< T_item >::sort | ( | const SlotCompare & | slot | ) |
Sorts the items according to slot.
slot | Pairwise comparison function for sorting. |
void Gio::ListStore< T_item >::splice | ( | guint | position, |
guint | n_removals, | ||
const std::vector< Glib::RefPtr< T_item > > & | additions | ||
) |
Removes n_removals items and adds additions.size() items.
additions must contain items of type ListStoreBase::property_item_type() or derived from it. Empty RefPtr is not permitted.
This function is more efficient than insert() and remove(), because it only emits ListModel::signal_items_changed() once for the change.
The parameters position and n_removals must be correct (i.e. position + n_removals must be less than or equal to the length of the list at the time this function is called).
position | The position at which to make the change. |
n_removals | The number of items to remove. |
additions | The items to add. |