gtkmm 4.14.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gtk::ColumnViewSorter Class Reference

A sorter implementation that is geared towards the needs of Gtk::ColumnView. More...

#include <gtkmm/columnviewsorter.h>

Inheritance diagram for Gtk::ColumnViewSorter:
Inheritance graph
[legend]

Public Member Functions

 ColumnViewSorter (ColumnViewSorter &&src) noexcept
 
ColumnViewSorteroperator= (ColumnViewSorter &&src) noexcept
 
 ~ColumnViewSorter () noexcept override
 
GtkColumnViewSortergobj ()
 Provides access to the underlying C GObject.
 
const GtkColumnViewSortergobj () const
 Provides access to the underlying C GObject.
 
GtkColumnViewSortergobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
 
Glib::RefPtr< ColumnViewColumnget_primary_sort_column ()
 Returns the primary sort column.
 
Glib::RefPtr< const ColumnViewColumnget_primary_sort_column () const
 Returns the primary sort column.
 
SortType get_primary_sort_order () const
 Returns the primary sort order.
 
unsigned int get_n_sort_columns () const
 Returns the number of columns by which the sorter sorts.
 
std::pair< Glib::RefPtr< ColumnViewColumn >, SortTypeget_nth_sort_column (unsigned int position)
 Gets the position'th sort column and its associated sort order.
 
std::pair< Glib::RefPtr< const ColumnViewColumn >, SortTypeget_nth_sort_column (unsigned int position) const
 See the non-const get_nth_sort_column().
 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< ColumnViewColumn > > property_primary_sort_column () const
 The primary sort column.
 
Glib::PropertyProxy_ReadOnly< SortTypeproperty_primary_sort_order () const
 The primary sort order.
 
- Public Member Functions inherited from Gtk::Sorter
 Sorter (Sorter &&src) noexcept
 
Sorteroperator= (Sorter &&src) noexcept
 
 ~Sorter () noexcept override
 
GtkSortergobj ()
 Provides access to the underlying C GObject.
 
const GtkSortergobj () const
 Provides access to the underlying C GObject.
 
GtkSortergobj_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.
 
- Static Public Member Functions inherited from Gtk::Sorter
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system.
 

Protected Member Functions

 ColumnViewSorter ()
 
- Protected Member Functions inherited from Gtk::Sorter
 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::ColumnViewSorterwrap (GtkColumnViewSorter *object, bool take_copy=false)
 A Glib::wrap() method for this object.
 

Additional Inherited Members

- Public Types inherited from Gtk::Sorter
enum class  Order {
  PARTIAL ,
  NONE ,
  TOTAL
}
 
enum class  Change {
  DIFFERENT ,
  INVERTED ,
  LESS_STRICT ,
  MORE_STRICT
}
 

Detailed Description

A sorter implementation that is geared towards the needs of Gtk::ColumnView.

The sorter returned by Gtk::ColumnView::get_sorter() is a Gtk::ColumnViewSorter.

In column views, sorting can be configured by associating sorters with columns, and users can invert sort order by clicking on column headers. The API of Gtk::ColumnViewSorter is designed to allow saving and restoring this configuration.

If you are only interested in the primary sort column (i.e. the column where a sort indicator is shown in the header), then you can just look at property_primary_sort_column() and property_primary_sort_order().

If you want to store the full sort configuration, including secondary sort columns that are used for tie breaking, then you can use get_nth_sort_column(). To get notified about changes, use Gtk::Sorter::signal_changed().

To restore a saved sort configuration on a Gtk::ColumnView, use code like:

auto sorter = column_view->get_sorter();
auto column_view_sorter = std::dynamic_pointer_cast<Gtk::ColumnViewSorter>(sorter);
if (column_view_sorter)
{
for (unsigned int i = column_view_sorter->get_n_sort_columns(); i > 0; --i)
{
auto [column, sort_order] = column_view_sorter->get_nth_sort_column(i-1);
column_view->sort_by_column(column, sort_order);
}
}
__shared_ptr< _Tp, _Lp > dynamic_pointer_cast(const __shared_ptr< _Tp1, _Lp > &__r) noexcept
Since gtkmm 4.10:

