Main Page Widgets Namespaces Book

# Gtk::ListStore Class Reference
[TreeView Classes]

Inheritance diagram for Gtk::ListStore:

[legend]
List of all members.

## Detailed Description

Thist is a list model for use with a Gtk::TreeView widget.

It implements the Gtk::TreeModel interface, and also implements the Gtk::TreeSortable interface so you can sort the list using the view. Finally, it also implements the tree drag and drop interfaces.

## Public Member Functions

iterator | append ()
| Creates a new row at the end.
void | clear ()
| Removes all rows from the list store.
iterator | erase (const iterator& iter)
| Removes the given row from the list store.
const GtkListStore* | gobj () const
| Provides access to the underlying C GObject.
GtkListStore* | gobj ()
| Provides access to the underlying C GObject.
GtkListStore* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
iterator | insert (const iterator& iter)
| Creates a new row before the position.
iterator | insert_after (const iterator& iter)
| Creates a new row after the position.
bool | iter_is_valid (const iterator& iter) const
| <warning>This function is slow.
void | iter_swap (const iterator& a, const iterator& b)
| Swaps a and b in store .
void | move (const iterator& source, const iterator& destination)
| Moves source to the position at destination.
iterator | prepend ()
| Creates a new row at the start.
void | reorder (const Glib::ArrayHandle<int>& new_order)
| Reorders the list store to follow the order indicated by new_order.
void | set_column_types (const TreeModelColumnRecord& columns)
virtual | ~ListStore ()

## Static Public Member Functions

static Glib::RefPtr<ListStore> | create (const TreeModelColumnRecord& columns)
| Instantiate a new ListStore.

## Protected Member Functions

| ListStore (const TreeModelColumnRecord& columns)
| ListStore ()
| When using this constructor, you must use set_column_types() immediately afterwards.
virtual void | set_value_impl (const iterator& row, int column, const Glib::ValueBase& value)
| Override and implement this in a derived TreeModel class, so that Row::operator() and Row::set_value() work.

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr<Gtk::ListStore> | wrap (GtkListStore* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Constructor & Destructor Documentation

virtual Gtk::ListStore::~ListStore | ( |  | ) | `[virtual]`

Gtk::ListStore::ListStore | ( |  | ) | `[protected]`

When using this constructor, you must use set_column_types() immediately afterwards.

This can be useful when deriving from this class, with a fixed TreeModelColumnRecord that is a member of the class. There is no create() method that corresponds to this constructor, because this constructor should only be used by derived classes.

Gtk::ListStore::ListStore | ( | const TreeModelColumnRecord& | columns | ) | `[explicit, protected]`

## Member Function Documentation

iterator Gtk::ListStore::append | ( |  | ) |

Creates a new row at the end.

The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value(). See also insert() and prepend().

Returns:
  An iterator to the new row.

void Gtk::ListStore::clear | ( |  | ) |

Removes all rows from the list store.

static Glib::RefPtr<ListStore> Gtk::ListStore::create | ( | const TreeModelColumnRecord& | columns | ) | `[static]`

Instantiate a new ListStore.

Parameters:

  | columns | The column types for this tree model.

Returns:
  The new ListStore.

iterator Gtk::ListStore::erase | ( | const iterator& | iter | ) |

Removes the given row from the list store.

Parameters:

  | iter | The iterator to the row to be removed.

Returns:
  An iterator to the next row, or end() if there is none.

const GtkListStore* Gtk::ListStore::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gtk::TreeDragDest.

GtkListStore* Gtk::ListStore::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gtk::TreeDragDest.

GtkListStore* Gtk::ListStore::gobj_copy | ( |  | ) |

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

iterator Gtk::ListStore::insert | ( | const iterator& | iter | ) |

Creates a new row before the position.

If iter is end() then a new row will be appended to the list. The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value(). See also prepend() and append().

Parameters:

  | iter | An iterator to the row before which the new row will be inserted.

Returns:
  An iterator to the new row.

iterator Gtk::ListStore::insert_after | ( | const iterator& | iter | ) |

Creates a new row after the position.

If iter is end() then a new row will be prepended to the list. The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value(). See also insert(), prepend() and append().

Parameters:

  | iter | An iterator to the row after which the new row will be inserted.

Returns:
  An iterator to the new row.

bool Gtk::ListStore::iter_is_valid | ( | const iterator& | iter | ) | const`[virtual]`

<warning>This function is slow.

Only use it for debugging and/or testing purposes.</warning>

Checks if the given iter is a valid iter for this Gtk::ListStore.

Parameters:

  | iter | A Gtk::TreeIter.

Returns:
  `true` if the iter is valid, `false` if the iter is invalid.

Since gtkmm 2.2:

Reimplemented from Gtk::TreeModel.

void Gtk::ListStore::iter_swap | ( | const iterator& | a,
|  | const iterator& | b |
| ) |  |  |

Swaps a and b in store .

Note that this function only works with unsorted stores.

Since gtkmm 2.2:

Parameters:

  | a | A Gtk::TreeIter.
  | b | Another Gtk::TreeIter.

void Gtk::ListStore::move | ( | const iterator& | source,
|  | const iterator& | destination |
| ) |  |  |

Moves source to the position at destination.

Note that this function only works with unsorted stores.

Parameters:

  | source | The row that should be moved.
  | destination | The position to move to.

iterator Gtk::ListStore::prepend | ( |  | ) |

Creates a new row at the start.

The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value(). See also insert() and append().

Returns:
  An iterator to the new row.

void Gtk::ListStore::reorder | ( | const Glib::ArrayHandle< int > & | new_order | ) |

Reorders the list store to follow the order indicated by new_order.

Note that this function only works with unsorted stores.

void Gtk::ListStore::set_column_types | ( | const TreeModelColumnRecord& | columns | ) |

virtual void Gtk::ListStore::set_value_impl | ( | const iterator& | row,
|  | int | column,
|  | const Glib::ValueBase & | value |
| ) |  |  | `[protected, virtual]`

Override and implement this in a derived TreeModel class, so that Row::operator() and Row::set_value() work.

You can probably just implement this by calling set_value_vfunc(). Your implementation of set_value_impl() should also call set_row_changed() after changing the value.

Reimplemented from Gtk::TreeModel.

## Friends And Related Function Documentation

Glib::RefPtr<Gtk::ListStore> wrap | ( | GtkListStore * | 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.

The documentation for this class was generated from the following file:

- liststore.h