gi-gtk-4.0.5: Gtk bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gtk.Objects.SortListModel

Description

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 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.

Synopsis

Exported types

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

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.

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.

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 ]

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 ]

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

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 ]