Emit row-has-child-toggled when a first node becomes visible in a level

If we have a level with zero visible nodes and the first node becomes
visible in that level, then parent has just become a "real" parent node.
In such a case we need to emit row-has-child-toggled.  This only applies
to non-root levels that have a parent.  This problem was also found when
writing the unit test, the respective cases in the unit test have been
corrected.

This fixes bugs:
 Bug 372010 - Filtering not working properly
 Bug 525965 - Filtered and sorted GtkTreeView is missing rows
This commit is contained in:
Kristian Rietveld 2009-09-05 16:41:09 +02:00
parent 0c4f29e857
commit f483c5b7d6
2 changed files with 20 additions and 2 deletions

View File

@ -1336,6 +1336,21 @@ gtk_tree_model_filter_row_changed (GtkTreeModel *c_model,
gtk_tree_model_row_inserted (GTK_TREE_MODEL (filter), path, &iter);
if (level->parent_level && level->visible_nodes == 1)
{
/* We know that this is the first visible node in this level, so
* we need to emit row-has-child-toggled on the parent. This
* does not apply to the root level.
*/
gtk_tree_path_up (path);
gtk_tree_model_get_iter (GTK_TREE_MODEL (filter), &iter, path);
gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (filter),
path,
&iter);
}
if (gtk_tree_model_iter_children (c_model, &children, c_iter))
gtk_tree_model_filter_update_children (filter, level, elt);
}

View File

@ -856,8 +856,9 @@ filled_hide_child_levels (FilterTest *fixture,
check_level_length (fixture->filter, "0:3", LEVEL_LENGTH);
check_level_length (fixture->filter, "0:4", 0);
/* FIXME: We are missing a row-has-child-toggled signal for path "0:4" */
signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:0");
/* Once 0:4:0 got inserted, 0:4 became a parent */
signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4");
signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4:0");
signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:1");
signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4:1");
@ -1048,11 +1049,12 @@ filled_vroot_hide_child_levels (FilterTest *fixture,
check_level_length (fixture->filter, "0:3", LEVEL_LENGTH);
check_level_length (fixture->filter, "0:4", 0);
/* FIXME: We are missing a row-has-child-toggled signal for path "0:4" */
/* FIXME: Inconsistency! For the non-vroot case we also receive two
* row-has-child-toggled signals here.
*/
signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:0");
/* Once 0:4:0 got inserted, 0:4 became a parent */
signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4");
signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:1");
set_path_visibility (fixture, "2:0:4:2", TRUE);
set_path_visibility (fixture, "2:0:4:4", TRUE);
@ -1080,6 +1082,7 @@ empty_show_nodes (FilterTest *fixture,
check_level_length (fixture->filter, "0", 0);
signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:0");
signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:0");
set_path_visibility (fixture, "3:2", TRUE);
check_filter_model (fixture);