Logo Search packages:      
Sourcecode: pan version File versions

PanTreeStore Struct Reference

#include <pan-tree.h>

List of all members.

Detailed Description

PanTreeStore is a GtkTreeModel implementation with a primary goal of fast, memory-efficient handling of very large and/or flat trees. It has no Pan dependencies and can be reused by copying pan-tree.{h,cc}.

Enhancements, as compared to GtkTreeStore:

1. Rows are constructed by the client, then passed into the tree. This helps lower memory use by having a single Row structure rather than an array of GValues. On an x86 architecture, sizeof(int)==4 and sizeof(GValue)==20. (Plus we avoid GtkTreeStore's extra hit of using linked lists to join the cells in a row,

2. Population before insertion is also much faster because there are no extra calls to tree_store_set_value(), no GObject type checking, no extra GtkTreePaths built for row-changed, and most importantly, no row-changed signals emitted at all.

3. Rows can be inserted in batches, which reduces some overhead of redundant per-call GObject type checking and GtkTreePath creation. for the row-inserted signal handlers.

4. Rows can be inserted into the tree sorted so that there's no separate sorting step.

5. GtkTreePath creation is practically free compared with GtkTreeStore: each child knows its child index to be used in the tree path. GtkTreeStore holds a list of children which must be walked in order to find the child's index, which is expensive on large/flat trees.

6. Entire subtrees can be reparented in a single call.


_ Sorting is not triggered when a row changes. When you're done with a batch of changes, call sort() manually.

_ Would have a better chance of being used outside of Pan if it had a C API.

Definition at line 90 of file pan-tree.h.

Public Types

typedef std::map< Row *, rows_t > parent_to_children_t
typedef std::vector< Row * > rows_t

Public Member Functions

void append (Row *parent, Row *child)
void append (Row *parent, const rows_t &children)
void clear ()
size_t get_depth (const Row *row) const
GtkTreeIter get_iter (const Row *)
void get_iter (const Row *, GtkTreeIter *setme)
bool get_parent (GtkTreeIter *setme_parent, GtkTreeIter *child)
GtkTreePath * get_path (const Row *row) const
GtkTreePath * get_path (GtkTreeIter *iter)
const Rowget_row (const GtkTreeIter *iter) const
Rowget_row (GtkTreeIter *iter)
void get_sort_column_id (int &column, GtkSortType &type) const
void insert (Row *parent, const rows_t &children, int pos)
void insert_sorted (Row *parent, const rows_t &children)
void insert_sorted (const parent_to_children_t &)
bool is_in_tree (Row *row) const
bool is_root (const GtkTreeIter *it) const
bool is_sorted () const
void pause_sorting ()
void postfix_walk (WalkFunctor &walk_functor, GtkTreeIter *top=0, bool need_path=false)
void prefix_walk (WalkFunctor &walk_functor, GtkTreeIter *top=0, bool need_path=false)
void remove (const rows_t &rows)
void reparent (const parent_to_children_t &parents_to_children)
void reparent (Row *parent_or_null_for_root, Row *child, int pos=INT_MAX)
void resume_sorting ()
void row_changed (Row *row)
void row_changed (GtkTreeIter *iter)
void set_row_dispose (RowDispose *r)
void walk (WalkFunctor &walk, bool need_path=false)

Static Public Member Functions

static GType get_type ()
static PanTreeStorenew_tree (int n_cols,...)

Public Attributes

GObject parent

Private Types

enum  { SORT, FLIP }
typedef std::map< int, SortInfocolumn_sort_info_t

Private Member Functions

void remove (const rows_t &rows, bool delete_rows)
void remove_siblings (const rows_t &siblings, bool delete_rows)
void renumber_children (Row *parent, int child_lo=0, int child_hi=INT_MAX)
void set_iter (GtkTreeIter *, const Row *)
void sort (int mode=SORT)
void sort_children (SortInfo &, Row *parent, bool recurse, int mode)
void walk (int walk_mode, WalkFunctor &walker, GtkTreeIter *top, bool need_path)
bool walk_helper (int walk_mode, Row *top_row, GtkTreePath *top_path_or_null, WalkFunctor &walk_functor)

Static Private Member Functions

static void invalidate_iter (GtkTreeIter *)
static GType model_get_column_type (GtkTreeModel *, int)
static GtkTreeModelFlags model_get_flags (GtkTreeModel *)
static gboolean model_get_iter (GtkTreeModel *, GtkTreeIter *, GtkTreePath *)
static gint model_get_n_columns (GtkTreeModel *)
static GtkTreePath * model_get_path (GtkTreeModel *, GtkTreeIter *)
static void model_get_value (GtkTreeModel *, GtkTreeIter *, gint, GValue *)
static gboolean model_iter_children (GtkTreeModel *, GtkTreeIter *, GtkTreeIter *)
static gboolean model_iter_has_child (GtkTreeModel *, GtkTreeIter *)
static gint model_iter_n_children (GtkTreeModel *, GtkTreeIter *)
static gboolean model_iter_next (GtkTreeModel *, GtkTreeIter *)
static gboolean model_iter_nth_child (GtkTreeModel *, GtkTreeIter *, GtkTreeIter *, gint)
static gboolean model_iter_parent (GtkTreeModel *, GtkTreeIter *, GtkTreeIter *)
static void pan_tree_class_init (PanTreeStoreClass *)
static void pan_tree_dispose (GObject *)
static void pan_tree_finalize (GObject *)
static void pan_tree_init (PanTreeStore *)
static void pan_tree_model_init (GtkTreeModelIface *)
static void pan_tree_sortable_init (GtkTreeSortableIface *)
static int row_compare_func (gconstpointer, gconstpointer, gpointer)
static gboolean sortable_get_sort_column_id (GtkTreeSortable *, gint *, GtkSortType *)
static gboolean sortable_has_default_sort_func (GtkTreeSortable *)
static gboolean sortable_has_sort_func (GtkTreeSortable *, gint)
static void sortable_set_default_sort_func (GtkTreeSortable *, GtkTreeIterCompareFunc, gpointer, GtkDestroyNotify)
static void sortable_set_sort_column_id (GtkTreeSortable *, gint, GtkSortType)
static void sortable_set_sort_func (GtkTreeSortable *, gint, GtkTreeIterCompareFunc, gpointer, GtkDestroyNotify)

Private Attributes

std::vector< GType > * column_types
int n_columns
GtkSortType order
RowDispose * row_dispose
int sort_column_id
int sort_paused
int stamp


struct  ClearWalker
struct  FreeRowWalker
struct  ReparentWalker
struct  Row
struct  RowCompareByChildPos
struct  RowCompareByColumn
struct  RowCompareByDepth
struct  RowDispose
struct  SortData
struct  SortInfo
struct  SortRowInfo
struct  WalkFunctor

The documentation for this struct was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index