SortListModelProtocol

public protocol SortListModelProtocol : ListModelProtocol, ObjectProtocol

A GListModel that sorts the elements of an underlying model according to a GtkSorter.

The model can be set up to do incremental sorting, so that sorting long lists doesn’t block the UI. See [methodGtk.SortListModel.set_incremental] for details.

GtkSortListModel is a generic model and because of that it cannot take advantage of any external knowledge when sorting. If you run into performance issues with GtkSortListModel, it is strongly recommended that you write your own sorting list model.

The SortListModelProtocol protocol exposes the methods and properties of an underlying GtkSortListModel instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see SortListModel. Alternatively, use SortListModelRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkSortListModel instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • sort_list_model_ptr Default implementation

    Typed pointer to the underlying GtkSortListModel instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkSortListModel instance.

    Declaration

    Swift

    var sort_list_model_ptr: UnsafeMutablePointer<GtkSortListModel>! { get }
  • Required Initialiser for types conforming to SortListModelProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

SortListModel Class

  • Bind a SortListModelPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: SortListModelPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a SortListModel property

    Declaration

    Swift

    @inlinable
    func get(property: SortListModelPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a SortListModel property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: SortListModelPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

SortListModel Class: SortListModelProtocol extension (methods and fields)

  • getIncremental() Extension method

    Returns whether incremental sorting is enabled.

    See [methodGtk.SortListModel.set_incremental].

    Declaration

    Swift

    @inlinable
    func getIncremental() -> Bool
  • getModel() Extension method

    Gets the model currently sorted or nil if none.

    Declaration

    Swift

    @inlinable
    func getModel() -> GIO.ListModelRef!
  • getPending() Extension method

    Estimates progress of an ongoing sorting operation.

    The estimate is the number of items that would still need to be sorted to finish the sorting operation if this was a linear algorithm. So this number is not related to how many items are already correctly sorted.

    If you want to estimate the progress, you can use code like this:

    pending = gtk_sort_list_model_get_pending (self);
    model = gtk_sort_list_model_get_model (self);
    progress = 1.0 - pending / (double) MAX (1, g_list_model_get_n_items (model));
    

    If no sort operation is ongoing - in particular when [propertyGtk.SortListModel:incremental] is false - this function returns 0.

    Declaration

    Swift

    @inlinable
    func getPending() -> Int
  • getSorter() Extension method

    Gets the sorter that is used to sort self.

    Declaration

    Swift

    @inlinable
    func getSorter() -> SorterRef!
  • set(incremental:) Extension method

    Sets the sort model to do an incremental sort.

    When incremental sorting is enabled, the GtkSortListModel will not do a complete sort immediately, but will instead queue an idle handler that incrementally sorts the items towards their correct position. This of course means that items do not instantly appear in the right place. It also means that the total sorting time is a lot slower.

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

    By default, incremental sorting is disabled.

    See [methodGtk.SortListModel.get_pending] for progress information about an ongoing incremental sorting operation.

    Declaration

    Swift

    @inlinable
    func set(incremental: Bool)
  • set(model:) Extension method

    Sets the model to be sorted.

    The model‘s item type must conform to the item type of self.

    Declaration

    Swift

    @inlinable
    func set(model: GIO.ListModelRef? = nil)
  • set(model:) Extension method

    Sets the model to be sorted.

    The model‘s item type must conform to the item type of self.

    Declaration

    Swift

    @inlinable
    func set<ListModelT>(model: ListModelT?) where ListModelT : ListModelProtocol
  • set(sorter:) Extension method

    Sets a new sorter on self.

    Declaration

    Swift

    @inlinable
    func set(sorter: SorterRef? = nil)
  • set(sorter:) Extension method

    Sets a new sorter on self.

    Declaration

    Swift

    @inlinable
    func set<SorterT>(sorter: SorterT?) where SorterT : SorterProtocol
  • incremental Extension method

    If the model should sort items incrementally.

    Declaration

    Swift

    @inlinable
    var incremental: Bool { get nonmutating set }
  • model Extension method

    The model being sorted.

    Declaration

    Swift

    @inlinable
    var model: GIO.ListModelRef! { get nonmutating set }
  • pending Extension method

    Estimate of unsorted items remaining.

    Declaration

    Swift

    @inlinable
    var pending: Int { get }
  • sorter Extension method

    The sorter for this model.

    Declaration

    Swift

    @inlinable
    var sorter: SorterRef! { get nonmutating set }