MCPcopy Create free account
hub / github.com/audacity/audacity / DoRemoveTrack

Method DoRemoveTrack

src/TrackUtilities.cpp:143–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143void TrackUtilities::DoRemoveTrack(AudacityProject &project, Track &toRemove)
144{
145 auto &tracks = TrackList::Get(project);
146 auto &trackFocus = TrackFocus::Get(project);
147
148 const auto iter = tracks.Find(&toRemove);
149
150 // If it was focused, then NEW focus is the next or, if
151 // unavailable, the previous track. (The NEW focus is set
152 // after the track has been removed.)
153 bool toRemoveWasFocused = trackFocus.Get() == *iter;
154 std::optional<decltype(iter)> newFocus{};
155 if (toRemoveWasFocused) {
156 auto iterNext = iter,
157 iterPrev = iter;
158 newFocus.emplace(++iterNext);
159 if (!**newFocus)
160 newFocus.emplace(--iterPrev);
161 }
162
163 wxString name = toRemove.GetName();
164
165 tracks.Remove(**iter);
166
167 if (toRemoveWasFocused)
168 trackFocus.Set(**newFocus);
169
170 ProjectHistory::Get(project).PushState(
171 XO("Removed track '%s'.").Format(name),
172 XO("Track Remove"));
173}
174
175void TrackUtilities::DoMoveTrack(
176 AudacityProject &project, Track& target, MoveChoice choice)

Callers

nothing calls this directly

Calls 8

GetFunction · 0.85
emplaceMethod · 0.80
FindMethod · 0.45
GetMethod · 0.45
GetNameMethod · 0.45
RemoveMethod · 0.45
SetMethod · 0.45
PushStateMethod · 0.45

Tested by

no test coverage detected