gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.SortListModel

Contents

- Exported types
- Methods
  - getIncremental
  - getModel
  - getPending
  - getSectionSorter
  - getSorter
  - new
  - setIncremental
  - setModel
  - setSectionSorter
  - setSorter
- Properties
  - incremental
  - itemType
  - model
  - nItems
  - pending
  - sectionSorter
  - sorter

Description

A list model that sorts the elements of another model.

The elements are sorted according to a `GtkSorter`.

The model is a stable sort. If two items compare equal according to the sorter, the one that appears first in the original model will also appear first after sorting.

Note that if you change the sorter, the previous order will have no influence on the new order. If you want that, consider using a `GtkMultiSorter` and appending the previous sorter to it.

The model can be set up to do incremental sorting, so that sorting long lists doesn't block the UI. See `sortListModelSetIncremental` 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.

`GtkSortListModel` allows sorting the items into sections. It implements `GtkSectionModel` and when SortListModel:sectionSorter is set, it will sort all items with that sorter and items comparing equal with it will be put into the same section. The SortListModel:sorter will then be used to sort items inside their sections.

Synopsis

- newtype SortListModel = SortListModel (ManagedPtr SortListModel)
- class (GObject o, IsDescendantOf SortListModel o) => IsSortListModel o
- toSortListModel :: (MonadIO m, IsSortListModel o) => o -> m SortListModel
- sortListModelGetIncremental :: (HasCallStack, MonadIO m, IsSortListModel a) => a -> m Bool
- sortListModelGetModel :: (HasCallStack, MonadIO m, IsSortListModel a) => a -> m (Maybe ListModel)
- sortListModelGetPending :: (HasCallStack, MonadIO m, IsSortListModel a) => a -> m Word32
- sortListModelGetSectionSorter :: (HasCallStack, MonadIO m, IsSortListModel a) => a -> m (Maybe Sorter)
- sortListModelGetSorter :: (HasCallStack, MonadIO m, IsSortListModel a) => a -> m (Maybe Sorter)
- sortListModelNew :: (HasCallStack, MonadIO m, IsListModel a, IsSorter b) => Maybe a -> Maybe b -> m SortListModel
- sortListModelSetIncremental :: (HasCallStack, MonadIO m, IsSortListModel a) => a -> Bool -> m ()
- sortListModelSetModel :: (HasCallStack, MonadIO m, IsSortListModel a, IsListModel b) => a -> Maybe b -> m ()
- sortListModelSetSectionSorter :: (HasCallStack, MonadIO m, IsSortListModel a, IsSorter b) => a -> Maybe b -> m ()
- sortListModelSetSorter :: (HasCallStack, MonadIO m, IsSortListModel a, IsSorter b) => a -> Maybe b -> m ()
- constructSortListModelIncremental :: (IsSortListModel o, MonadIO m) => Bool -> m (GValueConstruct o)
- getSortListModelIncremental :: (MonadIO m, IsSortListModel o) => o -> m Bool
- setSortListModelIncremental :: (MonadIO m, IsSortListModel o) => o -> Bool -> m ()
- getSortListModelItemType :: (MonadIO m, IsSortListModel o) => o -> m GType
- clearSortListModelModel :: (MonadIO m, IsSortListModel o) => o -> m ()
- constructSortListModelModel :: (IsSortListModel o, MonadIO m, IsListModel a) => a -> m (GValueConstruct o)
- getSortListModelModel :: (MonadIO m, IsSortListModel o) => o -> m (Maybe ListModel)
- setSortListModelModel :: (MonadIO m, IsSortListModel o, IsListModel a) => o -> a -> m ()
- getSortListModelNItems :: (MonadIO m, IsSortListModel o) => o -> m Word32
- getSortListModelPending :: (MonadIO m, IsSortListModel o) => o -> m Word32
- clearSortListModelSectionSorter :: (MonadIO m, IsSortListModel o) => o -> m ()
- constructSortListModelSectionSorter :: (IsSortListModel o, MonadIO m, IsSorter a) => a -> m (GValueConstruct o)
- getSortListModelSectionSorter :: (MonadIO m, IsSortListModel o) => o -> m (Maybe Sorter)
- setSortListModelSectionSorter :: (MonadIO m, IsSortListModel o, IsSorter a) => o -> a -> m ()
- clearSortListModelSorter :: (MonadIO m, IsSortListModel o) => o -> m ()
- constructSortListModelSorter :: (IsSortListModel o, MonadIO m, IsSorter a) => a -> m (GValueConstruct o)
- getSortListModelSorter :: (MonadIO m, IsSortListModel o) => o -> m (Maybe Sorter)
- setSortListModelSorter :: (MonadIO m, IsSortListModel o, IsSorter a) => o -> a -> m ()

# Exported types

