Class TreeListModel<T extends GObject>

All Implemented Interfaces:
Iterable<T>, Collection<T>, List<T>, SequencedCollection<T>, ListModel<T>, Proxy, ListModelJavaList<T>

@Generated("org.javagi.JavaGI") public class TreeListModel<T extends GObject> extends GObject implements ListModel<T>
A list model that can create child models on demand.
  • Constructor Details

    • TreeListModel

      public TreeListModel(MemorySegment address)
      Create a TreeListModel instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • TreeListModel

      public TreeListModel(ListModel root, boolean passthrough, boolean autoexpand, @Nullable TreeListModelCreateModelFunc createFunc)
      Creates a new empty GtkTreeListModel displaying root with all rows collapsed.
      Parameters:
      root - The GListModel to use as root
      passthrough - true to pass through items from the models
      autoexpand - true to set the autoexpand property and expand the root model
      createFunc - function to call to create the GListModel for the children of an item
    • TreeListModel

      public TreeListModel()
      Create a new TreeListModel.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the TreeListModel class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected TreeListModel asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • getAutoexpand

      public boolean getAutoexpand()

      Gets whether the model is set to automatically expand new rows that get added.

      This can be either rows added by changes to the underlying models or via TreeListRow.setExpanded(boolean).

      Returns:
      true if the model is set to autoexpand
    • getChildRow

      public @Nullable TreeListRow getChildRow(int position)

      Gets the row item corresponding to the child at index position for self's root model.

      If position is greater than the number of children in the root model, null is returned.

      Do not confuse this function with getRow(int).

      Parameters:
      position - position of the child to get
      Returns:
      the child in position
    • getModel

      public ListModel getModel()
      Gets the root model that this TreeListModel was created with.
      Returns:
      the root model
    • getPassthrough

      public boolean getPassthrough()

      Gets whether the model is passing through original row items.

      If this function returns false, the GListModel functions for this TreeListModel return custom GtkTreeListRow objects. You need to call TreeListRow.getItem() on these objects to get the original item.

      If true, the values of the child models are passed through in their original state. You then need to call getRow(int) to get the custom GtkTreeListRows.

      Returns:
      true if the model is passing through original row items
    • getRow

      public @Nullable TreeListRow getRow(int position)

      Gets the row object for the given row.

      If position is greater than the number of items in self, null is returned.

      The row object can be used to expand and collapse rows as well as to inspect its position in the tree. See its documentation for details.

      This row object is persistent and will refer to the current item as long as the row is present in self, independent of other rows being added or removed.

      If this TreeListModel is set to not be passthrough, this function is equivalent to calling g_list_model_get_item().

      Do not confuse this function with getChildRow(int).

      Parameters:
      position - the position of the row to fetch
      Returns:
      The row item
    • setAutoexpand

      public void setAutoexpand(boolean autoexpand)

      Sets whether the model should autoexpand.

      If set to true, the model will recursively expand all rows that get added to the model. This can be either rows added by changes to the underlying models or via TreeListRow.setExpanded(boolean).

      Parameters:
      autoexpand - true to make the model autoexpand its rows
    • builder

      public static TreeListModel.Builder<? extends TreeListModel.Builder> builder()
      A TreeListModel.Builder object constructs a TreeListModel with the specified properties. Use the various set...() methods to set properties, and finish construction with TreeListModel.Builder.build().
      Returns:
      the builder object