[model] Rework Model behaviour with a filter
authorEmmanuele Bassi <ebassi@linux.intel.com>
Wed, 29 Apr 2009 14:26:05 +0000 (15:26 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Wed, 29 Apr 2009 14:26:05 +0000 (15:26 +0100)
commit01d172293ce3c6dd8576319657ab316c479e6acc
treec5bd49556b01fc5f71fbe6538a090c7c359ca540
parent44fefa2afec991d9b60ae5694e511617b1369d1f
[model] Rework Model behaviour with a filter

Currently ClutterModel::get_iter_at_row() ignores whether we have
a filter in place. This also extends to the get_n_rows() method.

The more consistent, more intuitive and surely more correct way to
handle a Model with a filter in place is to take into account the
presence of the filter itself -- that is:

  - get_n_rows() should take into account the filter and return the
    number of *filtered* rows

  - get_iter_at_row() should also take the filter into account and
    get the first non-filtered row

These two changes make the ClutterModel with a filter function
behave like a subset of the original Model without a filter in
place.

For instance, given a model with three rows:

  - [row 0]     <does not match filter>
  - [row 1]     <matches filter>
  - [row 2]     <matches filter>
  - [row 3]     <does not match filter>

The get_n_rows() method will return "2", since only two rows will
match the filter; the get_first_iter() method will ask for the
zero-eth row, which will return an iterator pointing to the contents
of row 1 (but the :row property of the iterator will be set to 0);
the get_last_iter() method will ask for the last row, which will
return an iterator pointing to the contents of row 2 (but the :row
property of the iterator will be set to 1).

This changes will hopefully make the Model API more consistent
in its usage whether there is a filter in place or not.
clutter/clutter-list-model.c
clutter/clutter-model.c
clutter/clutter-model.h