newtype SortListModel Source #

Memory-managed wrapper type.

Constructors

SortListModel (ManagedPtr SortListModel) |

#### Instances

Instances details

Eq SortListModel Source # |
Instance details Defined in GI.Gtk.Objects.SortListModel Methods (==) :: SortListModel -> SortListModel -> Bool Source # (/=) :: SortListModel -> SortListModel -> Bool Source #
GObject SortListModel Source # |
Instance details Defined in GI.Gtk.Objects.SortListModel
ManagedPtrNewtype SortListModel Source # |
Instance details Defined in GI.Gtk.Objects.SortListModel Methods toManagedPtr :: SortListModel -> ManagedPtr SortListModel Source #
TypedObject SortListModel Source # |
Instance details Defined in GI.Gtk.Objects.SortListModel Methods glibType :: IO GType Source #
HasParentTypes SortListModel Source # |
Instance details Defined in GI.Gtk.Objects.SortListModel
IsGValue (Maybe SortListModel) Source # | Convert `SortListModel` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Objects.SortListModel Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe SortListModel -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe SortListModel) Source #
type ParentTypes SortListModel Source # |
Instance details Defined in GI.Gtk.Objects.SortListModel type ParentTypes SortListModel = '[Object, ListModel, SectionModel]

class (GObject o, IsDescendantOf SortListModel o) => IsSortListModel o Source #

Type class for types which can be safely cast to `SortListModel`, for instance with `toSortListModel`.

#### Instances

Instances details

(GObject o, IsDescendantOf SortListModel o) => IsSortListModel o Source # |
Instance details Defined in GI.Gtk.Objects.SortListModel

toSortListModel :: (MonadIO m, IsSortListModel o) => o -> m SortListModel Source #

Cast to `SortListModel`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, isFloating, itemsChanged, notify, notifyByPspec, ref, refSink, runDispose, sectionsChanged, stealData, stealQdata, thawNotify, unref, watchClosure.

#### Getters

getData, getIncremental, getItem, getItemType, getModel, getNItems, getPending, getProperty, getQdata, getSection, getSectionSorter, getSorter.

#### Setters

setData, setDataFull, setIncremental, setModel, setProperty, setSectionSorter, setSorter.

## getIncremental

sortListModelGetIncremental Source #

Arguments

:: (HasCallStack, MonadIO m, IsSortListModel a) |
=> a | `self`: a `GtkSortListModel`
-> m Bool | Returns: `True` if incremental sorting is enabled

Returns whether incremental sorting is enabled.

See `sortListModelSetIncremental`.

## getModel

sortListModelGetModel Source #

Arguments

:: (HasCallStack, MonadIO m, IsSortListModel a) |
=> a | `self`: a `GtkSortListModel`
-> m (Maybe ListModel) | Returns: The model that gets sorted

Gets the model currently sorted or `Nothing` if none.

## getPending

sortListModelGetPending Source #

Arguments

:: (HasCallStack, MonadIO m, IsSortListModel a) |
=> a | `self`: a `GtkSortListModel`
-> m Word32 | Returns: a progress estimate of remaining items to sort

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:

### c code

    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 SortListModel:incremental is `False` - this function returns 0.

## getSectionSorter

sortListModelGetSectionSorter Source #

Arguments

:: (HasCallStack, MonadIO m, IsSortListModel a) |
=> a | `self`: a `GtkSortListModel`
-> m (Maybe Sorter) | Returns: the sorter of `self`

Gets the section sorter that is used to sort items of `self` into sections.

Since: 4.12

## getSorter

sortListModelGetSorter Source #

Arguments

:: (HasCallStack, MonadIO m, IsSortListModel a) |
=> a | `self`: a `GtkSortListModel`
-> m (Maybe Sorter) | Returns: the sorter of `self`

Gets the sorter that is used to sort `self`.

## new

sortListModelNew Source #

Arguments

:: (HasCallStack, MonadIO m, IsListModel a, IsSorter b) |
=> Maybe a | `model`: the model to sort
-> Maybe b | `sorter`: the `GtkSorter` to sort `model` with,
-> m SortListModel | Returns: a new `GtkSortListModel`

Creates a new sort list model that uses the `sorter` to sort `model`.

## setIncremental

sortListModelSetIncremental Source #

Arguments

:: (HasCallStack, MonadIO m, IsSortListModel a) |
=> a | `self`: a `GtkSortListModel`
-> Bool | `incremental`: `True` to sort incrementally
-> m () |

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 `sortListModelGetPending` for progress information about an ongoing incremental sorting operation.

## setModel

sortListModelSetModel Source #

Arguments

:: (HasCallStack, MonadIO m, IsSortListModel a, IsListModel b) |
=> a | `self`: a `GtkSortListModel`
-> Maybe b | `model`: The model to be sorted
-> m () |

