glibmm 2.62.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Gio::ListStore< T_item > Class Template Reference

A simple implementation of Gio::ListModel that stores all items in memory. More...

`#include <giomm/liststore.h>`

Inheritance diagram for Gio::ListStore< T_item >:
[legend]

## 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. More...
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. More...
Public Types inherited from Glib::Object
using | DestroyNotify = void(*)(gpointer data)
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify

## Public Member Functions
Glib::RefPtr< T_item > | get_item (guint position)
| Get the item at position. More...
Glib::RefPtr< const T_item > | get_item (guint position) const
| Get the item at position. More...
void | insert (guint position, const Glib::RefPtr< T_item >& item)
| Inserts item at position. More...
guint | insert_sorted (const Glib::RefPtr< T_item >& item, const SlotCompare& slot)
| Inserts item at a position to be determined by the slot. More...
void | sort (const SlotCompare& slot)
| Sorts the items according to slot. More...
void | append (const Glib::RefPtr< T_item >& item)
| Appends item. More...
void | splice (guint position, guint n_removals, const std::vector< Glib::RefPtr< T_item >>& additions)
| Removes n_removals items and adds additions.size() items. More...
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. More...
const GListStore* | gobj () const
| Provides access to the underlying C GObject. More...
GListStore* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
void | insert (guint position, const Glib::RefPtr< Glib::ObjectBase >& item)
| Inserts item into store at position. More...
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. More...
void | sort (const SlotCompare& slot)
| Sort the items in store according to slot. More...
void | append (const Glib::RefPtr< Glib::ObjectBase >& item)
| Appends item to store. More...
void | remove (guint position)
| Removes the item from store that is at position. More...
void | remove_all ()
| Removes all items from store. More...
void | splice (guint position, guint n_removals, const std::vector< Glib::RefPtr< Glib::ObjectBase >>& additions)
| Removes n_removals items and adds additions.size() items. More...
Glib::PropertyProxy_ReadOnly< GType > | property_item_type () const
| The type of items contained in this list store. More...
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 (const Quark& key, void* data, DestroyNotify notify)
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. More...
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| You probably want to use a specific property_*() accessor method instead. More...
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. More...
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. More...
void | 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. More...
void | connect_property_changed (const Glib::ustring& property_name, sigc::slot< void >&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, sigc::slot< void >&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
void | freeze_notify ()
| Increases the freeze count on object. More...
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify(). More...
virtual void | reference () const
| Increment the reference count for this object. More...
virtual void | unreference () const
| Decrement the reference count for this object. More...
GObject* | gobj ()
| Provides access to the underlying C GObject. More...
const GObject* | gobj () const
| Provides access to the underlying C GObject. More...
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access. More...
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src)
| ~trackable ()
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src)
void | remove_destroy_notify_callback (void *data) const
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. More...
const GListModel* | gobj () const
| Provides access to the underlying C GObject. More...
GType | get_item_type () const
| Gets the type of the items in list. More...
guint | get_n_items () const
| Gets the number of items in list. More...
Glib::RefPtr< Glib::ObjectBase > | get_object (guint position)
| Get the item at position. More...
Glib::RefPtr< const Glib::ObjectBase > | get_object (guint position) const
| Get the item at position. More...
Glib::SignalProxy< void, guint, guint, guint > | signal_items_changed ()
virtual GType | get_item_type_vfunc ()
virtual guint | get_n_items_vfunc ()
virtual gpointer | get_item_vfunc (guint position)
Public Member Functions inherited from Glib::Interface
| Interface ()
| A Default constructor. More...
| Interface (Interface&& src) noexcept
Interface& | operator= (Interface&& src) noexcept
| Interface (const Glib::Interface_Class& interface_class)
| Called by constructors of derived classes. More...
| Interface (GObject* castitem)
| Called by constructors of derived classes. More...
| ~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. More...
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. More...

## 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. More...
| ObjectBase (const char* custom_type_name)
| A derived constructor always overrides this choice. More...
| 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. More...
| 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. More...
void | items_changed (guint position, guint removed, guint added)
| Emits the ListModel::signal_items_changed() signal on list. More...

## Additional Inherited Members
Related Functions inherited from Gio::ListStoreBase
Glib::RefPtr< Gio::ListStoreBase > | wrap (GListStore* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Glib::Object
Glib::RefPtr< Glib::Object > | wrap (GObject* object, bool take_copy=false)
Related Functions inherited from Gio::ListModel
Glib::RefPtr< Gio::ListModel > | wrap (GListModel* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Detailed Description

### template<typename T_item>
class Gio::ListStore< T_item >

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.

Since glibmm 2.50:

Template Parameters

  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::Object or a type derived from Glib::Object.

## Member Typedef Documentation

template <typename T_item >

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,

int on_compare_item(const Glib::RefPtr<const T_item>& item1, const Glib::RefPtr<const T_item>& item2);

Since glibmm 2.50:

## Constructor & Destructor Documentation

template <typename T_item >

Gio::ListStore< T_item >::ListStore | ( |  | ) |
| protected

## Member Function Documentation

template <typename T_item >

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.

Since glibmm 2.50:

Parameters

  item | The new item.

template <typename T_item >

static Glib::RefPtr<ListStore> Gio::ListStore< T_item >::create | ( |  | ) |
| static

template <typename T_item >

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().

Since glibmm 2.50:

Parameters

  position | The position of the item to fetch.

Returns
  The object at position.

template <typename T_item >

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().

Since glibmm 2.50:

Parameters

  position | The position of the item to fetch.

Returns
  The object at position.

template <typename T_item >

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.

Since glibmm 2.50:

Parameters

  position | The position at which to insert the new item.
  item | The new item.

template <typename T_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.

Since glibmm 2.50:

Parameters

  item | The new item.
  slot | Pairwise comparison function for sorting.

Returns
  The position at which item was inserted.

template <typename T_item >

void Gio::ListStore< T_item >::sort | ( | const SlotCompare& | slot | ) |

Sorts the items according to slot.

Since glibmm 2.50:

Parameters

  slot | Pairwise comparison function for sorting.

template <typename T_item >

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).

Since glibmm 2.50:

Parameters

  position | The position at which to make the change.
  n_removals | The number of items to remove.
  additions | The items to add.