Dee.Model¶
- Implementations:
Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
None
Signals¶
Name |
Short Description |
---|---|
Connect to this signal to be notified when a changeset that can contain multiple row additions / changes / removals has been committed to the model. |
|
Connect to this signal to be notified when a changeset that can contain multiple row additions / changes / removals is about to be committed to the model. |
|
Connect to this signal to be notified when a row is added to self. |
|
Connect to this signal to be notified when a row is changed. |
|
Connect to this signal to be notified when a row is removed from self. |
Fields¶
None
Class Details¶
- class Dee.Model¶
- Bases:
- Structure:
- append_row(row_members)¶
- Parameters:
row_members ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. If any of the variants have floating references they will be consumed- Returns:
A
Dee.ModelIter
pointing to the new row- Return type:
Like dee_model_append() but intended for language bindings or situations where you work with models on a meta level and may not have a prior knowledge of the column schemas of the models. See also dee_model_build_row().
- begin_changeset()¶
Notify listeners that the model is about to be changed, which means that multiple row additions / changes / removals will follow. The default implementation of this method will emit the
::changeset-started
signal.It is not stricly necessary to enclose every change to a model in a
Dee.Model.begin_changeset
() andDee.Model.end_changeset
() calls, but doing so is highly recommended and allows implementing various optimizations.The usual way to perform multiple changes to a model is as follows:
void update_model (DeeModel *model) { GVariant **added_row_data1 = ...; GVariant **added_row_data2 = ...; dee_model_begin_changeset (model); dee_model_remove (model, dee_model_get_first_iter (model)); dee_model_append_row (model, added_row_data1); dee_model_append_row (model, added_row_data2); dee_model_end_changeset (model); }
- clear()¶
Removes all rows in the model. Signals are emitted for each row in the model
- clear_tag(iter, tag)¶
- Parameters:
iter (
Dee.ModelIter
) – The row to clear the tag fromtag (
Dee.ModelTag
) – The tag to clear from iter
This method is purely syntactic sugar for calling
Dee.Model.set_tag
() with a value ofNone
. It’s included in order to help developers write more readable code.
- end_changeset()¶
Notify listeners that all changes have been committed to the model. The default implementation of this method will emit the
::changeset-finished
signal.See also
Dee.Model.begin_changeset
().
- find_row_sorted(row_spec, cmp_func, *user_data)¶
- Parameters:
row_spec ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. No references will be taken on the variants.cmp_func (
Dee.CompareRowFunc
) – Callback used for comparison or rowsuser_data (
object
orNone
) – Arbitrary pointer passed to cmp_func during search
- Returns:
If out_was_found is set to
True
then aDee.ModelIter
pointing to the last matching row. If it isFalse
then the iter pointing to the row just after where row_spec_would have been inserted.- Return type:
(
Dee.ModelIter
, out_was_found:bool
)
Finds a row in self according to the sorting specified by cmp_func. This method will assume that self is already sorted by cmp_func.
If you use this method for searching you should only use
Dee.Model.insert_row_sorted
() to insert rows in the model.
- find_row_sorted_with_sizes(row_spec, cmp_func, *user_data)¶
- Parameters:
row_spec ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. No references will be taken on the variants.cmp_func (
Dee.CompareRowSizedFunc
) – Callback used for comparison or rowsuser_data (
object
orNone
) – Arbitrary pointer passed to cmp_func during search
- Returns:
If out_was_found is set to
True
then aDee.ModelIter
pointing to the last matching row. If it isFalse
then the iter pointing to the row just after where row_spec_would have been inserted.- Return type:
(
Dee.ModelIter
, out_was_found:bool
)
Like
Dee.Model.find_row_sorted
(), but usesDee.CompareRowSizedFunc
and therefore doesn’t cause trouble when used from introspected languages.Finds a row in self according to the sorting specified by cmp_func. This method will assume that self is already sorted by cmp_func.
If you use this method for searching you should only use
Dee.Model.insert_row_sorted
() (orDee.Model.insert_row_sorted_with_sizes
()) to insert rows in the model.
- get_bool(iter, column)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a boolean from
- Returns:
if iter and column are valid, the boolean stored at column. Otherwise
False
- Return type:
- get_column_index(column_name)¶
- Parameters:
column_name (
str
) – the column name to retrieve the index of- Returns:
0-based index of the column or -1 if column with this name wasn’t found
- Return type:
Get the column index of a column.
- get_column_names()¶
- Returns:
A
None
-terminated array ofGLib.Variant
type strings. The length of the returned array is written to num_columns. The returned array should not be freed or modified. It is owned by the model.- Return type:
[
str
]
Get a
None
-terminated array of column names for the columns of self. These names can be used in calls to dee_model_build_named_row().
- get_column_schema(column)¶
- Parameters:
column (
int
) – the column to get retrieve theGLib.Variant
type string of- Returns:
the
GLib.Variant
signature of the column at index column- Return type:
Get the
GLib.Variant
signature of a column
- get_double(iter, column)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a double from
- Returns:
if iter and column are valid, the double stored at column. Otherwise 0.
- Return type:
- get_field_schema(field_name)¶
- Parameters:
field_name (
str
) – name of vardict field to get schema of- Returns:
the
GLib.Variant
signature for the field, orNone
if given field wasn’t registered withDee.Model.register_vardict_schema
().- out_column:
column index of the associated vardict
- Return type:
Get the
GLib.Variant
signature of field previously registered withDee.Model.register_vardict_schema
().
- get_first_iter()¶
- Returns:
A
Dee.ModelIter
(owned by self, do not free it)- Return type:
Retrieves a
Dee.ModelIter
representing the first row in self.
- get_int32(iter, column)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a int from
- Returns:
if iter and column are valid, the int stored at column. Otherwise 0.
- Return type:
- get_int64(iter, column)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a int64 from
- Returns:
if iter and column are valid, the int64 stored at column. Otherwise 0.
- Return type:
- get_iter_at_row(row)¶
- Parameters:
row (
int
) – position of the row to retrieve- Returns:
A new
Dee.ModelIter
, orNone
if row was out of bounds. The returned iter is owned by self, so do not free it.- Return type:
Retrieves a
Dee.ModelIter
representing the row at the given index.Note that this method does not have any performance guarantees. In particular it is not guaranteed to be O(1).
- get_last_iter()¶
- Returns:
A
Dee.ModelIter
(owned by self, do not free it)- Return type:
Retrieves a
Dee.ModelIter
pointing right after the last row in self. This is refered to also the the end iter.As with other iters the end iter, in particular, is stable over inserts, changes, or removals.
- get_n_columns()¶
- Returns:
the number of columns per row in self
- Return type:
Gets the number of columns in self
- get_position(iter)¶
- Parameters:
iter (
Dee.ModelIter
) – The iter to get the position of- Returns:
The integer offset of iter in self
- Return type:
Get the numeric offset of iter into self. Note that this method is not guaranteed to be O(1).
- get_row(iter)¶
- Parameters:
iter (
Dee.ModelIter
) – ADee.ModelIter
pointing to the row to get- Returns:
out_row_members if it was not
None
or a newly allocated array otherwise which you must free withGLib.free
(). The variants in the array will have a strong reference and needs to be freed withGLib.Variant.unref
().- Return type:
([
GLib.Variant
], out_row_members: [GLib.Variant
])
- get_schema()¶
- Returns:
A
None
-terminated array ofGLib.Variant
type strings. The length of the returned array is written to num_columns. The returned array should not be freed or modified. It is owned by the model.- Return type:
[
str
]
Get a
None
-terminated array ofGLib.Variant
type strings that defines the required formats for the columns of self.
- get_string(iter, column)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a string from
- Returns:
if iter and column are valid, the string stored at column. Otherwise
None
.- Return type:
- get_tag(iter, tag)¶
- Parameters:
iter (
Dee.ModelIter
) – ADee.ModelIter
pointing to the row to get the tag fromtag (
Dee.ModelTag
) – The tag handle to retrieve the tag value for
- Returns:
Returns
None
if tag is unset otherwise the value of the tag as it was set withDee.Model.set_tag
().- Return type:
Look up a tag value for a given row in a model. This method is guaranteed to be O(1).
- get_uchar(iter, column)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a uchar from
- Returns:
if iter and column are valid, the uchar stored at column. Otherwise 0.
- Return type:
- get_uint32(iter, column)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a uint from
- Returns:
if iter and column are valid, the uint stored at column. Otherwise 0.
- Return type:
- get_uint64(iter, column)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a uint64 from
- Returns:
if iter and column are valid, the uint64 stored at column. Otherwise 0.
- Return type:
- get_value(iter, column)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
pointing to the row to inspectcolumn (
int
) – column number to retrieve the value from
- Returns:
A, guaranteed non-floating, reference to a
GLib.Variant
containing the row data. Free withGLib.Variant.unref
().- Return type:
- get_value_by_name(iter, column_name)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
pointing to the row to inspectcolumn_name (
str
) –
- Returns:
A, guaranteed non-floating, reference to a
GLib.Variant
containing the row data. Free withGLib.Variant.unref
().- Return type:
- get_vardict_schema(column)¶
- Parameters:
column (
int
) – the column index to get the schemas for- Returns:
Hashtable containing a mapping from field names to schemas or
None
. Note that keys and values in the hashtable may be owned by the model, so you need to create a deep copy if you intend to keep the hashtable around.- Return type:
Get a schema for variant dictionary column previously registered using
Dee.Model.register_vardict_schema
().
- insert_row(pos, row_members)¶
- Parameters:
pos (
int
) – The index to insert the row on. The existing row will be pushed down.row_members ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. If any of the variants have floating references they will be consumed.
- Returns:
A
Dee.ModelIter
pointing to the new row- Return type:
As dee_model_insert(), but intended for language bindings or situations where you work with models on a meta level and may not have a priori knowledge of the column schemas of the models. See also dee_model_build_row().
- insert_row_before(iter, row_members)¶
- Parameters:
iter (
Dee.ModelIter
) – An iter pointing to the row before which to insert the new onerow_members ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. If any of the variants have floating references they will be consumed.
- Returns:
A
Dee.ModelIter
pointing to the new row- Return type:
As dee_model_insert_before(), but intended for language bindings or situations where you work with models on a meta level and may not have a priori knowledge of the column schemas of the models. See also dee_model_build_row().
- insert_row_sorted(row_members, cmp_func, *user_data)¶
- Parameters:
row_members ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. If any of the variants have floating references they will be consumed.cmp_func (
Dee.CompareRowFunc
) – Callback used for comparison or rowsuser_data (
object
orNone
) – Arbitrary pointer passed to cmp_func during search
- Returns:
A
Dee.ModelIter
pointing to the new row- Return type:
Inserts a row in self according to the sorting specified by cmp_func. If you use this method for insertion you should not use other methods as this method assumes the model to be already sorted by cmp_func.
- insert_row_sorted_with_sizes(row_members, cmp_func, *user_data)¶
- Parameters:
row_members ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. If any of the variants have floating references they will be consumed.cmp_func (
Dee.CompareRowSizedFunc
) – Callback used for comparison or rowsuser_data (
object
orNone
) – Arbitrary pointer passed to cmp_func during search
- Returns:
A
Dee.ModelIter
pointing to the new row- Return type:
Inserts a row in self according to the sorting specified by cmp_func. If you use this method for insertion you should not use other methods as this method assumes the model to be already sorted by cmp_func.
- is_first(iter)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
- Returns:
True
if iter is the first iter in the model- Return type:
Checks if iter is the very first iter self.
- is_last(iter)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
- Returns:
True
if iter is the last iter in the model- Return type:
Whether iter is the end iter of self. Note that the end iter points right after the last valid row in self.
- next(iter)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
- Returns:
A
Dee.ModelIter
, pointing to the next row in the model. The iter is owned by self, do not free it.- Return type:
Returns a
Dee.ModelIter
that points to the next position in the model.
- prepend_row(row_members)¶
- Parameters:
row_members ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. If any of the variants have floating references they will be consumed.- Returns:
A
Dee.ModelIter
pointing to the new row- Return type:
Like dee_model_prepend() but intended for language bindings or situations where you work with models on a meta level and may not have a priori knowledge of the column schemas of the models. See also dee_model_build_row().
- prev(iter)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
- Returns:
A
Dee.ModelIter
, pointing to the previous row in the model. The iter is owned by self, do not free it.- Return type:
Returns a
Dee.ModelIter
that points to the previous position in the model.
- register_tag(tag_destroy)¶
- Parameters:
tag_destroy (
GLib.DestroyNotify
) – Function called when a tagged row is removed from the model. This function will also be called on all tagged rows when the model is finalized.- Returns:
A
Dee.ModelTag
handle that you can use to set and get tags with- Return type:
Register a new tag on a
Dee.Model
. A tag is an extra value attached to a given row on a model. The tags are invisible to all that doesn’t have the tag handle returned by this method.Dee.Model
implementations must ensure thatDee.Model.get_tag
() is an O(1) operation.Tags can be very useful in associating some extra data to a row in a model and have that automatically synced when the model changes. If you’re writing a tiled view for a model you might want to tag each row with the tile widget for that row. That way you have very convenient access to the tile widget given any row in the model.
The private nature of tags and the fact that you can store arbitrary pointers and binary data in them also means that they are not serialized if you utilize a model implementation that exposes the
Dee.Serializable
interface.
- register_vardict_schema(column, schemas)¶
- Parameters:
Register schema for fields in a model containing column with variant dictionary schema (‘a{sv}’). The keys registered with this function can be later used with dee_model_build_named_row() function, as well as
Dee.Model.get_value_by_name
(). Note that it is possible to register the same field name for multiple columns, in which case you need to use fully-qualified “column_name::field” name in the calls to dee_model_build_named_row() andDee.Model.get_field_schema
().
- remove(iter)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
pointing to the row to remove
Removes the row at the given position from the model.
- set_column_names_full(column_names)¶
-
Set column names used by self. This method must be called exactly once, but only after setting a schema of the model. Note that some constructors will do this for you.
- set_row(iter, row_members)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
row_members ([
GLib.Variant
]) – And array ofGLib.Variant
s with type signature matching those from the model schema. If any of the variants have floating references these will be consumed
Sets all columns in the row iter points to, to those found in row_members. The variants in row_members must match the types defined in the model’s schema.
- set_schema_full(column_schemas)¶
- Parameters:
column_schemas ([
str
]) – A list ofGLib.Variant
type strings terminated by aNone
Set the
GLib.Variant
types and the number of columns used by self. This method must be called exactly once before using self. Note that some constructors will do this for you.
- set_tag(iter, tag, value)¶
- Parameters:
iter (
Dee.ModelIter
) – The row to set the tag ontag (
Dee.ModelTag
) – The tag handle for the tag as obtained fromDee.Model.register_tag
()value (
object
orNone
) – The value to set for tag. Note thatNone
represents an unset tag
Set a tag on a row in a model. This function is guaranteed to be O(1). See also
Dee.Model.register_tag
().If tag is already set on this row the existing tag value will be destroyed with the
GLib.DestroyNotify
passed to theDee.Model.register_tag
().
- set_value(iter, column, value)¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – column number to set the valuevalue (
GLib.Variant
) – New value for cell. If value is a floating reference the model will assume ownership of the variant
Sets the data in column for the row iter points to, to value. The type of value must be convertible to the type of the column.
When this method call completes the model will emit
::row-changed
. You can edit the model in place without triggering the change signals by calling dee_model_set_value_silently().
- do_append_row(row_members) virtual¶
- Parameters:
row_members ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. If any of the variants have floating references they will be consumed- Returns:
A
Dee.ModelIter
pointing to the new row- Return type:
Like dee_model_append() but intended for language bindings or situations where you work with models on a meta level and may not have a prior knowledge of the column schemas of the models. See also dee_model_build_row().
- do_begin_changeset() virtual¶
Notify listeners that the model is about to be changed, which means that multiple row additions / changes / removals will follow. The default implementation of this method will emit the
::changeset-started
signal.It is not stricly necessary to enclose every change to a model in a
Dee.Model.begin_changeset
() andDee.Model.end_changeset
() calls, but doing so is highly recommended and allows implementing various optimizations.The usual way to perform multiple changes to a model is as follows:
void update_model (DeeModel *model) { GVariant **added_row_data1 = ...; GVariant **added_row_data2 = ...; dee_model_begin_changeset (model); dee_model_remove (model, dee_model_get_first_iter (model)); dee_model_append_row (model, added_row_data1); dee_model_append_row (model, added_row_data2); dee_model_end_changeset (model); }
- do_changeset_finished() virtual¶
- do_changeset_started() virtual¶
- do_clear() virtual¶
Removes all rows in the model. Signals are emitted for each row in the model
- do_end_changeset() virtual¶
Notify listeners that all changes have been committed to the model. The default implementation of this method will emit the
::changeset-finished
signal.See also
Dee.Model.begin_changeset
().
- do_find_row_sorted(row_spec, cmp_func, *user_data) virtual¶
- Parameters:
row_spec ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. No references will be taken on the variants.cmp_func (
Dee.CompareRowFunc
) – Callback used for comparison or rowsuser_data (
object
orNone
) – Arbitrary pointer passed to cmp_func during search
- Returns:
If out_was_found is set to
True
then aDee.ModelIter
pointing to the last matching row. If it isFalse
then the iter pointing to the row just after where row_spec_would have been inserted.- Return type:
(
Dee.ModelIter
, out_was_found:bool
)
Finds a row in self according to the sorting specified by cmp_func. This method will assume that self is already sorted by cmp_func.
If you use this method for searching you should only use
Dee.Model.insert_row_sorted
() to insert rows in the model.
- do_get_bool(iter, column) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a boolean from
- Returns:
if iter and column are valid, the boolean stored at column. Otherwise
False
- Return type:
- do_get_column_index(column_name) virtual¶
- Parameters:
column_name (
str
) – the column name to retrieve the index of- Returns:
0-based index of the column or -1 if column with this name wasn’t found
- Return type:
Get the column index of a column.
- do_get_column_names() virtual¶
- Returns:
A
None
-terminated array ofGLib.Variant
type strings. The length of the returned array is written to num_columns. The returned array should not be freed or modified. It is owned by the model.- Return type:
[
str
]
Get a
None
-terminated array of column names for the columns of self. These names can be used in calls to dee_model_build_named_row().
- do_get_column_schema(column) virtual¶
- Parameters:
column (
int
) – the column to get retrieve theGLib.Variant
type string of- Returns:
the
GLib.Variant
signature of the column at index column- Return type:
Get the
GLib.Variant
signature of a column
- do_get_double(iter, column) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a double from
- Returns:
if iter and column are valid, the double stored at column. Otherwise 0.
- Return type:
- do_get_field_schema(field_name) virtual¶
- Parameters:
field_name (
str
) – name of vardict field to get schema of- Returns:
the
GLib.Variant
signature for the field, orNone
if given field wasn’t registered withDee.Model.register_vardict_schema
().- out_column:
column index of the associated vardict
- Return type:
Get the
GLib.Variant
signature of field previously registered withDee.Model.register_vardict_schema
().
- do_get_first_iter() virtual¶
- Returns:
A
Dee.ModelIter
(owned by self, do not free it)- Return type:
Retrieves a
Dee.ModelIter
representing the first row in self.
- do_get_int32(iter, column) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a int from
- Returns:
if iter and column are valid, the int stored at column. Otherwise 0.
- Return type:
- do_get_int64(iter, column) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a int64 from
- Returns:
if iter and column are valid, the int64 stored at column. Otherwise 0.
- Return type:
- do_get_iter_at_row(row) virtual¶
- Parameters:
row (
int
) – position of the row to retrieve- Returns:
A new
Dee.ModelIter
, orNone
if row was out of bounds. The returned iter is owned by self, so do not free it.- Return type:
Retrieves a
Dee.ModelIter
representing the row at the given index.Note that this method does not have any performance guarantees. In particular it is not guaranteed to be O(1).
- do_get_last_iter() virtual¶
- Returns:
A
Dee.ModelIter
(owned by self, do not free it)- Return type:
Retrieves a
Dee.ModelIter
pointing right after the last row in self. This is refered to also the the end iter.As with other iters the end iter, in particular, is stable over inserts, changes, or removals.
- do_get_n_columns() virtual¶
- Returns:
the number of columns per row in self
- Return type:
Gets the number of columns in self
- do_get_n_rows() virtual¶
- Returns:
the number of rows in self
- Return type:
Gets the number of rows in self
- do_get_position(iter) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – The iter to get the position of- Returns:
The integer offset of iter in self
- Return type:
Get the numeric offset of iter into self. Note that this method is not guaranteed to be O(1).
- do_get_row(iter, out_row_members) virtual¶
- Parameters:
iter (
Dee.ModelIter
) –out_row_members (
GLib.Variant
) –
- Return type:
- do_get_schema() virtual¶
- Returns:
A
None
-terminated array ofGLib.Variant
type strings. The length of the returned array is written to num_columns. The returned array should not be freed or modified. It is owned by the model.- Return type:
[
str
]
Get a
None
-terminated array ofGLib.Variant
type strings that defines the required formats for the columns of self.
- do_get_string(iter, column) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a string from
- Returns:
if iter and column are valid, the string stored at column. Otherwise
None
.- Return type:
- do_get_tag(iter, tag) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – ADee.ModelIter
pointing to the row to get the tag fromtag (
Dee.ModelTag
) – The tag handle to retrieve the tag value for
- Returns:
Returns
None
if tag is unset otherwise the value of the tag as it was set withDee.Model.set_tag
().- Return type:
Look up a tag value for a given row in a model. This method is guaranteed to be O(1).
- do_get_uchar(iter, column) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a uchar from
- Returns:
if iter and column are valid, the uchar stored at column. Otherwise 0.
- Return type:
- do_get_uint32(iter, column) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a uint from
- Returns:
if iter and column are valid, the uint stored at column. Otherwise 0.
- Return type:
- do_get_uint64(iter, column) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – the column to retrieve a uint64 from
- Returns:
if iter and column are valid, the uint64 stored at column. Otherwise 0.
- Return type:
- do_get_value(iter, column) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
pointing to the row to inspectcolumn (
int
) – column number to retrieve the value from
- Returns:
A, guaranteed non-floating, reference to a
GLib.Variant
containing the row data. Free withGLib.Variant.unref
().- Return type:
- do_get_value_by_name(iter, column_name) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
pointing to the row to inspectcolumn_name (
str
) –
- Returns:
A, guaranteed non-floating, reference to a
GLib.Variant
containing the row data. Free withGLib.Variant.unref
().- Return type:
- do_get_vardict_schema(num_column) virtual¶
- Parameters:
num_column (
int
) –- Returns:
Hashtable containing a mapping from field names to schemas or
None
. Note that keys and values in the hashtable may be owned by the model, so you need to create a deep copy if you intend to keep the hashtable around.- Return type:
Get a schema for variant dictionary column previously registered using
Dee.Model.register_vardict_schema
().
- do_insert_row(pos, row_members) virtual¶
- Parameters:
pos (
int
) – The index to insert the row on. The existing row will be pushed down.row_members ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. If any of the variants have floating references they will be consumed.
- Returns:
A
Dee.ModelIter
pointing to the new row- Return type:
As dee_model_insert(), but intended for language bindings or situations where you work with models on a meta level and may not have a priori knowledge of the column schemas of the models. See also dee_model_build_row().
- do_insert_row_before(iter, row_members) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – An iter pointing to the row before which to insert the new onerow_members ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. If any of the variants have floating references they will be consumed.
- Returns:
A
Dee.ModelIter
pointing to the new row- Return type:
As dee_model_insert_before(), but intended for language bindings or situations where you work with models on a meta level and may not have a priori knowledge of the column schemas of the models. See also dee_model_build_row().
- do_insert_row_sorted(row_members, cmp_func, *user_data) virtual¶
- Parameters:
row_members ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. If any of the variants have floating references they will be consumed.cmp_func (
Dee.CompareRowFunc
) – Callback used for comparison or rowsuser_data (
object
orNone
) – Arbitrary pointer passed to cmp_func during search
- Returns:
A
Dee.ModelIter
pointing to the new row- Return type:
Inserts a row in self according to the sorting specified by cmp_func. If you use this method for insertion you should not use other methods as this method assumes the model to be already sorted by cmp_func.
- do_is_first(iter) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
- Returns:
True
if iter is the first iter in the model- Return type:
Checks if iter is the very first iter self.
- do_is_last(iter) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
- Returns:
True
if iter is the last iter in the model- Return type:
Whether iter is the end iter of self. Note that the end iter points right after the last valid row in self.
- do_next(iter) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
- Returns:
A
Dee.ModelIter
, pointing to the next row in the model. The iter is owned by self, do not free it.- Return type:
Returns a
Dee.ModelIter
that points to the next position in the model.
- do_prepend_row(row_members) virtual¶
- Parameters:
row_members ([
GLib.Variant
]) – An array ofGLib.Variants
with type signature matching those of the column schemas of self. If any of the variants have floating references they will be consumed.- Returns:
A
Dee.ModelIter
pointing to the new row- Return type:
Like dee_model_prepend() but intended for language bindings or situations where you work with models on a meta level and may not have a priori knowledge of the column schemas of the models. See also dee_model_build_row().
- do_prev(iter) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
- Returns:
A
Dee.ModelIter
, pointing to the previous row in the model. The iter is owned by self, do not free it.- Return type:
Returns a
Dee.ModelIter
that points to the previous position in the model.
- do_register_tag(tag_destroy) virtual¶
- Parameters:
tag_destroy (
GLib.DestroyNotify
) – Function called when a tagged row is removed from the model. This function will also be called on all tagged rows when the model is finalized.- Returns:
A
Dee.ModelTag
handle that you can use to set and get tags with- Return type:
Register a new tag on a
Dee.Model
. A tag is an extra value attached to a given row on a model. The tags are invisible to all that doesn’t have the tag handle returned by this method.Dee.Model
implementations must ensure thatDee.Model.get_tag
() is an O(1) operation.Tags can be very useful in associating some extra data to a row in a model and have that automatically synced when the model changes. If you’re writing a tiled view for a model you might want to tag each row with the tile widget for that row. That way you have very convenient access to the tile widget given any row in the model.
The private nature of tags and the fact that you can store arbitrary pointers and binary data in them also means that they are not serialized if you utilize a model implementation that exposes the
Dee.Serializable
interface.
- do_register_vardict_schema(num_column, schemas) virtual¶
- Parameters:
Register schema for fields in a model containing column with variant dictionary schema (‘a{sv}’). The keys registered with this function can be later used with dee_model_build_named_row() function, as well as
Dee.Model.get_value_by_name
(). Note that it is possible to register the same field name for multiple columns, in which case you need to use fully-qualified “column_name::field” name in the calls to dee_model_build_named_row() andDee.Model.get_field_schema
().
- do_remove(iter) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
pointing to the row to remove
Removes the row at the given position from the model.
- do_row_added(iter) virtual¶
- Parameters:
iter (
Dee.ModelIter
) –
- do_row_changed(iter) virtual¶
- Parameters:
iter (
Dee.ModelIter
) –
- do_row_removed(iter) virtual¶
- Parameters:
iter (
Dee.ModelIter
) –
- do_set_column_names_full(column_names) virtual¶
-
Set column names used by self. This method must be called exactly once, but only after setting a schema of the model. Note that some constructors will do this for you.
- do_set_row(iter, row_members) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
row_members ([
GLib.Variant
]) – And array ofGLib.Variant
s with type signature matching those from the model schema. If any of the variants have floating references these will be consumed
Sets all columns in the row iter points to, to those found in row_members. The variants in row_members must match the types defined in the model’s schema.
- do_set_schema_full(column_schemas) virtual¶
- Parameters:
column_schemas ([
str
]) – A list ofGLib.Variant
type strings terminated by aNone
Set the
GLib.Variant
types and the number of columns used by self. This method must be called exactly once before using self. Note that some constructors will do this for you.
- do_set_tag(iter, tag, value) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – The row to set the tag ontag (
Dee.ModelTag
) – The tag handle for the tag as obtained fromDee.Model.register_tag
()value (
object
orNone
) – The value to set for tag. Note thatNone
represents an unset tag
Set a tag on a row in a model. This function is guaranteed to be O(1). See also
Dee.Model.register_tag
().If tag is already set on this row the existing tag value will be destroyed with the
GLib.DestroyNotify
passed to theDee.Model.register_tag
().
- do_set_value(iter, column, value) virtual¶
- Parameters:
iter (
Dee.ModelIter
) – aDee.ModelIter
column (
int
) – column number to set the valuevalue (
GLib.Variant
) – New value for cell. If value is a floating reference the model will assume ownership of the variant
Sets the data in column for the row iter points to, to value. The type of value must be convertible to the type of the column.
When this method call completes the model will emit
::row-changed
. You can edit the model in place without triggering the change signals by calling dee_model_set_value_silently().
Signal Details¶
- Dee.Model.signals.changeset_finished(model)¶
- Signal Name:
changeset-finished
- Flags:
- Parameters:
model (
Dee.Model
) – The object which received the signal
Connect to this signal to be notified when a changeset that can contain multiple row additions / changes / removals has been committed to the model.
- Dee.Model.signals.changeset_started(model)¶
- Signal Name:
changeset-started
- Flags:
- Parameters:
model (
Dee.Model
) – The object which received the signal
Connect to this signal to be notified when a changeset that can contain multiple row additions / changes / removals is about to be committed to the model. Note that not all model implementations use the changeset approach and you might still get a row change signal outside of changeset-started and changeset-finished signals. It also isn’t guaranteed that a changeset would always be non-empty.
- Dee.Model.signals.row_added(model, iter)¶
- Signal Name:
row-added
- Flags:
- Parameters:
model (
Dee.Model
) – The object which received the signaliter (
Dee.ModelIter
) – aDee.ModelIter
pointing to the newly added row
Connect to this signal to be notified when a row is added to self.
- Dee.Model.signals.row_changed(model, iter)¶
- Signal Name:
row-changed
- Flags:
- Parameters:
model (
Dee.Model
) – The object which received the signaliter (
Dee.ModelIter
) – aDee.ModelIter
pointing to the changed row
Connect to this signal to be notified when a row is changed.
- Dee.Model.signals.row_removed(model, iter)¶
- Signal Name:
row-removed
- Flags:
- Parameters:
model (
Dee.Model
) – The object which received the signaliter (
Dee.ModelIter
) – aDee.ModelIter
pointing to the removed row
Connect to this signal to be notified when a row is removed from self. The row is still valid while the signal is being emitted.