Constructor & Destructor Documentation

◆ ColumnViewSorter() [1/2]

Gtk::ColumnViewSorter::ColumnViewSorter ( ColumnViewSorter &&  src)
noexcept

◆ ~ColumnViewSorter()

Gtk::ColumnViewSorter::~ColumnViewSorter ( )
overridenoexcept

◆ ColumnViewSorter() [2/2]

Gtk::ColumnViewSorter::ColumnViewSorter ( )
protected

Member Function Documentation

◆ get_n_sort_columns()

unsigned int Gtk::ColumnViewSorter::get_n_sort_columns ( ) const

Returns the number of columns by which the sorter sorts.

If the sorter of the primary sort column does not determine a total order, then the secondary sorters are consulted to break the ties.

Use the Gtk::Sorter::signal_changed() signal to get notified when the number of sort columns changes.

Since gtkmm 4.10:
Returns
The number of sort columns.

◆ get_nth_sort_column() [1/2]

std::pair< Glib::RefPtr< ColumnViewColumn >, SortType > Gtk::ColumnViewSorter::get_nth_sort_column ( unsigned int  position)

Gets the position'th sort column and its associated sort order.

Use the Gtk::Sorter::signal_changed() signal to get notified when sort columns change.

Since gtkmm 4.10:
Parameters
positionThe position of the sort column to retrieve (0 for the primary sort column).
Returns
{sort_column, sort_order} The position's sort column and sort order.

◆ get_nth_sort_column() [2/2]

std::pair< Glib::RefPtr< const ColumnViewColumn >, SortType > Gtk::ColumnViewSorter::get_nth_sort_column ( unsigned int  position) const

See the non-const get_nth_sort_column().

◆ get_primary_sort_column() [1/2]

Glib::RefPtr< ColumnViewColumn > Gtk::ColumnViewSorter::get_primary_sort_column ( )

Returns the primary sort column.

The primary sort column is the one that displays the triangle in a column view header.

Since gtkmm 4.10:
Returns
The primary sort column.

◆ get_primary_sort_column() [2/2]

Glib::RefPtr< const ColumnViewColumn > Gtk::ColumnViewSorter::get_primary_sort_column ( ) const

Returns the primary sort column.

The primary sort column is the one that displays the triangle in a column view header.

Since gtkmm 4.10:
Returns
The primary sort column.

◆ get_primary_sort_order()

SortType Gtk::ColumnViewSorter::get_primary_sort_order ( ) const

Returns the primary sort order.

The primary sort order determines whether the triangle displayed in the column view header of the primary sort column points upwards or downwards.

If there is no primary sort column, then this function returns Gtk::SortType::ASCENDING.

Since gtkmm 4.10:
Returns
The primary sort order.

◆ get_type()

static GType Gtk::ColumnViewSorter::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gobj() [1/2]

GtkColumnViewSorter * Gtk::ColumnViewSorter::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GtkColumnViewSorter * Gtk::ColumnViewSorter::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GtkColumnViewSorter * Gtk::ColumnViewSorter::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

◆ operator=()

ColumnViewSorter & Gtk::ColumnViewSorter::operator= ( ColumnViewSorter &&  src)
noexcept

◆ property_primary_sort_column()

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< ColumnViewColumn > > Gtk::ColumnViewSorter::property_primary_sort_column ( ) const

The primary sort column.

The primary sort column is the one that displays the triangle in a column view header.

Since gtkmm 4.10:
Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_primary_sort_order()

Glib::PropertyProxy_ReadOnly< SortType > Gtk::ColumnViewSorter::property_primary_sort_order ( ) const

The primary sort order.

The primary sort order determines whether the triangle displayed in the column view header of the primary sort column points upwards or downwards.

Since gtkmm 4.10:

Default value: Gtk::SortType::ASCENDING

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Friends And Related Symbol Documentation

◆ wrap()

Glib::RefPtr< Gtk::ColumnViewSorter > wrap ( GtkColumnViewSorter object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.