Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# Xfc::Gtk::TreeSortable Class Reference

A GtkTreeSortable C++ wrapper class. More...

`#include <xfc/gtk/treesortable.hh>`

Inheritance diagram for Xfc::Gtk::TreeSortable:

List of all members.

## Signal Prototypes

- const SortColumnChangedSignalType sort_column_changed_signal
    Sort column changed signal (see signal_sort_column_changed()).

## Public Types

- typedef sigc::slot< int, const
  TreeIter &, const TreeIter & > CompareSlot
    Signature of the callback slot to be used for comparing two TreeIter's when sorting.

## Public Member Functions

Accessors

- GtkTreeSortable * gtk_tree_sortable () const
    Get a pointer to the GtkTreeSortable structure.
- operator GtkTreeSortable * () const
    Conversion operator; safely converts a TreeSortable to a GtkTreeSortable pointer.
- bool get_sort_column_id (int *sort_column_id, SortType *order) const
    Fills in sort_column_id and order with the current sort column and the order, if applicable.
- bool has_default_sort_func () const
    Returns true if the model has a default sort function.

Methods

- void sort_column_changed ()
    Emits a "sort_column_changed" signal on the sortable.
- void set_sort_column_id (int sort_column_id, SortType order)
    Sets the current sort column to be sort_column_id.
- void set_sort_func (int sort_column_id, const CompareSlot &compare)
    Sets the comparison callback slot used when sorting to be compare.
- void set_default_sort_func (const CompareSlot &compare)
    Sets the default comparison callback slot used when sorting to be compare.
- void reset_default_sort_func ()
    Resets the default sort function to be in the 'unsorted' state.

Signal Proxies

- const SortColumnChangedSignalProxy signal_sort_column_changed ()
    Connect to the sort_column_changed_signal; emitted whenever the current sort column is changed.

## Protected Member Functions

Constructors

- TreeSortable ()
    Constructs a new TreeSortable object.
- virtual ~TreeSortable ()=0
    Destructor.

## Detailed Description

A GtkTreeSortable C++ wrapper class.

The TreeSortable interface defines a generic interface for sorting a model. It is an abstract interface, and is designed to be usable with any derived class. The programmer just has to multiplely inherit this interface on their own model for it to be sortable. To make life easier two generic sortable models are already provided, ListStore and TreeStore.

## Member Typedef Documentation

typedef sigc::slot<int, const TreeIter&, const TreeIter&> Xfc::Gtk::TreeSortable::CompareSlot

Signature of the callback slot to be used for comparing two TreeIter's when sorting.

Example: Method signature for CompareSlot.

                 int method(const TreeIter& a, const TreeIter& b);

                 // a: A TreeIter.
                 // b: Another TreeIter.
                 // return: -1 if "a" comes before "b" in the tree, 1 if "a" comes after "b" in
                 //         the tree and 0 if a and b point to the same location in the tree.

## Member Function Documentation

bool Xfc::Gtk::TreeSortable::get_sort_column_id | ( | int * | sort_column_id,
|  | SortType * | order
| ) | const

Fills in sort_column_id and order with the current sort column and the order, if applicable.

Parameters:

  | sort_column_id | The sort column id to be filled in.
  | order | The SortType to be filled in.

Returns:
  true if the sort column is not one of the special sort column ids.

If sort_column_id is one of the special sort column id's: DEFAULT_SORT_COLUMN_ID or UNSORTED_SORT_COLUMN_ID, false is returned.

bool Xfc::Gtk::TreeSortable::has_default_sort_func | ( |  | ) | const

Returns true if the model has a default sort function.

Returns:
  true if the model has a default sort function.

This is used primarily by TreeViewColumns in order to determine if a model can go back to its default state, or not.

void Xfc::Gtk::TreeSortable::reset_default_sort_func | ( |  | ) |

Resets the default sort function to be in the 'unsorted' state.

After calling this method there will be no default comparison callback slot. This means that once the model has been sorted, it can't go back to its default state. In this case, when the current sort column id of the sortable is Gtk::TreeSortable::DEFAULT_SORT_COLUMN_ID, the model will be unsorted.

Reimplemented in Xfc::Gtk::TreeModelSort.

void Xfc::Gtk::TreeSortable::set_default_sort_func | ( | const CompareSlot & | compare | ) |

Sets the default comparison callback slot used when sorting to be compare.

Parameters:

  | compare | The sorting slot.

If the current sort_column_id of sortable is Gtk::TreeSortable::DEFAULT_SORT_COLUMN_ID, then the model will sort using this function.

void Xfc::Gtk::TreeSortable::set_sort_column_id | ( | int | sort_column_id,
|  | SortType | order
| ) |

Sets the current sort column to be sort_column_id.

Parameters:

  | sort_column_id | The sort column id to set.
  | order | The sort order of the column.

The sortable will resort itself to reflect this change, after emitting a sort_column_changed signal. If sort_column_id is DEFAULT_SORT_COLUMN_ID, then the default sort function will be used, if it is set.

void Xfc::Gtk::TreeSortable::set_sort_func | ( | int | sort_column_id,
|  | const CompareSlot & | compare
| ) |

Sets the comparison callback slot used when sorting to be compare.

Parameters:

  | sort_column_id | The sort column id to set the callback slot for.
  | compare | The sorting slot to call.

If the current sort column id of sortable is the same as sort_column_id, then the model will sort using this function.

## Member Data Documentation

const SortColumnChangedSignalType Xfc::Gtk::TreeSortable::sort_column_changed_signal `[static, protected]`

Sort column changed signal (see signal_sort_column_changed()).

Calls a slot with the signature:

                 void function();

The documentation for this class was generated from the following file:

- treesortable.hh

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3