GcrUi.CollectionModel
Description: Reference for GcrUi.CollectionModel

### Class

# GcrUiCollectionModel

#### Description [src]

    class GcrUi.CollectionModel : GObject.Object
      implements Gtk.TreeModel, Gtk.TreeSortable {
      /* No available fields */
    }

Ain implementation of a `GtkTreeModel` which contains a row for each object in a `GcrCollection`.

As objects are added or removed from the collection, rows are added and removed from this model.

The row values come from the properties of the objects in the collection. Use `gcr_collection_model_new()` to create a new collection model. To have more control over the values use a set of `GcrColumn` structures to define the columns. This can be done with `gcr_collection_model_new_full()` or `gcr_collection_model_set_columns()`.

Each row can have a selected state, which is represented by a boolean column. The selected state can be toggled with `gcr_collection_model_toggle_selected()` or set with `gcr_collection_model_set_selected_objects()` and retrieved with `gcr_collection_model_get_selected_objects()`.

To determine which object a row represents and vice versa, use the `gcr_collection_model_iter_for_object()` or `gcr_collection_model_object_for_iter()` functions.

#### Hierarchy

#### Ancestors

- GObject

#### Implements

- GtkTreeModel
- GtkTreeSortable

#### Constructors

###### gcr_collection_model_new

Create a new `GcrCollectionModel`. The variable argument list should contain pairs of property names, and `GType` values. The variable argument list should be terminated with `NULL`.

###### gcr_collection_model_new_full

Create a new `GcrCollectionModel`.

#### Instance methods

###### gcr_collection_model_change_selected

Set whether a given row is toggled selected or not.

###### gcr_collection_model_column_for_selected

Get the column identifier for the column that contains the values of the selected state.

###### gcr_collection_model_get_collection

Get the collection which this model represents.

###### gcr_collection_model_get_selected_objects

Get a list of checked/selected objects.

###### gcr_collection_model_is_selected

Check whether a given row has been toggled as selected.

###### gcr_collection_model_iter_for_object

Set `iter` to the row for the given object. If the object is not in this model, then `FALSE` will be returned.

###### gcr_collection_model_object_for_iter

Get the object that is represented by the given row in the model.

###### gcr_collection_model_set_collection

Set the collection which this model represents.

###### gcr_collection_model_set_columns

Set the columns that the model should contain. `columns` is an array of `GcrColumn` structures, with the last one containing `NULL` for all values.

###### gcr_collection_model_set_selected_objects

Set the checked/selected objects.

###### gcr_collection_model_toggle_selected

Toggle the selected state of a given row.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

##### Methods inherited from GtkTreeModel (28)

Please see GtkTreeModel for a full list of methods.

##### Methods inherited from GtkTreeSortable (6)

###### gtk_tree_sortable_get_sort_column_id

Fills in `sort_column_id` and `order` with the current sort column and the order. It returns `TRUE` unless the `sort_column_id` is `GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID` or `GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID`.

###### gtk_tree_sortable_has_default_sort_func

Returns `TRUE` if the model has a default sort function. This is used primarily by GtkTreeViewColumns in order to determine if a model can go back to the default state, or not.

###### gtk_tree_sortable_set_default_sort_func

Sets the default comparison function used when sorting to be `sort_func`. If the current sort column id of `sortable` is `GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID`, then the model will sort using this function.

###### gtk_tree_sortable_set_sort_column_id

Sets the current sort column to be `sort_column_id`. The `sortable` will resort itself to reflect this change, after emitting a `GtkTreeSortable::sort-column-changed` signal. `sort_column_id` may either be a regular column id, or one of the following special values:.

###### gtk_tree_sortable_set_sort_func

Sets the comparison function used when sorting to be `sort_func`. If the current sort column id of `sortable` is the same as `sort_column_id`, then the model will sort using this function.

###### gtk_tree_sortable_sort_column_changed

Emits a `GtkTreeSortable::sort-column-changed` signal on `sortable`.

#### Properties

###### GcrUi.CollectionModel:collection

No description available.

###### GcrUi.CollectionModel:columns

No description available.

###### GcrUi.CollectionModel:mode

No description available.

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

##### Signals inherited from GtkTreeModel (5)

###### GtkTreeModel::row-changed

This signal is emitted when a row in the model has changed.

###### GtkTreeModel::row-deleted

This signal is emitted when a row has been deleted.

###### GtkTreeModel::row-has-child-toggled

This signal is emitted when a row has gotten the first child row or lost its last child row.

###### GtkTreeModel::row-inserted

This signal is emitted when a new row has been inserted in the model.

###### GtkTreeModel::rows-reordered

This signal is emitted when the children of a node in the `GtkTreeModel` have been reordered.

##### Signals inherited from GtkTreeSortable (1)

###### GtkTreeSortable::sort-column-changed

The ::sort-column-changed signal is emitted when the sort column or sort order of `sortable` is changed. The signal is emitted before the contents of `sortable` are resorted.

#### Class structure

    struct GcrUiCollectionModelClass {
      GObjectClass parent_class;

    }

The class for `GcrCollectionModel`.

###### Class members

`parent_class: GObjectClass`

  The parent class.