mousetrap v0.2.0
Loading...
Searching...
No Matches
mousetrap::SelectionModel Class Reference

selection model, provides interface and signals for selectable widgets More...

#include <selection_model.hpp>

Inheritance diagram for mousetrap::SelectionModel:
mousetrap::SignalEmitter mousetrap::has_signal_selection_changed< SelectionModel >

Public Member Functions

 SelectionModel (detail::SelectionModelInternal *)
 construct from internal, for interal use only. Use get_selection_model to acquire a selection model from a selectable widget
 
 SelectionModel (SelectionMode mode, GListModel *model)
 construct from selection mode,
 
 ~SelectionModel ()
 destruct
 
NativeObject get_internal () const override
 expose internal
 
 operator GtkSelectionModel * () const
 expose as GtkSelectionModel \for_internal_use_only
 
 operator NativeObject () const override
 expose as GObject \for_internal_use_only
 
SelectionMode get_selection_mode () const
 get mode of selection
 
std::vector< uint64_t > get_selection ()
 get indices of selected items
 
void select_all ()
 select all items or, if selection mode is single, select the first item
 
void unselect_all ()
 unselect all itmes
 
void select (uint64_t i, bool unselect_others=true)
 select item at specific index
 
void unselect (uint64_t i)
 unselect item at specific item
 
void set_allow_no_selection_if_single (bool b)
 if the selection mode is SelectionMode::SINGLE, determines whether no items can be selected
 
uint64_t get_n_items () const
 get number of items
 
- Public Member Functions inherited from mousetrap::SignalEmitter
void set_signal_blocked (const std::string &signal_id, bool b)
 block a signal by id \for_internal_use_only
 
bool get_signal_blocked (const std::string &signal_id) const
 get whether a signal is currently blocked
 
std::vector< std::string > get_all_signal_names ()
 get list of possible signal ids \for_internal_use_only
 
template<typename Function_t >
void connect_signal (const std::string &signal_id, Function_t *function, void *data=nullptr)
 connect static function to signal, does not work with lambdas \for_internal_use_only
 
void disconnect_signal (const std::string &signal_id)
 disconnect signal, it may not be invoked until reconnected, if signal is not registered, does nothing. For internal use only
 
virtual operator NativeObject () const =0
 expose as NativeObject, this is the GLib instance that signals are emitted on \for_internal_use_only
 
virtual NativeObject get_internal () const
 expose internally managed object, \for_internal_use_only
 
- Public Member Functions inherited from mousetrap::has_signal_selection_changed< SelectionModel >
void connect_signal_selection_changed (Function_t f, Data_t data)
 connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function
 
void connect_signal_selection_changed (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_selection_changed_blocked (bool b)
 
bool get_signal_selection_changed_blocked () const
 
void emit_signal_selection_changed (int32_t position, int32_t n_items)
 invoke signal handler manually
 
void disconnect_signal_selection_changed ()
 

Protected Attributes

detail::SelectionModelInternal * _internal = nullptr
 

Additional Inherited Members

- Static Public Attributes inherited from mousetrap::has_signal_selection_changed< SelectionModel >
static const char * signal_id
 glib ID
 
- Protected Member Functions inherited from mousetrap::SignalEmitter
 SignalEmitter ()
 ctor
 
 ~SignalEmitter ()
 destructor
 
- Protected Member Functions inherited from mousetrap::has_signal_selection_changed< SelectionModel >
 has_signal_selection_changed (SelectionModel *instance)
 

Detailed Description

selection model, provides interface and signals for selectable widgets

signal id signature emitted when...
selection_changed (SelectionModel&, int32_t position, int32_t n_items, (Data_t)) -> void Selection state changes, usually because the user selected a different item or the internal list of items was otherwise modified

Member Function Documentation

◆ get_internal()

NativeObject mousetrap::SelectionModel::get_internal ( ) const
overridevirtual

expose internal

Reimplemented from mousetrap::SignalEmitter.

◆ get_n_items()

uint64_t mousetrap::SelectionModel::get_n_items ( ) const

get number of items

Returns
uint64_t

◆ get_selection()

std::vector< uint64_t > mousetrap::SelectionModel::get_selection ( )

get indices of selected items

Returns
vector of indices, may be empty

◆ get_selection_mode()

SelectionMode mousetrap::SelectionModel::get_selection_mode ( ) const

get mode of selection

Returns
selection mode

◆ operator NativeObject()

mousetrap::SelectionModel::operator NativeObject ( ) const
overridevirtual

expose as GObject \for_internal_use_only

Implements mousetrap::SignalEmitter.

◆ select()

void mousetrap::SelectionModel::select ( uint64_t  i,
bool  unselect_others = true 
)

select item at specific index

Parameters
iindex
unselect_othersif selection mode is multiple, should all other items be unselected

◆ set_allow_no_selection_if_single()

void mousetrap::SelectionModel::set_allow_no_selection_if_single ( bool  b)

if the selection mode is SelectionMode::SINGLE, determines whether no items can be selected

Parameters
btrue to allow no selection

References mousetrap::log::warning().

◆ unselect()

void mousetrap::SelectionModel::unselect ( uint64_t  i)

unselect item at specific item

Parameters
iindex

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