Class FilterListModel

All Implemented Interfaces:
PointerInterface

public class FilterListModel extends Object
`GtkFilterListModel` is a list model that filters the elements of
the underlying model according to a `GtkFilter`.

It hides some elements from the other model according to
criteria given by a `GtkFilter`.

The model can be set up to do incremental searching, so that
filtering long lists doesn't block the UI. See
[method@Gtk.FilterListModel.set_incremental] for details.

https://docs.gtk.org/gtk4/class.FilterListModel.html

  • Constructor Details

    • FilterListModel

      public FilterListModel(PointerContainer pointer)
    • FilterListModel

      public FilterListModel(@Nullable ListModel model, @Nullable Filter filter)
      Creates a new `GtkFilterListModel` that will filter @model using the given
      @filter.
      Parameters:
      model - the model to sort
      filter - filter
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getFilter

      public Filter getFilter()
      Gets the `GtkFilter` currently set on @self.
      Returns:
      The filter currently in use
    • getIncremental

      public boolean getIncremental()
      Returns whether incremental filtering is enabled.

      See [method@Gtk.FilterListModel.set_incremental].
      Returns:
      %TRUE if incremental filtering is enabled
    • getModel

      public ListModel getModel()
      Gets the model currently filtered or %NULL if none.
      Returns:
      The model that gets filtered
    • getPending

      public int getPending()
      Returns the number of items that have not been filtered yet.

      You can use this value to check if @self is busy filtering by
      comparing the return value to 0 or you can compute the percentage
      of the filter remaining by dividing the return value by the total
      number of items in the underlying model:

      ```c
      pending = gtk_filter_list_model_get_pending (self);
      model = gtk_filter_list_model_get_model (self);
      percentage = pending / (double) g_list_model_get_n_items (model);
      ```

      If no filter operation is ongoing - in particular when
      [property@Gtk.FilterListModel:incremental] is %FALSE - this
      function returns 0.
      Returns:
      The number of items not yet filtered
    • setFilter

      public void setFilter(@Nullable Filter filter)
      Sets the filter used to filter items.
      Parameters:
      filter - filter to use
    • setIncremental

      public void setIncremental(boolean incremental)
      Sets the filter model to do an incremental sort.

      When incremental filtering is enabled, the `GtkFilterListModel` will not
      run filters immediately, but will instead queue an idle handler that
      incrementally filters the items and adds them to the list. This of course
      means that items are not instantly added to the list, but only appear
      incrementally.

      When your filter blocks the UI while filtering, you might consider
      turning this on. Depending on your model and filters, this may become
      interesting around 10,000 to 100,000 items.

      By default, incremental filtering is disabled.

      See [method@Gtk.FilterListModel.get_pending] for progress information
      about an ongoing incremental filtering operation.
      Parameters:
      incremental - %TRUE to enable incremental filtering
    • setModel

      public void setModel(@Nullable ListModel model)
      Sets the model to be filtered.

      Note that GTK makes no effort to ensure that @model conforms to
      the item type of @self. It assumes that the caller knows what they
      are doing and have set up an appropriate filter to ensure that item
      types match.
      Parameters:
      model - The model to be filtered
    • asListModel

      public ListModel asListModel()
      Implements interface ListModel. Call this to get access to interface functions.
      Returns:
      ListModel
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()