filterlistmodel: Look at type of change

This way we can avoid refiltering most of an already filtered list when
the change becomes more strict.
This commit is contained in:
Benjamin Otte 2020-06-30 04:18:59 +02:00
parent b64eb6ca13
commit 66fa9380b5

View File

@ -476,7 +476,7 @@ gtk_filter_list_model_refilter (GtkFilterListModel *self,
case GTK_FILTER_MATCH_SOME:
{
GtkBitset *old;
GtkBitset *old, *pending;
if (self->matches == NULL)
{
@ -489,9 +489,27 @@ gtk_filter_list_model_refilter (GtkFilterListModel *self,
{
old = self->matches;
}
self->matches = gtk_bitset_new_empty ();
self->strictness = new_strictness;
gtk_filter_list_model_start_filtering (self, gtk_bitset_new_range (0, g_list_model_get_n_items (self->model)));
switch (change)
{
default:
g_assert_not_reached ();
G_GNUC_FALLTHROUGH;
case GTK_FILTER_CHANGE_DIFFERENT:
self->matches = gtk_bitset_new_empty ();
pending = gtk_bitset_new_range (0, g_list_model_get_n_items (self->model));
break;
case GTK_FILTER_CHANGE_LESS_STRICT:
self->matches = gtk_bitset_copy (old);
pending = gtk_bitset_new_range (0, g_list_model_get_n_items (self->model));
gtk_bitset_subtract (pending, self->matches);
break;
case GTK_FILTER_CHANGE_MORE_STRICT:
self->matches = gtk_bitset_new_empty ();
pending = gtk_bitset_copy (old);
break;
}
gtk_filter_list_model_start_filtering (self, pending);
gtk_filter_list_model_emit_items_changed_for_changes (self, old);
}