#include <TrackSelection.h>
Inheritance diagram for TSE3::App::TrackSelection:
Public Types | |
typedef std::vector< TSE3::Track * >::const_iterator | iterator_t |
Public Member Functions | |
TrackSelection () | |
~TrackSelection () | |
TrackSelection (const TrackSelection &) | |
void | select (TSE3::Track *track, bool add) |
void | deselect (TSE3::Track *track) |
void | clear () |
void | selectAll (TSE3::Song *song) |
void | invert (TSE3::Song *song) |
TrackSelection & | operator= (const TrackSelection &) |
size_t | size () const |
bool | isSelected (TSE3::Track *track) const |
Track * | front () const |
Track * | back () const |
iterator_t | begin () const |
iterator_t | end () const |
virtual void | Track_Reparented (Track *) |
virtual void | Notifier_Deleted (Track *) |
virtual void | PartSelection_Selected (PartSelection *, TSE3::Part *, bool) |
The TrackSelection class allows an Application to provide the facility to 'select' one or more TSE3::Track in a TSE3::Song. These TSE3::Track objects must be held in a TSE3::Song. As soon as a TSE3::Track is removed from a TSE3::Song, it is removed from the selection.
This behviour is useful when using the command history system in the TSE3::Cmd namespace where undoing a TSE3::Track add, for example, may cause a selected Track to be removed from the TSE3::Song.
Internally, the Tracks are held in an STL vector of type <Track*>. In order to get access to the contents of this vector, access is provided to it's iterator.
If you are using the iterators and performing any operations that may affect the TrackSelection (i.e. removing a TSE3::Track from it's TSE3::Track and reinserting it elsewhere) then you will invalidate the iterator.
A method of avoiding this would be to, rather than iterate over each Track, to remove a Track from the head of the list, work on it, and place it into a second TrackSelection. Do this for each Track in the TrackSelection, and when finished, copy the new TrackSelection into the old one.
To facilitate this, the TrackSelection is a PartSelectionListener. You can attach it to a PartSelection object, and whenever the PartSelection has a TSE3::Part selected the TrackSelection will be cleared.
You will need to use an attach like this:
TrackSelection ts; PartSelection *ps = somePartSelection(); ts.TSE3::Listener<TSE3::App::PartSelectionListener>::attachTo(ps);
|
|
|
The TrackSelection begins with no Track selected. |
|
|
|
|
|
Selects a TSE3::Track. If the TSE3::Track is not in a TSE3::Song, it will not be selected.
|
|
Deselects a Track. If the Track is not selected, then nothing will happen.
|
|
Clears the entire selection. |
|
Selects all the TSE3::Track objects in the given TSE3::Song (this 'should' include any Tracks alreadys selected!).
|
|
Inverts the selection for all the TSE3::Track objects in the given TSE3::Song (i.e. all selected Tracks are deselected and all deselected Tracks are selected).
|
|
Copy TrackSelection contents. |
|
Returns how many TSE3::Track objects are selected.
|
|
Returns whether a particular TSE3::Track is selected.
|
|
Returns the first item in the TrackSelection, or zero if there are no selected Tracks.
|
|
Returns the last item in the TrackSelection, or zero if there are no selected Tracks.
|
|
Returns an iterator pointing to the first TSE3::Track in this selection.
|
|
Returns an iterator pointing to the last TSE3::Track in this selection.
|
|
Reimplemented from TSE3::TrackListener. |
|
|
|
|