41#include <wx/filename.h>
42#include <wx/listctrl.h>
45#include <wx/clipbrd.h>
46#include <wx/dataobj.h>
48#include <wx/stattext.h>
50#include "blockfile/SimpleBlockFile.h"
51#include "DirManager.h"
60#include "widgets/AudacityMessageBox.h"
61#include "widgets/ProgressDialog.h"
63#include <unordered_map>
79 for(
const auto &clip : waveTrack->GetAllClips()) {
80 Sequence *sequence = clip->GetSequence();
82 for (
size_t i = 0; i < blocks.size(); i++)
83 outBlocks->push_back(&blocks[i]);
97 for (
const auto &pBlock : blocks) {
100 if (hash.count( src ) > 0) {
101 const auto &dst = hash[src];
118 for (
const auto &blockFile : blocks) {
119 const auto &f = blockFile->f;
120 if (f->IsAlias() && (blockFileHash.count( &*f ) == 0))
123 blockFileHash[ &*f ] =
true;
124 auto aliasBlockFile =
static_cast<AliasBlockFile*
>( &*f );
125 const wxFileName &fileName = aliasBlockFile->GetAliasedFileName();
130 if (!fileName.IsOk())
133 const wxString &fileNameStr = fileName.GetFullPath();
135 aliasBlockFile->GetLength());
136 if (aliasedFileHash.count(fileNameStr) > 0)
139 aliasedFileHash[fileNameStr]->mByteCount += blockBytes;
148 outAliasedFiles.back() =
151 wxLongLong(blockBytes), fileName.FileExists()
153 aliasedFileHash[fileNameStr] = &outAliasedFiles.back();
169 XO(
"Removing Dependencies"),
170 XO(
"Copying audio data into project..."));
176 wxLongLong totalBytesToProcess = 0;
177 for (
auto &aliasedFile : aliasedFiles) {
178 totalBytesToProcess += aliasedFile.mByteCount;
179 const wxString &fileNameStr = aliasedFile.mFileName.GetFullPath();
180 aliasedFileHash[fileNameStr] = &aliasedFile;
188 wxLongLong completedBytes = 0;
189 for (
const auto blockFile : blocks) {
190 const auto &f = blockFile->f;
191 if (f->IsAlias() && (blockFileHash.count( &*f ) == 0))
194 auto aliasBlockFile =
static_cast<AliasBlockFile*
>( &*f );
195 const wxFileName &fileName = aliasBlockFile->GetAliasedFileName();
196 const wxString &fileNameStr = fileName.GetFullPath();
198 if (aliasedFileHash.count(fileNameStr) == 0)
203 auto len = aliasBlockFile->GetLength();
204 BlockFilePtr newBlockFile;
209 f->ReadData(buffer.
ptr(),
format, 0, len);
212 return make_blockfile<SimpleBlockFile>(
213 std::move(filePath), buffer.
ptr(), len,
format);
218 blockFileHash[ &*f ] = newBlockFile;
222 updateResult = progress.
Update(completedBytes, totalBytesToProcess);
258 void OnList(wxListEvent &evt);
259 void OnSize(wxSizeEvent &evt);
260 void OnNo(wxCommandEvent &evt);
261 void OnYes(wxCommandEvent &evt);
282 DECLARE_EVENT_TABLE()
310 wxDefaultPosition, wxDefaultSize,
312 (wxDEFAULT_DIALOG_STYLE & ~wxCLOSE_BOX) :
313 wxDEFAULT_DIALOG_STYLE) |
316 mAliasedFiles(aliasedFiles),
318 mHasMissingFiles(false),
319 mHasNonMissingFiles(false),
320 mMessageStaticText(NULL),
322 mCopySelectedFilesButton(NULL),
323 mCopyAllFilesButton(NULL),
324 mFutureActionChoice(NULL)
328 PopulateOrExchange(
S);
334XO(
"Copying these files into your project will remove this dependency.\
335\nThis is safer, but needs more disk space.");
341XO(
"\n\nFiles shown as MISSING have been moved or deleted and cannot be copied.\
342\nRestore them to their original location to be able to copy into project.");
348 S.StartVerticalLay();
352 S.StartStatic(
XO(
"Project Dependencies"),1);
355 {
XO(
"Audio File"), wxLIST_FORMAT_LEFT, 220 },
356 {
XO(
"Disk Space"), wxLIST_FORMAT_LEFT, 120 }
365 XXO(
"Copy Selected Files"),
370 S.StartHorizontalLay(wxALIGN_CENTRE,0);
373 S.Id(wxID_CANCEL).AddButton(
XXO(
"Cancel Save"));
374 S.Id(wxID_NO).AddButton(
XXO(
"Save Without Copying"));
377 S.Id(wxID_NO).AddButton(
XXO(
"Do Not Copy"));
384 .AddButton(
XXO(
"Copy All Files (Safer)"));
387 S.EndHorizontalLay();
391 S.StartHorizontalLay(wxALIGN_LEFT,0);
395 XXO(
"Whenever a project depends on other files:"),
402 XO(
"Always copy all files (safest)") ,
405 XO(
"Never copy any files") ,
410 S.EndHorizontalLay();
420 SetMinSize(GetSize());
432 const wxFileName &fileName = aliasedFile.mFileName;
433 wxLongLong byteCount = (aliasedFile.mByteCount * 124) / 100;
434 bool bOriginalExists = aliasedFile.mbOriginalExists;
440 mFileListCtrl->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
445 wxString::Format(
_(
"MISSING %s"), fileName.GetFullPath() ) );
470 wxString itemStr = evt.GetText();
471 if (evt.GetData() == 0)
476 mFileListCtrl->SetItemState(evt.GetIndex(), 0, wxLIST_STATE_SELECTED);
484 int fileListCtrlWidth, fileListCtrlHeight;
485 mFileListCtrl->GetSize(&fileListCtrlWidth, &fileListCtrlHeight);
490 mFileListCtrl->SetColumnWidth(0, fileListCtrlWidth - 120 - 8);
514 aliasedFilesToDelete.push_back( file );
516 remainingAliasedFiles.push_back( file );
536 static_cast<void>(event);
546 const wxFileName & fileName = aliasedFile.mFileName;
547 wxLongLong byteCount = (aliasedFile.mByteCount * 124) / 100;
548 bool bOriginalExists = aliasedFile.mbOriginalExists;
550 Files +=
XO(
"\"%s\", \"%s\", \"%s\"\n").Format(
551 fileName.GetFullPath(),
553 bOriginalExists ?
XO(
"OK") :
XO(
"Missing") );
557 if (wxTheClipboard->Open()) {
560 wxTheClipboard->Close();
570"If you proceed, your project will not be saved to disk. Is this what you want?"),
572 wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT,
this);
577 EndModal(wxID_CANCEL);
588 case 1: savePref =
wxT(
"copy");
break;
589 case 2: savePref =
wxT(
"never");
break;
590 default: savePref =
wxT(
"ask");
592 FileFormatsSaveWithDependenciesSetting.Write( savePref );
607 if (aliasedFiles.empty()) {
611XO(
"Your project is self-contained; it does not depend on any external audio files. \
612\n\nSome older Audacity projects may not be self-contained, and care \n\
613is needed to keep their external dependencies in the right place.\n\
614New projects will be self-contained and are less risky.");
617 XO(
"Dependency Check"),
618 wxOK | wxICON_INFORMATION,
631 int returnCode = dlog.ShowModal();
632 if (returnCode == wxID_CANCEL)
634 else if (returnCode == wxID_YES)
EVT_MENU(OnSetPlayRegionToSelectionID, AdornedRulerPanel::OnSetPlayRegionToSelection) EVT_COMMAND(OnTogglePinnedStateID
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static const TranslatableString kStdMsg()
std::unordered_map< BlockFile *, bool > BoolBlockFileHash
static const TranslatableString kExtraMsgForMissingFiles()
static void RemoveDependencies(AudacityProject *project, AliasedFileArray &aliasedFiles)
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
bool ShowDependencyDialogIfNeeded(AudacityProject *project, bool isSaving)
static void GetAllSeqBlocks(AudacityProject *project, BlockPtrArray *outBlocks)
void FindDependencies(AudacityProject *project, AliasedFileArray &outAliasedFiles)
@ CopySelectedFilesButtonID
std::unordered_map< wxString, AliasedFile * > AliasedFileHash
static void ReplaceBlockFiles(BlockPtrArray &blocks, ReplacedBlockFileHash &hash)
std::unordered_map< BlockFile *, BlockFilePtr > ReplacedBlockFileHash
std::list< AliasedFile > AliasedFileArray
EVT_LIST_ITEM_SELECTED(CurvesListID, EqualizationCurvesDialog::OnListSelectionChange) EVT_LIST_ITEM_DESELECTED(CurvesListID
XXO("&Cut/Copy/Paste Toolbar")
audacity::BasicSettings * gPrefs
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
std::deque< SeqBlock * > BlockPtrArray
static void OnSize(wxSizeEvent &evt)
An audio file that is referenced (pointed into) directly from an Audacity .aup file rather than Audac...
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
DependencyDialog shows dependencies of an AudacityProject on AliasedFile s.
void OnList(wxListEvent &evt)
void OnCopyToClipboard(wxCommandEvent &evt)
wxListCtrl * mFileListCtrl
wxChoice * mFutureActionChoice
void OnYes(wxCommandEvent &evt)
void OnRightClick(wxListEvent &evt)
AudacityProject * mProject
wxButton * mCopyAllFilesButton
void OnCancel(wxCommandEvent &evt)
DependencyDialog(wxWindow *parent, wxWindowID id, AudacityProject *project, AliasedFileArray &aliasedFiles, bool isSaving)
AliasedFileArray & mAliasedFiles
void PopulateOrExchange(ShuttleGui &S)
wxButton * mCopySelectedFilesButton
wxStaticText * mMessageStaticText
void OnNo(wxCommandEvent &evt)
void OnSize(wxSizeEvent &evt)
void OnCopySelectedFiles(wxCommandEvent &evt)
void SaveFutureActionChoice()
static TranslatableString FormatSize(wxLongLong size)
Convert a number to a string while formatting it in bytes, KB, MB, GB.
ProgressResult Update(int value, const TranslatableString &message={})
A WaveTrack contains WaveClip(s). A WaveClip contains a Sequence. A Sequence is primarily an interfac...
const BlockArray & GetBlockArray() const
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
auto Any() -> TrackIterRange< TrackType >
static TrackList & Get(AudacityProject &project)
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const
A Track that contains audio waveform data.
virtual bool Flush() noexcept=0
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
PROJECT_RATE_API sampleFormat SampleFormatChoice()
constexpr auto Project
Return a tuple of values initialized from a subsequence of a tuple.