tbx  0.7.6
Classes | Public Member Functions | Protected Member Functions | List of all members
tbx::view::SingleSelection Class Reference

Class to represent a single selection. More...

#include <selection.h>

Inheritance diagram for tbx::view::SingleSelection:
tbx::view::Selection

Classes

class  SingleIteratorImpl
 Class derived to implement iterator. More...
 

Public Member Functions

virtual Type type () const
 Returns the type of this selection class.
 
virtual bool selected (unsigned int index) const
 Returns true if an item is selected. More...
 
virtual unsigned int first () const
 Returns first selected item. More...
 
virtual unsigned int last () const
 Returns last selected item.
 
virtual bool empty () const
 Returns true if selection is empty.
 
virtual unsigned int count () const
 Return the number of selected items.
 
virtual bool any () const
 Returns true if one or more items are selected.
 
virtual bool one () const
 Returns true if only one item is selected.
 
virtual bool many () const
 Always returns false. More...
 
virtual void inserted (unsigned int index, unsigned int count)
 Called by the object selection is on when new items have been inserted and selected item need to be moved. More...
 
virtual void removed (unsigned int index, unsigned int count)
 Called by the object selection is on when items have been removed and selected item to be deleted or moved. More...
 
virtual void clear ()
 Clear the current selection.
 
virtual void set (unsigned int index)
 Select an item. More...
 
virtual void select (unsigned int index)
 Select an item. More...
 
virtual void deselect (unsigned int index)
 Clear the selection for an item. More...
 
virtual void toggle (unsigned int index)
 Toggle the selection for an item. More...
 
virtual void set (unsigned int from, unsigned int to)
 Set the selection a range of items. More...
 
virtual void select (unsigned int from, unsigned int to)
 Selection a range of items. More...
 
virtual void deselect (unsigned int from, unsigned int to)
 Deselect a range of items. More...
 
virtual void toggle (unsigned int from, unsigned int to)
 Toggle the selection of a range of items. More...
 
- Public Member Functions inherited from tbx::view::Selection
void add_listener (SelectionListener *listener)
 Add listeners. More...
 
void remove_listener (SelectionListener *listener)
 Remove listener for selection changes.
 
Iterator begin () const
 Get iterator to first selected item. More...
 
Iterator end () const
 Get iterator to end of selection. More...
 

Protected Member Functions

virtual IteratorImplget_iterator_impl () const
 Override to return the iterator implementation for the selection iterator to used. More...
 
- Protected Member Functions inherited from tbx::view::Selection
 Selection ()
 Protected constructor, must always use a subclass.
 
void fire_event (const SelectionChangedEvent &event)
 Helper for subclasses to fire Selection Changed Events.
 
void fire_event (unsigned int index, bool selected, bool final)
 Helper for subclasses to fire Selection Changed Events.
 
void fire_event (unsigned int from, unsigned int to, bool selected, bool final)
 Helper for subclasses to fire Selection Changed Events.
 

Additional Inherited Members

- Public Types inherited from tbx::view::Selection
enum  Type { NONE, SINGLE, MULTIPLE }
 Type of selection.
 
- Static Public Attributes inherited from tbx::view::Selection
static const unsigned int NO_SELECTION = -1
 Constant for indices when there is no selection.
 

Detailed Description

Class to represent a single selection.

Member Function Documentation

◆ deselect() [1/2]

void tbx::view::SingleSelection::deselect ( unsigned int  from,
unsigned int  to 
)
virtual

Deselect a range of items.

For a single selection from and to must be identical

Parameters
fromfirst index to deselect
tolast index to deselect
Exceptions
std::runtime_errorif from != to

Implements tbx::view::Selection.

◆ deselect() [2/2]

void tbx::view::SingleSelection::deselect ( unsigned int  index)
virtual

Clear the selection for an item.

Parameters
indexto deselect

Implements tbx::view::Selection.

◆ first()

virtual unsigned int tbx::view::SingleSelection::first ( ) const
inlinevirtual

Returns first selected item.

Only one item is ever selected so first() always equals last().

Implements tbx::view::Selection.

◆ get_iterator_impl()

virtual IteratorImpl* tbx::view::SingleSelection::get_iterator_impl ( ) const
inlineprotectedvirtual

Override to return the iterator implementation for the selection iterator to used.

Returns
Iterator implementation for this selection type.

Implements tbx::view::Selection.

◆ inserted()

void tbx::view::SingleSelection::inserted ( unsigned int  index,
unsigned int  count 
)
virtual

Called by the object selection is on when new items have been inserted and selected item need to be moved.

Parameters
indexof the insertion
countof items inserted

Implements tbx::view::Selection.

◆ many()

virtual bool tbx::view::SingleSelection::many ( ) const
inlinevirtual

Always returns false.

This class has a maximum of one selection

Implements tbx::view::Selection.

◆ removed()

void tbx::view::SingleSelection::removed ( unsigned int  index,
unsigned int  count 
)
virtual

Called by the object selection is on when items have been removed and selected item to be deleted or moved.

Parameters
indexof the insertion
countof items inserted

Implements tbx::view::Selection.

◆ select() [1/2]

void tbx::view::SingleSelection::select ( unsigned int  from,
unsigned int  to 
)
virtual

Selection a range of items.

For a single selection from and to must be identical and this is equivalent to set(from).

Parameters
fromfirst index to select
tolast index to select
Exceptions
std::runtime_errorif from != to

Implements tbx::view::Selection.

◆ select() [2/2]

void tbx::view::SingleSelection::select ( unsigned int  index)
virtual

Select an item.

Causes current item to be deselected so in this case is identical to set(index)

Parameters
indexto select

Implements tbx::view::Selection.

◆ selected()

virtual bool tbx::view::SingleSelection::selected ( unsigned int  index) const
inlinevirtual

Returns true if an item is selected.

Parameters
indexof item to test

Implements tbx::view::Selection.

◆ set() [1/2]

void tbx::view::SingleSelection::set ( unsigned int  from,
unsigned int  to 
)
virtual

Set the selection a range of items.

For a single selection from and to must be identical

Parameters
fromfirst index to select
tolast index to select
Exceptions
std::runtime_errorif from != to

Implements tbx::view::Selection.

◆ set() [2/2]

void tbx::view::SingleSelection::set ( unsigned int  index)
virtual

Select an item.

Caused current selected item to be deselected.

Parameters
indexto select

Implements tbx::view::Selection.

◆ toggle() [1/2]

void tbx::view::SingleSelection::toggle ( unsigned int  from,
unsigned int  to 
)
virtual

Toggle the selection of a range of items.

For a single selection from and to must be identical

Parameters
fromfirst index to toggle
tolast index to toggle
Exceptions
std::runtime_errorif from != to

Implements tbx::view::Selection.

◆ toggle() [2/2]

void tbx::view::SingleSelection::toggle ( unsigned int  index)
virtual

Toggle the selection for an item.

Parameters
indexto toggle

Implements tbx::view::Selection.


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