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 58 of file SelectionState.h.

Constructor & Destructor Documentation

◆ SelectionStateChanger() [1/2]

SelectionStateChanger::SelectionStateChanger ( SelectionState state,
TrackList tracks 
)

Definition at line 154 of file SelectionState.cpp.

156 : mpState{ &state }
157 , mTracks{ tracks }
159{
160 // Save initial state of track selections
161 const auto range = tracks.Any();
163 mInitialTrackSelection.reserve(range.size());
164 for (const auto track : range) {
165 const bool isSelected = track->GetSelected();
166 mInitialTrackSelection.push_back(isSelected);
167 }
168}
const auto tracks
SelectionState * mpState
std::vector< bool > mInitialTrackSelection
std::weak_ptr< Track > mInitialLastPickedTrack
std::weak_ptr< Track > mLastPickedTrack

References mInitialTrackSelection, and tracks.

◆ SelectionStateChanger() [2/2]

SelectionStateChanger::SelectionStateChanger ( const SelectionStateChanger )
delete

◆ ~SelectionStateChanger()

SelectionStateChanger::~SelectionStateChanger ( )

Definition at line 170 of file SelectionState.cpp.

171{
172 if ( mpState ) {
173 // roll back changes
175 std::vector<bool>::const_iterator
176 it = mInitialTrackSelection.begin(),
178
179 for (auto track : mTracks) {
180 if (it == end)
181 break;
182 track->SetSelected( *it++ );
183 }
184 }
185}
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References details::end(), 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 187 of file SelectionState.cpp.

188{
189 mpState = nullptr;
190}

References mpState.

◆ operator=()

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

Member Data Documentation

◆ mInitialLastPickedTrack

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

Definition at line 71 of file SelectionState.h.

Referenced by ~SelectionStateChanger().

◆ mInitialTrackSelection

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

Definition at line 72 of file SelectionState.h.

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

◆ mpState

SelectionState* SelectionStateChanger::mpState
private

Definition at line 69 of file SelectionState.h.

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

◆ mTracks

TrackList& SelectionStateChanger::mTracks
private

Definition at line 70 of file SelectionState.h.

Referenced by ~SelectionStateChanger().


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