mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-18 17:10:55 +02:00
More simplifications by use of SelectionStateChanger
This commit is contained in:
parent
d834bcdbd1
commit
6b5c5a0335
@ -4073,7 +4073,7 @@ bool AudacityProject::Save(bool overwrite /* = true */ ,
|
||||
{
|
||||
if (pTrack->GetKind() == Track::Wave)
|
||||
{
|
||||
auto wasSelected = pTrack->GetSelected();
|
||||
SelectionStateChanger changer{ GetSelectionState(), *GetTracks() };
|
||||
pTrack->SetSelected(true);
|
||||
if (pTrack->GetLinked())
|
||||
{
|
||||
@ -4083,14 +4083,6 @@ bool AudacityProject::Save(bool overwrite /* = true */ ,
|
||||
else
|
||||
pRightTrack = NULL;
|
||||
|
||||
auto cleanup = finally( [&] {
|
||||
if (!wasSelected) {
|
||||
pTrack->SetSelected(false);
|
||||
if (pRightTrack)
|
||||
pRightTrack->SetSelected(false);
|
||||
}
|
||||
} );
|
||||
|
||||
uniqueTrackFileName = wxFileName(strDataDirPathName, pTrack->GetName(), wxT("ogg"));
|
||||
FileNames::MakeNameUnique(mStrOtherNamesArray, uniqueTrackFileName);
|
||||
bSuccess =
|
||||
|
@ -105,6 +105,7 @@ END_EVENT_TABLE()
|
||||
|
||||
ExportMultiple::ExportMultiple(AudacityProject *project)
|
||||
: wxDialogWrapper(project, wxID_ANY, wxString(_("Export Multiple")))
|
||||
, mSelectionState{ project->GetSelectionState() }
|
||||
{
|
||||
SetName(GetTitle());
|
||||
|
||||
@ -777,8 +778,6 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName,
|
||||
int l = 0; // track counter
|
||||
auto ok = ProgressResult::Success;
|
||||
wxArrayString otherNames;
|
||||
std::vector<Track*> selected; /**< Array of pointers to the tracks which were
|
||||
selected when we started */
|
||||
ExportKitArray exportSettings; // dynamic array we will use to store the
|
||||
// settings needed to do the exports with in
|
||||
exportSettings.Alloc(mNumWaveTracks); // Allocate some guessed space to use.
|
||||
@ -790,24 +789,17 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName,
|
||||
wxString title; // un-messed-with title of file for tagging with
|
||||
|
||||
/* Remember which tracks were selected, and set them to unselected */
|
||||
SelectionStateChanger changer{ mSelectionState, *mTracks };
|
||||
TrackListIterator iter;
|
||||
for (tr = iter.First(mTracks); tr != NULL; tr = iter.Next()) {
|
||||
if (tr->GetKind() != Track::Wave) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tr->GetSelected()) {
|
||||
selected.push_back(tr);
|
||||
if (tr->GetSelected())
|
||||
tr->SetSelected(false);
|
||||
}
|
||||
}
|
||||
|
||||
auto cleanup = finally( [&] {
|
||||
// Restore the selection states
|
||||
for (auto pTrack : selected)
|
||||
pTrack->SetSelected(true);
|
||||
} );
|
||||
|
||||
/* Examine all tracks in turn, collecting export information */
|
||||
for (tr = iter.First(mTracks); tr != NULL; tr = iter.Next()) {
|
||||
|
||||
@ -922,22 +914,11 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName,
|
||||
}
|
||||
|
||||
/* Select the track */
|
||||
auto wasSelected = tr->GetSelected();
|
||||
SelectionStateChanger changer2{ mSelectionState, *mTracks };
|
||||
tr->SetSelected(true);
|
||||
if (tr2) {
|
||||
if (tr2)
|
||||
// Select it also
|
||||
tr2->SetSelected(true);
|
||||
}
|
||||
|
||||
auto cleanup = finally( [&] {
|
||||
if (!wasSelected) {
|
||||
// Reset selection state
|
||||
tr->SetSelected(false);
|
||||
if (tr2) {
|
||||
tr2->SetSelected(false);
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// Export the data. "channels" are per track.
|
||||
ok = DoExport(activeSetting.channels, activeSetting.destfile, true, activeSetting.t0, activeSetting.t1, activeSetting.filetags);
|
||||
|
@ -28,6 +28,7 @@ class wxTextCtrl;
|
||||
|
||||
class AudacityProject;
|
||||
class LabelTrack;
|
||||
class SelectionState;
|
||||
class ShuttleGui;
|
||||
class Track;
|
||||
|
||||
@ -160,6 +161,8 @@ private:
|
||||
|
||||
wxSimplebook *mBook;
|
||||
|
||||
SelectionState &mSelectionState;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user