Audacity  3.2.0
Public Member Functions | Private Attributes | List of all members
SelectionStateChanger Class Reference

#include <SelectionState.h>

Collaboration diagram for SelectionStateChanger:
[legend]

Public Member Functions

 SelectionStateChanger (SelectionState &state, TrackList &tracks)
 
 SelectionStateChanger (const SelectionStateChanger &)=delete
 
SelectionStateChangeroperator= (const SelectionStateChanger &)=delete
 
 ~SelectionStateChanger ()
 
void Commit ()
 

Private Attributes

SelectionStatempState
 
TrackListmTracks
 
std::weak_ptr< TrackmInitialLastPickedTrack
 
std::vector< bool > mInitialTrackSelection
 

Detailed Description

Definition at line 55 of file SelectionState.h.

Constructor & Destructor Documentation

◆ SelectionStateChanger() [1/2]

SelectionStateChanger::SelectionStateChanger ( SelectionState state,
TrackList tracks 
)

Definition at line 146 of file SelectionState.cpp.

148  : mpState{ &state }
149  , mTracks{ tracks }
151 {
152  // Save initial state of track selections
153  mInitialTrackSelection.clear();
154  for (const auto track : tracks.Any()) {
155  const bool isSelected = track->GetSelected();
156  mInitialTrackSelection.push_back(isSelected);
157  }
158 }

◆ SelectionStateChanger() [2/2]

SelectionStateChanger::SelectionStateChanger ( const SelectionStateChanger )
delete

◆ ~SelectionStateChanger()

SelectionStateChanger::~SelectionStateChanger ( )

Definition at line 160 of file SelectionState.cpp.

161 {
162  if ( mpState ) {
163  // roll back changes
165  std::vector<bool>::const_iterator
166  it = mInitialTrackSelection.begin(),
167  end = mInitialTrackSelection.end();
168 
169  for (auto track : mTracks.Any()) {
170  if (it == end)
171  break;
172  track->SetSelected( *it++ );
173  }
174  }
175 }

References TrackList::Any(), mInitialLastPickedTrack, mInitialTrackSelection, SelectionState::mLastPickedTrack, mpState, and mTracks.

Here is the call graph for this function:

Member Function Documentation

◆ Commit()

void SelectionStateChanger::Commit ( )

Definition at line 177 of file SelectionState.cpp.

178 {
179  mpState = nullptr;
180 }

References mpState.

◆ operator=()

SelectionStateChanger& SelectionStateChanger::operator= ( const SelectionStateChanger )
delete

Member Data Documentation

◆ mInitialLastPickedTrack

std::weak_ptr<Track> SelectionStateChanger::mInitialLastPickedTrack
private

Definition at line 68 of file SelectionState.h.

Referenced by ~SelectionStateChanger().

◆ mInitialTrackSelection

std::vector<bool> SelectionStateChanger::mInitialTrackSelection
private

Definition at line 69 of file SelectionState.h.

Referenced by ~SelectionStateChanger().

◆ mpState

SelectionState* SelectionStateChanger::mpState
private

Definition at line 66 of file SelectionState.h.

Referenced by Commit(), and ~SelectionStateChanger().

◆ mTracks

TrackList& SelectionStateChanger::mTracks
private

Definition at line 67 of file SelectionState.h.

Referenced by ~SelectionStateChanger().


The documentation for this class was generated from the following files:
SelectionState::mLastPickedTrack
std::weak_ptr< Track > mLastPickedTrack
Definition: SelectionState.h:50
SelectionStateChanger::mTracks
TrackList & mTracks
Definition: SelectionState.h:67
SelectionStateChanger::mpState
SelectionState * mpState
Definition: SelectionState.h:66
TrackList::Any
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1379
SelectionStateChanger::mInitialLastPickedTrack
std::weak_ptr< Track > mInitialLastPickedTrack
Definition: SelectionState.h:68
SelectionStateChanger::mInitialTrackSelection
std::vector< bool > mInitialTrackSelection
Definition: SelectionState.h:69