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

Method DoRemoveTracks

src/TrackUtilities.cpp:19–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include "Viewport.h"
18
19void TrackUtilities::DoRemoveTracks(AudacityProject &project) {
20 auto &tracks = TrackList::Get(project);
21 auto &trackPanel = TrackPanel::Get(project);
22
23 auto range = tracks.Selected();
24 using Iter = decltype(range.begin());
25
26 // Find the track preceding the first removed track
27 std::optional<Iter> focus;
28 if (!range.empty()) {
29 auto iter = tracks.Find(*range.begin());
30 // TrackIter allows decrement even of begin iterators
31 focus.emplace(--iter);
32 }
33
34 while (!range.empty())
35 tracks.Remove(**range.first++);
36
37 if (!(focus.has_value() && **focus))
38 // try to use the last track
39 focus.emplace(tracks.end().advance(-1));
40 assert(focus);
41 Track *f = **focus;
42 // Try to use the first track after the removal
43 // TrackIter allows increment even of end iterators
44 if (const auto nextF = * ++ *focus)
45 f = nextF;
46
47 // If we actually have something left, then set focus and make sure it's seen
48 if (f) {
49 TrackFocus::Get(project).Set(f);
50 Viewport::Get(project).ShowTrack(*f);
51 }
52
53 ProjectHistory::Get(project)
54 .PushState(XO("Removed audio track(s)"), XO("Remove Track"));
55
56 trackPanel.UpdateViewIfNoTracks();
57}
58
59void TrackUtilities::DoTrackMute(
60 AudacityProject &project, Track &track, bool exclusive)

Callers

nothing calls this directly

Calls 13

GetFunction · 0.85
emplaceMethod · 0.80
has_valueMethod · 0.80
ShowTrackMethod · 0.80
UpdateViewIfNoTracksMethod · 0.80
beginMethod · 0.45
emptyMethod · 0.45
FindMethod · 0.45
RemoveMethod · 0.45
advanceMethod · 0.45
endMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected