EVirtualTreeModel

EVirtualTreeModel — Interface for providing row data to EVirtualTree

Functions

Signals

void after-rebuild Run Last
void before-rebuild Run Last
void row-count-changed Run Last
void rows-changed Run Last
void rows-inserted Run Last
void rows-removed Run Last

Types and Values

Object Hierarchy

    GInterface
    ╰── EVirtualTreeModel

Prerequisites

EVirtualTreeModel requires GObject.

Includes

#include <e-util/e-util.h>

Description

EVirtualTreeModel is an interface that supplies row objects and tree-structure metadata to an EVirtualTree widget. Implementors provide the total row count, row retrieval, depth/expand state, and an opaque key system used for selection tracking.

The key system is defined by two vfuncs:

  • get_row_key() returns a transfer-none pointer that uniquely identifies a row object. The pointer must remain valid while the row object is alive.

  • get_key_type() returns an EVirtualTreeKeyType struct that supplies hash, equal, copy, and free functions for the keys. The defaults use pointer identity (g_direct_hash / g_direct_equal, no copy/free).

Models notify the tree of data changes via e_virtual_tree_model_emit_before_rebuild(), e_virtual_tree_model_emit_after_rebuild(), e_virtual_tree_model_emit_rows_changed(), e_virtual_tree_model_emit_rows_inserted(), e_virtual_tree_model_emit_rows_removed(), and e_virtual_tree_model_emit_row_count_changed().

Functions

e_virtual_tree_model_get_row_count ()

guint
e_virtual_tree_model_get_row_count (EVirtualTreeModel *self);

Returns the total number of visible rows in the model.

Parameters

self

an EVirtualTreeModel

 

Returns

the row count

Since: 3.64


e_virtual_tree_model_dup_rows ()

GPtrArray *
e_virtual_tree_model_dup_rows (EVirtualTreeModel *self,
                               guint first_row,
                               guint last_row,
                               gboolean include_collapsed);

Returns a GPtrArray of GObject row objects for the given range. Each element has its reference count incremented; the caller must release each element with g_object_unref() and the array with g_ptr_array_unref().

Parameters

self

an EVirtualTreeModel

 

first_row

zero-based index of the first row to retrieve

 

last_row

zero-based index of the last row to retrieve (inclusive)

 

include_collapsed

whether to include rows inside collapsed nodes

 

Returns

the rows.

[transfer container][element-type GObject]

Since: 3.64


e_virtual_tree_model_dup_row ()

GObject *
e_virtual_tree_model_dup_row (EVirtualTreeModel *self,
                              guint row_index);

Returns the row object at row_index with an added reference. The caller must release the reference with g_object_unref() when done.

The default implementation delegates to e_virtual_tree_model_dup_rows().

Parameters

self

an EVirtualTreeModel

 

row_index

zero-based row index

 

Returns

the row object, or NULL.

[transfer full][nullable]

Since: 3.64


e_virtual_tree_model_get_depth ()

guint
e_virtual_tree_model_get_depth (EVirtualTreeModel *self,
                                GObject *row_object);

Returns the nesting depth of row_object . Top-level rows have depth 0.

Parameters

self

an EVirtualTreeModel

 

row_object

a row GObject

 

Returns

the depth

Since: 3.64


e_virtual_tree_model_is_expandable ()

gboolean
e_virtual_tree_model_is_expandable (EVirtualTreeModel *self,
                                    GObject *row_object);

Returns whether row_object can be expanded to show children.

Parameters

self

an EVirtualTreeModel

 

row_object

a row GObject

 

Returns

TRUE if the row is expandable

Since: 3.64


e_virtual_tree_model_get_expanded ()

gboolean
e_virtual_tree_model_get_expanded (EVirtualTreeModel *self,
                                   GObject *row_object);

Returns whether row_object is currently expanded.

Parameters

self

an EVirtualTreeModel

 

row_object

a row GObject

 

Returns

TRUE if the row is expanded

Since: 3.64


e_virtual_tree_model_set_expanded ()

void
e_virtual_tree_model_set_expanded (EVirtualTreeModel *self,
                                   GObject *row_object,
                                   gboolean expanded);

Sets the expanded state of row_object .

Parameters

self

an EVirtualTreeModel

 

row_object

a row GObject

 

expanded

TRUE to expand, FALSE to collapse

 

Since: 3.64


e_virtual_tree_model_get_row_key ()

gconstpointer
e_virtual_tree_model_get_row_key (EVirtualTreeModel *self,
                                  GObject *row_object);

Returns an opaque key that uniquely identifies row_object for selection tracking. The returned pointer is owned by row_object and remains valid only while row_object is alive; callers must not free it.

The default implementation returns row_object itself (pointer identity).

Parameters

self

an EVirtualTreeModel

 

row_object

a row GObject

 

Returns

the key, or NULL.

[transfer none][nullable]

Since: 3.64


e_virtual_tree_model_get_key_type ()

EVirtualTreeKeyType
e_virtual_tree_model_get_key_type (EVirtualTreeModel *self);

Returns an EVirtualTreeKeyType describing how to hash, compare, copy, and free the keys returned by e_virtual_tree_model_get_row_key().

The default returns g_direct_hash/g_direct_equal with NULL copy and free functions (pointer identity, no allocation).

Parameters

self

an EVirtualTreeModel

 

Returns

the key type descriptor

Since: 3.64


e_virtual_tree_model_find_row_by_key ()

guint
e_virtual_tree_model_find_row_by_key (EVirtualTreeModel *self,
                                      gconstpointer key);

Searches the model for a row whose key (as returned by e_virtual_tree_model_get_row_key()) equals key according to the model's key type equal function.

The default implementation performs a linear scan.

Parameters

self

an EVirtualTreeModel

 

key

the key to search for

 

Returns

the row index, or G_MAXUINT if not found

Since: 3.64


e_virtual_tree_model_emit_before_rebuild ()

void
e_virtual_tree_model_emit_before_rebuild
                               (EVirtualTreeModel *self);

Emits the “before-rebuild” signal. Model implementations should call this before bulk data changes that invalidate all existing row indices. Call e_virtual_tree_model_emit_after_rebuild() when done.

Parameters

self

an EVirtualTreeModel

 

Since: 3.64


e_virtual_tree_model_emit_after_rebuild ()

void
e_virtual_tree_model_emit_after_rebuild
                               (EVirtualTreeModel *self);

Emits the “after-rebuild” signal. Finishes a rebuild previously announced with e_virtual_tree_model_emit_before_rebuild(), so the tree can re-query row data.

Parameters

self

an EVirtualTreeModel

 

Since: 3.64


e_virtual_tree_model_emit_rows_changed ()

void
e_virtual_tree_model_emit_rows_changed
                               (EVirtualTreeModel *self,
                                guint first_row,
                                guint last_row);

Emits the “rows-changed” signal to notify the tree that existing rows in the range [first_row , last_row ] have new data and need to be re-rendered.

Parameters

self

an EVirtualTreeModel

 

first_row

zero-based index of the first changed row

 

last_row

zero-based index of the last changed row (inclusive)

 

Since: 3.64


e_virtual_tree_model_emit_rows_inserted ()

void
e_virtual_tree_model_emit_rows_inserted
                               (EVirtualTreeModel *self,
                                guint first_row,
                                guint last_row);

Emits the “rows-inserted” signal to notify the tree that new rows have been inserted at indices [first_row , last_row ].

Parameters

self

an EVirtualTreeModel

 

first_row

zero-based index of the first inserted row

 

last_row

zero-based index of the last inserted row (inclusive)

 

Since: 3.64


e_virtual_tree_model_emit_rows_removed ()

void
e_virtual_tree_model_emit_rows_removed
                               (EVirtualTreeModel *self,
                                guint first_row,
                                guint last_row);

Emits the “rows-removed” signal to notify the tree that rows at indices [first_row , last_row ] have been removed.

Parameters

self

an EVirtualTreeModel

 

first_row

zero-based index of the first removed row

 

last_row

zero-based index of the last removed row (inclusive)

 

Since: 3.64


e_virtual_tree_model_emit_row_count_changed ()

void
e_virtual_tree_model_emit_row_count_changed
                               (EVirtualTreeModel *self);

Emits the “row-count-changed” signal to notify the tree that the total number of rows has changed.

