Top |
Functions
GtkSortListModel * | gtk_sort_list_model_new () |
void | gtk_sort_list_model_set_sorter () |
GtkSorter * | gtk_sort_list_model_get_sorter () |
void | gtk_sort_list_model_set_model () |
GListModel * | gtk_sort_list_model_get_model () |
void | gtk_sort_list_model_set_incremental () |
gboolean | gtk_sort_list_model_get_incremental () |
guint | gtk_sort_list_model_get_pending () |
Properties
gboolean | incremental | Read / Write |
GListModel * | model | Read / Write |
guint | pending | Read |
GtkSorter * | sorter | Read / Write |
Description
GtkSortListModel is a list model that takes a list model and sorts its elements 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
gtk_sort_list_model_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.
Functions
gtk_sort_list_model_new ()
GtkSortListModel * gtk_sort_list_model_new (GListModel *model
,GtkSorter *sorter
);
Creates a new sort list model that uses the sorter
to sort model
.
Parameters
model |
the model to sort, or |
[allow-none][transfer full] |
sorter |
the GtkSorter to sort |
[allow-none][transfer full] |
gtk_sort_list_model_set_sorter ()
void gtk_sort_list_model_set_sorter (GtkSortListModel *self
,GtkSorter *sorter
);
Sets a new sorter on self
.
gtk_sort_list_model_get_sorter ()
GtkSorter *
gtk_sort_list_model_get_sorter (GtkSortListModel *self
);
Gets the sorter that is used to sort self
.
gtk_sort_list_model_set_model ()
void gtk_sort_list_model_set_model (GtkSortListModel *self
,GListModel *model
);
Sets the model to be sorted. The model
's item type must conform to
the item type of self
.
gtk_sort_list_model_get_model ()
GListModel *
gtk_sort_list_model_get_model (GtkSortListModel *self
);
Gets the model currently sorted or NULL
if none.
gtk_sort_list_model_set_incremental ()
void gtk_sort_list_model_set_incremental (GtkSortListModel *self
,gboolean incremental
);
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 gtk_sort_list_model_get_pending()
for progress information
about an ongoing incremental sorting operation.
gtk_sort_list_model_get_incremental ()
gboolean
gtk_sort_list_model_get_incremental (GtkSortListModel *self
);
Returns whether incremental sorting was enabled via
gtk_sort_list_model_set_incremental()
.
gtk_sort_list_model_get_pending ()
guint
gtk_sort_list_model_get_pending (GtkSortListModel *self
);
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:
1 2 3 |
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
“incremental” is FALSE
- this function returns 0.
Property Details
The “incremental”
property
“incremental” gboolean
If the model should sort items incrementally
Owner: GtkSortListModel
Flags: Read / Write
Default value: FALSE
The “model”
property
“model” GListModel *
The model being sorted
Owner: GtkSortListModel
Flags: Read / Write
The “pending”
property
“pending” guint
Estimate of unsorted items remaining
Owner: GtkSortListModel
Flags: Read
Default value: 0
The “sorter”
property
“sorter” GtkSorter *
The sorter for this model
Owner: GtkSortListModel
Flags: Read / Write