43#include <wx/filename.h>
44#include <wx/listctrl.h>
47#include <wx/clipbrd.h>
48#include <wx/dataobj.h>
50#include <wx/stattext.h>
52#include "blockfile/SimpleBlockFile.h"
53#include "DirManager.h"
65#include <unordered_map>
81 for(
const auto &clip : waveTrack->GetAllClips()) {
82 Sequence *sequence = clip->GetSequence();
84 for (
size_t i = 0; i < blocks.size(); i++)
85 outBlocks->push_back(&blocks[i]);
99 for (
const auto &pBlock : blocks) {
101 const auto src = &*f;
102 if (hash.count( src ) > 0) {
103 const auto &dst = hash[src];
120 for (
const auto &blockFile : blocks) {
121 const auto &f = blockFile->f;
122 if (f->IsAlias() && (blockFileHash.count( &*f ) == 0))
125 blockFileHash[ &*f ] =
true;
126 auto aliasBlockFile =
static_cast<AliasBlockFile*
>( &*f );
127 const wxFileName &fileName = aliasBlockFile->GetAliasedFileName();
132 if (!fileName.IsOk())
135 const wxString &fileNameStr = fileName.GetFullPath();
137 aliasBlockFile->GetLength());
138 if (aliasedFileHash.count(fileNameStr) > 0)
141 aliasedFileHash[fileNameStr]->mByteCount += blockBytes;
150 outAliasedFiles.back() =
153 wxLongLong(blockBytes), fileName.FileExists()
155 aliasedFileHash[fileNameStr] = &outAliasedFiles.back();
171 XO(
"Removing Dependencies"),
172 XO(
"Copying audio data into project..."));
178 wxLongLong totalBytesToProcess = 0;
179 for (
auto &aliasedFile : aliasedFiles) {
180 totalBytesToProcess += aliasedFile.mByteCount;
181 const wxString &fileNameStr = aliasedFile.mFileName.GetFullPath();
182 aliasedFileHash[fileNameStr] = &aliasedFile;
190 wxLongLong completedBytes = 0;
191 for (
const auto blockFile : blocks) {
192 const auto &f = blockFile->f;
193 if (f->IsAlias() && (blockFileHash.count( &*f ) == 0))
196 auto aliasBlockFile =
static_cast<AliasBlockFile*
>( &*f );
197 const wxFileName &fileName = aliasBlockFile->GetAliasedFileName();
198 const wxString &fileNameStr = fileName.GetFullPath();
200 if (aliasedFileHash.count(fileNameStr) == 0)
205 auto len = aliasBlockFile->GetLength();
206 BlockFilePtr newBlockFile;
211 f->ReadData(buffer.
ptr(),
format, 0, len);
214 return make_blockfile<SimpleBlockFile>(
215 std::move(filePath), buffer.
ptr(), len,
format);
220 blockFileHash[ &*f ] = newBlockFile;
224 updateResult = progress.
Update(completedBytes, totalBytesToProcess);
260 void OnList(wxListEvent &evt);
261 void OnSize(wxSizeEvent &evt);
262 void OnNo(wxCommandEvent &evt);
263 void OnYes(wxCommandEvent &evt);
284 DECLARE_EVENT_TABLE()
312 wxDefaultPosition, wxDefaultSize,
314 (wxDEFAULT_DIALOG_STYLE & ~wxCLOSE_BOX) :
315 wxDEFAULT_DIALOG_STYLE) |
318 mAliasedFiles(aliasedFiles),
320 mHasMissingFiles(false),
321 mHasNonMissingFiles(false),
322 mMessageStaticText(NULL),
324 mCopySelectedFilesButton(NULL),
325 mCopyAllFilesButton(NULL),
326 mFutureActionChoice(NULL)
330 PopulateOrExchange(
S);
336XO(
"Copying these files into your project will remove this dependency.\
337\nThis is safer, but needs more disk space.");
343XO(
"\n\nFiles shown as MISSING have been moved or deleted and cannot be copied.\
344\nRestore them to their original location to be able to copy into project.");
350 S.StartVerticalLay();
354 S.StartStatic(
XO(
"Project Dependencies"),1);
357 {
XO(
"Audio File"), wxLIST_FORMAT_LEFT, 220 },
358 {
XO(
"Disk Space"), wxLIST_FORMAT_LEFT, 120 }
367 XXO(
"Copy Selected Files"),
372 S.StartHorizontalLay(wxALIGN_CENTRE,0);
375 S.Id(wxID_CANCEL).AddButton(
XXO(
"Cancel Save"));
376 S.Id(wxID_NO).AddButton(
XXO(
"Save Without Copying"));
379 S.Id(wxID_NO).AddButton(
XXO(
"Do Not Copy"));
386 .AddButton(
XXO(
"Copy All Files (Safer)"));
389 S.EndHorizontalLay();
393 S.StartHorizontalLay(wxALIGN_LEFT,0);
397 XXO(
"Whenever a project depends on other files:"),
404 XO(
"Always copy all files (safest)") ,
407 XO(
"Never copy any files") ,
412 S.EndHorizontalLay();
422 SetMinSize(GetSize());
434 const wxFileName &fileName = aliasedFile.mFileName;
435 wxLongLong byteCount = (aliasedFile.mByteCount * 124) / 100;
436 bool bOriginalExists = aliasedFile.mbOriginalExists;
442 mFileListCtrl->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
447 wxString::Format(
_(
"MISSING %s"), fileName.GetFullPath() ) );
472 wxString itemStr = evt.GetText();
473 if (evt.GetData() == 0)
478 mFileListCtrl->SetItemState(evt.GetIndex(), 0, wxLIST_STATE_SELECTED);
486 int fileListCtrlWidth, fileListCtrlHeight;
487 mFileListCtrl->GetSize(&fileListCtrlWidth, &fileListCtrlHeight);
492 mFileListCtrl->SetColumnWidth(0, fileListCtrlWidth - 120 - 8);
516 aliasedFilesToDelete.push_back( file );
518 remainingAliasedFiles.push_back( file );
538 static_cast<void>(event);
548 const wxFileName & fileName = aliasedFile.mFileName;
549 wxLongLong byteCount = (aliasedFile.mByteCount * 124) / 100;
550 bool bOriginalExists = aliasedFile.mbOriginalExists;
552 Files +=
XO(
"\"%s\", \"%s\", \"%s\"\n").Format(
553 fileName.GetFullPath(),
555 bOriginalExists ?
XO(
"OK") :
XO(
"Missing") );
559 if (wxTheClipboard->Open()) {
562 wxTheClipboard->Close();
572"If you proceed, your project will not be saved to disk. Is this what you want?"),
574 wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT,
this);
579 EndModal(wxID_CANCEL);
590 case 1: savePref = wxT(
"copy");
break;
591 case 2: savePref = wxT(
"never");
break;
592 default: savePref = wxT(
"ask");
609 if (aliasedFiles.empty()) {
613XO(
"Your project is self-contained; it does not depend on any external audio files. \
614\n\nSome older Audacity projects may not be self-contained, and care \n\
615is needed to keep their external dependencies in the right place.\n\
616New projects will be self-contained and are less risky.");
619 XO(
"Dependency Check"),
620 wxOK | wxICON_INFORMATION,
633 int returnCode = dlog.ShowModal();
634 if (returnCode == wxID_CANCEL)
636 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, EditCurvesDialog::OnListSelectionChange) EVT_LIST_ITEM_DESELECTED(CurvesListID
Constructor.
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
std::vector< 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...
bool Write(const wxString &value)
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()
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
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...
BlockArray & GetBlockArray()
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.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
PROJECT_RATE_API sampleFormat SampleFormatChoice()