diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-08-08 07:31:02 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-08-08 07:31:02 +0800 |
commit | 7b0cfb30ea6b8a8f81f927e1ed3034145e5143c2 (patch) | |
tree | 98ea889230fe889e1a088d8c5ea5fd3afc9da3dc /widgets/table/e-tree-selection-model.c | |
parent | e9adce66e5890eff3474b3927f2fb31ca4b4fd18 (diff) | |
download | gsoc2013-evolution-7b0cfb30ea6b8a8f81f927e1ed3034145e5143c2.tar.gz gsoc2013-evolution-7b0cfb30ea6b8a8f81f927e1ed3034145e5143c2.tar.zst gsoc2013-evolution-7b0cfb30ea6b8a8f81f927e1ed3034145e5143c2.zip |
Implemented this function. Fixes Ximian bug #5353.
2001-08-07 Christopher James Lahey <clahey@ximian.com>
* e-tree-selection-model.c (etsm_selected_count): Implemented this
function. Fixes Ximian bug #5353.
svn path=/trunk/; revision=11753
Diffstat (limited to 'widgets/table/e-tree-selection-model.c')
-rw-r--r-- | widgets/table/e-tree-selection-model.c | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/widgets/table/e-tree-selection-model.c b/widgets/table/e-tree-selection-model.c index 375003f35d..3c06515cc9 100644 --- a/widgets/table/e-tree-selection-model.c +++ b/widgets/table/e-tree-selection-model.c @@ -797,7 +797,49 @@ etsm_clear(ESelectionModel *selection) e_selection_model_cursor_changed(E_SELECTION_MODEL(etsm), -1, -1); } -#if 0 +/* Standard functions */ +static void +etsm_selected_count_all_recurse (ETreeSelectionModel *etsm, + ETreePath path, + int *count) +{ + ETreePath child; + + (*count) ++; + + child = e_tree_model_node_get_first_child(E_TREE_MODEL(etsm->priv->model), path); + for ( ; child; child = e_tree_model_node_get_next(E_TREE_MODEL(etsm->priv->model), child)) + if (child) + etsm_selected_count_all_recurse (etsm, child, count); +} + +static void +etsm_selected_count_recurse (ETreeSelectionModel *etsm, + ETreeSelectionModelNode *selection_node, + ETreePath path, + int *count) +{ + if (selection_node->all_children_selected) { + if (path) + etsm_selected_count_all_recurse(etsm, path, count); + return; + } + if (!selection_node->any_children_selected) + return; + + if (selection_node->selected) { + (*count) ++; + } + + if (selection_node->children) { + ETreePath child = e_tree_model_node_get_first_child(E_TREE_MODEL(etsm->priv->model), path); + int i; + for (i = 0; i < selection_node->num_children; i++, child = e_tree_model_node_get_next(E_TREE_MODEL(etsm->priv->model), child)) + if (selection_node->children[i]) + etsm_selected_count_recurse (etsm, selection_node->children[i], child, count); + } +} + /** * e_selection_model_selected_count * @selection: #ESelectionModel to count @@ -810,10 +852,14 @@ static gint etsm_selected_count (ESelectionModel *selection) { ETreeSelectionModel *etsm = E_TREE_SELECTION_MODEL(selection); - - return g_hash_table_size(etsm->priv->data); + int count = 0; + if (etsm->priv->root) { + ETreePath model_root; + model_root = e_tree_model_get_root(etsm->priv->model); + etsm_selected_count_recurse(etsm, etsm->priv->root, model_root, &count); + } + return count; } -#endif /** * e_selection_model_select_all @@ -1212,9 +1258,7 @@ e_tree_selection_model_class_init (ETreeSelectionModelClass *klass) esm_class->is_row_selected = etsm_is_row_selected ; esm_class->foreach = etsm_foreach ; esm_class->clear = etsm_clear ; -#if 0 esm_class->selected_count = etsm_selected_count ; -#endif esm_class->select_all = etsm_select_all ; esm_class->invert_selection = etsm_invert_selection ; esm_class->row_count = etsm_row_count ; |