gtkmm 4.16.0
|
Sorting items. More...
#include <gtkmm/sorter.h>
Public Types | |
enum class | Order { Order::PARTIAL , Order::NONE , Order::TOTAL } |
Describes the type of order that a Gtk::Sorter may produce. More... | |
enum class | Change { Change::DIFFERENT , Change::INVERTED , Change::LESS_STRICT , Change::MORE_STRICT } |
Describes changes in a sorter in more detail and allows users to optimize resorting. More... | |
Public Member Functions | |
Sorter (Sorter &&src) noexcept | |
Sorter & | operator= (Sorter &&src) noexcept |
~Sorter () noexcept override | |
GtkSorter * | gobj () |
Provides access to the underlying C GObject. | |
const GtkSorter * | gobj () const |
Provides access to the underlying C GObject. | |
GtkSorter * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
Ordering | compare (gpointer item1, gpointer item2) |
Compares two given items according to the sort order implemented by the sorter. | |
Order | get_order () const |
Gets the order that self conforms to. | |
void | changed (Change change) |
Notifies all users of the sorter that it has changed. | |
Glib::SignalProxy< void(Change)> | signal_changed () |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Protected Member Functions | |
Sorter () | |
virtual Ordering | compare_vfunc (gpointer item1, gpointer item2) |
virtual Order | get_order_vfunc () |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gtk::Sorter > | wrap (GtkSorter *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Sorting items.
Gtk::Sorter is the way to describe sorting criteria. Its primary user is Gtk::SortListModel.
The model will use a sorter to determine the order in which its items should appear by calling compare() for pairs of items.
Sorters may change their sorting behavior through their lifetime. In that case, they will emit the signal_changed() signal to notify that the sort order is no longer valid and should be updated by calling compare() again.
GTK provides various pre-made sorter implementations for common sorting operations. Gtk::ColumnView has built-in support for sorting lists via the Gtk::ColumnViewColumn::property_sorter(), where the user can change the sorting by clicking on list headers.
Of course, in particular for large lists, it is also possible to subclass Gtk::Sorter and provide one's own sorter.
|
noexcept |
|
overridenoexcept |
|
protected |
Notifies all users of the sorter that it has changed.
This emits the signal_changed() signal. Users of the sorter should then update the sort order via compare().
Depending on the change parameter, it may be possible to update the sort order without a full resorting. Refer to the Gtk::SorterChange documentation for details.
This function is intended for implementers of Gtk::Sorter
subclasses and should not be called from other functions.
change | How the sorter changed. |
Compares two given items according to the sort order implemented by the sorter.
Sorters implement a partial order:
The sorter may signal it conforms to additional constraints via the return value of get_order().
item1 | First item to compare. |
item2 | Second item to compare. |
Order Gtk::Sorter::get_order | ( | ) | const |
Gets the order that self conforms to.
See Gtk::SorterOrder for details of the possible return values.
This function is intended to allow optimizations.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
GtkSorter * Gtk::Sorter::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void on_my_changed(Change change)
Flags: Run Last
Emitted whenever the sorter changed.
Users of the sorter should then update the sort order again via Gtk::Sorter::compare().
Gtk::SortListModel handles this signal automatically.
Depending on the change parameter, it may be possible to update the sort order without a full resorting. Refer to the Gtk::SorterChange documentation for details.
change | How the sorter changed. |
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |