Gio::ListStoreBase Class Reference

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

`#include <giomm/liststore.h>`

Inheritance diagram for Gio::ListStoreBase:
[legend]

## Public Types

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

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

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

## Related Functions

(Note that these are not member functions.)
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

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

The templated subclass ListStore<> provides better compile-time type safety.

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:

## Member Typedef Documentation

using Gio::ListStoreBase::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.

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 Glib::ObjectBase>& item1, const Glib::RefPtr<const Glib::ObjectBase>& item2);

Since glibmm 2.50:

## Constructor & Destructor Documentation

Gio::ListStoreBase::ListStoreBase | ( | ListStoreBase&& | src | ) |

noexcept

Gio::ListStoreBase::~ListStoreBase | ( |  | ) |

override noexcept

Gio::ListStoreBase::ListStoreBase | ( | GType | item_type | ) |

explicit protected

## Member Function Documentation

void Gio::ListStoreBase::append | ( | const Glib::RefPtr< Glib::ObjectBase >& | item | ) |

Appends item to store.

item must be of type ListStore::property_item_type().

This function takes a ref on item.

Use g_list_store_splice() to append multiple items at the same time efficiently.

Since glibmm 2.50:

Parameters

  item | The new item.

static Glib::RefPtr<ListStoreBase> Gio::ListStoreBase::create | ( | GType | item_type | ) |

static

static GType Gio::ListStoreBase::get_type | ( |  | ) |

static

Get the GType for this class, for use with the underlying GObject type system.

GListStore* Gio::ListStoreBase::gobj | ( |  | ) |

inline

Provides access to the underlying C GObject.

const GListStore* Gio::ListStoreBase::gobj | ( |  | ) | const

inline

Provides access to the underlying C GObject.

GListStore* Gio::ListStoreBase::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

void Gio::ListStoreBase::insert | ( | guint | position,
|  | const Glib::RefPtr< Glib::ObjectBase >& | item
| ) |  |

Inserts item into store at position.

item must be of type ListStore::property_item_type() or derived from it. position must be smaller than the length of the list, or equal to it to append.

This function takes a ref on item.

Use g_list_store_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.

guint Gio::ListStoreBase::insert_sorted | ( | const Glib::RefPtr< Glib::ObjectBase >& | item,
|  | const SlotCompare& | slot
| ) |  |

Inserts item into store 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.

This function takes a ref on item.

Since glibmm 2.50:

Parameters

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

Returns
  The position at which item was inserted.

ListStoreBase& Gio::ListStoreBase::operator= | ( | ListStoreBase&& | src | ) |

noexcept

Glib::PropertyProxy_ReadOnly< GType > Gio::ListStoreBase::property_item_type | ( |  | ) | const

The type of items contained in this list store.

Items must be subclasses of Object.

Since glibmm 2.50:

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

void Gio::ListStoreBase::remove | ( | guint | position | ) |

Removes the item from store that is at position.

position must be smaller than the current length of the list.

Use g_list_store_splice() to remove multiple items at the same time efficiently.

Since glibmm 2.50:

Parameters

  position | The position of the item that is to be removed.

void Gio::ListStoreBase::remove_all | ( |  | ) |

Removes all items from store.

Since glibmm 2.50:

void Gio::ListStoreBase::sort | ( | const SlotCompare& | slot | ) |

Sort the items in store according to slot.

Since glibmm 2.50:

Parameters

  slot | Pairwise comparison function for sorting.

void Gio::ListStoreBase::splice | ( | guint | position,
|  | guint | n_removals,
|  | const std::vector< Glib::RefPtr< Glib::ObjectBase >>& | additions
| ) |  |

Removes n_removals items and adds additions.size() items.

additions must contain items of type 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.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::ListStoreBase > wrap | ( | GListStore * | object,
|  | bool | take_copy = `false`
| ) |  |

related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.