| Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
GI.Gtk.Objects.SortListModel
Description
SortListModel is a list model that takes a list model and
sorts its elements according to a Sorter.
The model can be set up to do incremental sorting, so that
sorting long lists doesn't block the UI. See
sortListModelSetIncremental for details.
SortListModel 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 SortListModel, it
is strongly recommended that you write your own sorting list
model.
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
- 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 ()
- 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 ()
- 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 ()
- getSortListModelPending :: (MonadIO m, IsSortListModel o) => o -> m Word32
- 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
| Eq SortListModel Source # | |
Defined in GI.Gtk.Objects.SortListModel Methods (==) :: SortListModel -> SortListModel -> Bool # (/=) :: SortListModel -> SortListModel -> Bool # | |
| GObject SortListModel Source # | |
Defined in GI.Gtk.Objects.SortListModel | |
| ManagedPtrNewtype SortListModel Source # | |
Defined in GI.Gtk.Objects.SortListModel Methods toManagedPtr :: SortListModel -> ManagedPtr SortListModel | |
| TypedObject SortListModel Source # | |
Defined in GI.Gtk.Objects.SortListModel | |
| HasParentTypes SortListModel Source # | |
Defined in GI.Gtk.Objects.SortListModel | |
| IsGValue (Maybe SortListModel) Source # | Convert |
Defined in GI.Gtk.Objects.SortListModel Methods gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe SortListModel -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe SortListModel) | |
| type ParentTypes SortListModel Source # | |
Defined in GI.Gtk.Objects.SortListModel | |
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
| (GObject o, IsDescendantOf SortListModel o) => IsSortListModel o Source # | |
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
Methods
bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, isFloating, itemsChanged, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getIncremental, getItem, getItemType, getModel, getNItems, getPending, getProperty, getQdata, getSorter.
Setters
setData, setDataFull, setIncremental, setModel, setProperty, setSorter.
getIncremental
sortListModelGetIncremental Source #
Arguments
| :: (HasCallStack, MonadIO m, IsSortListModel a) | |
| => a |
|
| -> m Bool | Returns: |
Returns whether incremental sorting was enabled via
sortListModelSetIncremental.
getModel
sortListModelGetModel Source #
Arguments
| :: (HasCallStack, MonadIO m, IsSortListModel a) | |
| => a |
|
| -> 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 |
|
| -> 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 |
|
| -> m (Maybe Sorter) | Returns: the sorter of |
Gets the sorter that is used to sort self.
new
Arguments
| :: (HasCallStack, MonadIO m, IsListModel a, IsSorter b) | |
| => Maybe a |
|
| -> Maybe b | |
| -> m SortListModel | Returns: a new |
Creates a new sort list model that uses the sorter to sort model.
setIncremental
sortListModelSetIncremental Source #
Arguments
| :: (HasCallStack, MonadIO m, IsSortListModel a) | |
| => a |
|
| -> Bool |
|
| -> m () |
Sets the sort model to do an incremental sort.
When incremental sorting is enabled, the sortlistmodel 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 |
|
| -> Maybe b |
|
| -> 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 |
|
| -> Maybe b |
|
| -> 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
setsortListModel [ #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
setsortListModel [ #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
setsortListModel [ #sorter:=value ]