Parameters

self

an EVirtualTreeModel

 

Since: 3.64


e_virtual_tree_model_notify_row_changed ()

void
e_virtual_tree_model_notify_row_changed
                               (EVirtualTreeModel *self,
                                gconstpointer key,
                                gboolean is_added);

Notifies the tree that a single row identified by key was added or changed, without the caller having to know its current row index. The index is resolved via e_virtual_tree_model_find_row_by_key() at the time the notification is actually emitted, which is throttled to a few times per second per model instance, so bursts of many calls (e.g. from a bulk data load) coalesce instead of each one triggering a full tree refill.

Parameters

self

an EVirtualTreeModel

 

key

the row key of the added/changed row, as returned by e_virtual_tree_model_get_row_key()

 

is_added

TRUE when the row was newly added, FALSE when an existing row changed

 

Since: 3.64

Types and Values

E_TYPE_VIRTUAL_TREE_MODEL

#define E_TYPE_VIRTUAL_TREE_MODEL (e_virtual_tree_model_get_type ())

EVirtualTreeKeyType

typedef struct {
	GHashFunc      hash_func;
	GEqualFunc     equal_func;
	GBoxedCopyFunc copy_func;
	GDestroyNotify free_func;
} EVirtualTreeKeyType;

struct EVirtualTreeModelInterface

struct EVirtualTreeModelInterface {
	GTypeInterface parent_interface;

	guint		(*get_row_count) (EVirtualTreeModel *self);

	GPtrArray * (*dup_rows)		(EVirtualTreeModel *self,
						 guint first_row,
						 guint last_row,
						 gboolean include_collapsed);

	GObject * (*dup_row)		(EVirtualTreeModel *self,
						 guint row_index);

	guint		(*get_depth)		(EVirtualTreeModel *self,
						 GObject *row_object);
	gboolean (*is_expandable) (EVirtualTreeModel *self,
						 GObject *row_object);
	gboolean (*get_expanded)		(EVirtualTreeModel *self,
						 GObject *row_object);
	void		(*set_expanded)		(EVirtualTreeModel *self,
						 GObject *row_object,
						 gboolean expanded);

	gconstpointer (*get_row_key)		(EVirtualTreeModel *self,
						 GObject *row_object);
	EVirtualTreeKeyType (*get_key_type) (EVirtualTreeModel *self);

	guint		(*find_row_by_key) (EVirtualTreeModel *self,
						 gconstpointer key);

	/* Signals */
	void		(*before_rebuild) (EVirtualTreeModel *self);
	void		(*after_rebuild) (EVirtualTreeModel *self);
	void		(*rows_changed)		(EVirtualTreeModel *self,
						 guint first_row,
						 guint last_row);
	void		(*rows_inserted) (EVirtualTreeModel *self,
						 guint first_row,
						 guint last_row);
	void		(*rows_removed)		(EVirtualTreeModel *self,
						 guint first_row,
						 guint last_row);
	void		(*row_count_changed) (EVirtualTreeModel *self);
};

EVirtualTreeModel

typedef struct _EVirtualTreeModel EVirtualTreeModel;

Signal Details

The “after-rebuild” signal

void
user_function (EVirtualTreeModel *evirtualtreemodel,
               gpointer           user_data)

Flags: Run Last


The “before-rebuild” signal

void
user_function (EVirtualTreeModel *evirtualtreemodel,
               gpointer           user_data)

Flags: Run Last


The “row-count-changed” signal

void
user_function (EVirtualTreeModel *evirtualtreemodel,
               gpointer           user_data)

Flags: Run Last


The “rows-changed” signal

void
user_function (EVirtualTreeModel *evirtualtreemodel,
               guint              arg1,
               guint              arg2,
               gpointer           user_data)

Flags: Run Last


The “rows-inserted” signal

void
user_function (EVirtualTreeModel *evirtualtreemodel,
               guint              arg1,
               guint              arg2,
               gpointer           user_data)

Flags: Run Last


The “rows-removed” signal

void
user_function (EVirtualTreeModel *evirtualtreemodel,
               guint              arg1,
               guint              arg2,
               gpointer           user_data)

Flags: Run Last