Sets the model to be sorted.

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

## setSectionSorter

sortListModelSetSectionSorter Source #

Arguments

:: (HasCallStack, MonadIO m, IsSortListModel a, IsSorter b) |
=> a | `self`: a `GtkSortListModel`
-> Maybe b | `sorter`: the `GtkSorter` to sort `model` with
-> m () |

Sets a new section sorter on `self`.

Since: 4.12

## setSorter

sortListModelSetSorter Source #

Arguments

:: (HasCallStack, MonadIO m, IsSortListModel a, IsSorter b) |
=> a | `self`: a `GtkSortListModel`
-> Maybe b | `sorter`: the `GtkSorter` to sort `model` with
-> m () |

Sets a new sorter on `self`.

# Properties

## incremental

If the model should sort items incrementally.

constructSortListModelIncremental :: (IsSortListModel o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`incremental`” property. This is rarely needed directly, but it is used by `new`.

getSortListModelIncremental :: (MonadIO m, IsSortListModel o) => o -> m Bool Source #

Get the value of the “`incremental`” property. When overloading is enabled, this is equivalent to

    get sortListModel #incremental

setSortListModelIncremental :: (MonadIO m, IsSortListModel o) => o -> Bool -> m () Source #

Set the value of the “`incremental`” property. When overloading is enabled, this is equivalent to

    set sortListModel [ #incremental := value ]

## itemType

The type of items. See `listModelGetItemType`.

Since: 4.8

getSortListModelItemType :: (MonadIO m, IsSortListModel o) => o -> m GType Source #

Get the value of the “`item-type`” property. When overloading is enabled, this is equivalent to

    get sortListModel #itemType

## model

The model being sorted.

clearSortListModelModel :: (MonadIO m, IsSortListModel o) => o -> m () Source #

Set the value of the “`model`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #model

constructSortListModelModel :: (IsSortListModel o, MonadIO m, IsListModel a) => a -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`model`” property. This is rarely needed directly, but it is used by `new`.

getSortListModelModel :: (MonadIO m, IsSortListModel o) => o -> m (Maybe ListModel) Source #

Get the value of the “`model`” property. When overloading is enabled, this is equivalent to

    get sortListModel #model

setSortListModelModel :: (MonadIO m, IsSortListModel o, IsListModel a) => o -> a -> m () Source #

Set the value of the “`model`” property. When overloading is enabled, this is equivalent to

    set sortListModel [ #model := value ]

## nItems

The number of items. See `listModelGetNItems`.

Since: 4.8

getSortListModelNItems :: (MonadIO m, IsSortListModel o) => o -> m Word32 Source #

Get the value of the “`n-items`” property. When overloading is enabled, this is equivalent to

    get sortListModel #nItems

## pending

Estimate of unsorted items remaining.

getSortListModelPending :: (MonadIO m, IsSortListModel o) => o -> m Word32 Source #

Get the value of the “`pending`” property. When overloading is enabled, this is equivalent to

    get sortListModel #pending

## sectionSorter

The section sorter for this model, if one is set.

Since: 4.12

clearSortListModelSectionSorter :: (MonadIO m, IsSortListModel o) => o -> m () Source #

Set the value of the “`section-sorter`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #sectionSorter

constructSortListModelSectionSorter :: (IsSortListModel o, MonadIO m, IsSorter a) => a -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`section-sorter`” property. This is rarely needed directly, but it is used by `new`.

getSortListModelSectionSorter :: (MonadIO m, IsSortListModel o) => o -> m (Maybe Sorter) Source #

Get the value of the “`section-sorter`” property. When overloading is enabled, this is equivalent to

    get sortListModel #sectionSorter

setSortListModelSectionSorter :: (MonadIO m, IsSortListModel o, IsSorter a) => o -> a -> m () Source #

Set the value of the “`section-sorter`” property. When overloading is enabled, this is equivalent to

    set sortListModel [ #sectionSorter := value ]

## sorter

The sorter for this model.

clearSortListModelSorter :: (MonadIO m, IsSortListModel o) => o -> m () Source #

Set the value of the “`sorter`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #sorter

constructSortListModelSorter :: (IsSortListModel o, MonadIO m, IsSorter a) => a -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`sorter`” property. This is rarely needed directly, but it is used by `new`.

getSortListModelSorter :: (MonadIO m, IsSortListModel o) => o -> m (Maybe Sorter) Source #

Get the value of the “`sorter`” property. When overloading is enabled, this is equivalent to

    get sortListModel #sorter

setSortListModelSorter :: (MonadIO m, IsSortListModel o, IsSorter a) => o -> a -> m () Source #

Set the value of the “`sorter`” property. When overloading is enabled, this is equivalent to

    set sortListModel [ #sorter := value ]