Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DependencyDialog Class Referencefinal

DependencyDialog shows dependencies of an AudacityProject on AliasedFile s. More...

Inheritance diagram for DependencyDialog:
[legend]
Collaboration diagram for DependencyDialog:
[legend]

Public Member Functions

 DependencyDialog (wxWindow *parent, wxWindowID id, AudacityProject *project, AliasedFileArray &aliasedFiles, bool isSaving)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void PopulateList ()
 
void PopulateOrExchange (ShuttleGui &S)
 
void OnCancel (wxCommandEvent &evt)
 
void OnCopySelectedFiles (wxCommandEvent &evt)
 
void OnList (wxListEvent &evt)
 
void OnSize (wxSizeEvent &evt)
 
void OnNo (wxCommandEvent &evt)
 
void OnYes (wxCommandEvent &evt)
 
void OnRightClick (wxListEvent &evt)
 
void OnCopyToClipboard (wxCommandEvent &evt)
 
void SaveFutureActionChoice ()
 

Private Attributes

AudacityProjectmProject
 
AliasedFileArraymAliasedFiles
 
bool mIsSaving
 
bool mHasMissingFiles
 
bool mHasNonMissingFiles
 
wxStaticText * mMessageStaticText
 
wxListCtrl * mFileListCtrl
 
wxButton * mCopySelectedFilesButton
 
wxButton * mCopyAllFilesButton
 
wxChoice * mFutureActionChoice
 

Detailed Description

DependencyDialog shows dependencies of an AudacityProject on AliasedFile s.

Definition at line 242 of file Dependencies.cpp.

Constructor & Destructor Documentation

◆ DependencyDialog()

DependencyDialog::DependencyDialog ( wxWindow *  parent,
wxWindowID  id,
AudacityProject project,
AliasedFileArray aliasedFiles,
bool  isSaving 
)

Member Function Documentation

◆ OnCancel()

void DependencyDialog::OnCancel ( wxCommandEvent &  evt)
private

Definition at line 564 of file Dependencies.cpp.

565{
566 if (mIsSaving)
567 {
568 int ret = AudacityMessageBox(
569 XO(
570"If you proceed, your project will not be saved to disk. Is this what you want?"),
571 XO("Cancel Save"),
572 wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT, this);
573 if (ret != wxYES)
574 return;
575 }
576
577 EndModal(wxID_CANCEL);
578}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
XO("Cut/Copy/Paste")

References AudacityMessageBox(), mIsSaving, and XO().

Here is the call graph for this function:

◆ OnCopySelectedFiles()

void DependencyDialog::OnCopySelectedFiles ( wxCommandEvent &  evt)
private

Definition at line 507 of file Dependencies.cpp.

508{
509 AliasedFileArray aliasedFilesToDelete, remainingAliasedFiles;
510
511 long i = 0;
512 for( const auto &file : mAliasedFiles ) {
513 if (mFileListCtrl->GetItemState(i, wxLIST_STATE_SELECTED))
514 aliasedFilesToDelete.push_back( file );
515 else
516 remainingAliasedFiles.push_back( file );
517 ++i;
518 }
519
520 // provides STRONG-GUARANTEE
521 RemoveDependencies(mProject, aliasedFilesToDelete);
522
523 // COMMIT OPERATIONS needing NOFAIL-GUARANTEE:
524 mAliasedFiles.swap( remainingAliasedFiles );
525 PopulateList();
526
527 if (mAliasedFiles.empty() || !mHasNonMissingFiles)
528 {
530 EndModal(wxID_NO); // Don't need to remove dependencies
531 }
532}
static void RemoveDependencies(AudacityProject *project, AliasedFileArray &aliasedFiles)
std::list< AliasedFile > AliasedFileArray
Definition: Dependencies.h:52
wxListCtrl * mFileListCtrl
AudacityProject * mProject
AliasedFileArray & mAliasedFiles
void SaveFutureActionChoice()

References mAliasedFiles, mFileListCtrl, mHasNonMissingFiles, mProject, PopulateList(), RemoveDependencies(), and SaveFutureActionChoice().

Here is the call graph for this function:

◆ OnCopyToClipboard()

void DependencyDialog::OnCopyToClipboard ( wxCommandEvent &  evt)
private

Definition at line 542 of file Dependencies.cpp.

543{
544 TranslatableString Files;
545 for (const auto &aliasedFile : mAliasedFiles) {
546 const wxFileName & fileName = aliasedFile.mFileName;
547 wxLongLong byteCount = (aliasedFile.mByteCount * 124) / 100;
548 bool bOriginalExists = aliasedFile.mbOriginalExists;
549 // All fields quoted, as e.g. size may contain a comma in the number.
550 Files += XO( "\"%s\", \"%s\", \"%s\"\n").Format(
551 fileName.GetFullPath(),
552 Internat::FormatSize( byteCount),
553 bOriginalExists ? XO("OK") : XO("Missing") );
554 }
555
556 // copy data onto clipboard
557 if (wxTheClipboard->Open()) {
558 // Clipboard owns the data you give it
559 wxTheClipboard->SetData(safenew wxTextDataObject(Files.Translation()));
560 wxTheClipboard->Close();
561 }
562}
#define safenew
Definition: MemoryX.h:10
static TranslatableString FormatSize(wxLongLong size)
Convert a number to a string while formatting it in bytes, KB, MB, GB.
Definition: Internat.cpp:203
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const

References Internat::FormatSize(), mAliasedFiles, safenew, TranslatableString::Translation(), and XO().

Here is the call graph for this function:

◆ OnList()

void DependencyDialog::OnList ( wxListEvent &  evt)
private

Definition at line 465 of file Dependencies.cpp.

466{
468 return;
469
470 wxString itemStr = evt.GetText();
471 if (evt.GetData() == 0)
472 // This list item is one of mAliasedFiles for which
473 // the original is missing, i.e., moved or deleted.
474 // wxListCtrl does not provide for items that are not
475 // allowed to be selected, so always deselect these items.
476 mFileListCtrl->SetItemState(evt.GetIndex(), 0, wxLIST_STATE_SELECTED); // Deselect.
477
479 mFileListCtrl->GetSelectedItemCount() > 0);
480}
wxButton * mCopySelectedFilesButton

References mCopySelectedFilesButton, and mFileListCtrl.

◆ OnNo()

void DependencyDialog::OnNo ( wxCommandEvent &  evt)
private

Definition at line 495 of file Dependencies.cpp.

496{
498 EndModal(wxID_NO);
499}

References SaveFutureActionChoice().

Here is the call graph for this function:

◆ OnRightClick()

void DependencyDialog::OnRightClick ( wxListEvent &  evt)
private

Definition at line 534 of file Dependencies.cpp.

535{
536 static_cast<void>(event);
537 wxMenu menu;
538 menu.Append(CopyNamesToClipboardID, _("&Copy Names to Clipboard"));
539 PopupMenu(&menu);
540}
@ CopyNamesToClipboardID
#define _(s)
Definition: Internat.h:75

References _, and CopyNamesToClipboardID.

◆ OnSize()

void DependencyDialog::OnSize ( wxSizeEvent &  evt)
private

Definition at line 482 of file Dependencies.cpp.

483{
484 int fileListCtrlWidth, fileListCtrlHeight;
485 mFileListCtrl->GetSize(&fileListCtrlWidth, &fileListCtrlHeight);
486
487 // File path is column 0. File size is column 1.
488 // File size column is always 120 px wide.
489 // Also subtract 8 from file path column width for borders.
490 mFileListCtrl->SetColumnWidth(0, fileListCtrlWidth - 120 - 8);
491 mFileListCtrl->SetColumnWidth(1, 120);
493}
static void OnSize(wxSizeEvent &evt)
Definition: VSTEffect.cpp:2537

References mFileListCtrl, and OnSize().

Here is the call graph for this function:

◆ OnYes()

void DependencyDialog::OnYes ( wxCommandEvent &  evt)
private

Definition at line 501 of file Dependencies.cpp.

502{
504 EndModal(wxID_YES);
505}

References SaveFutureActionChoice().

Here is the call graph for this function:

◆ PopulateList()

void DependencyDialog::PopulateList ( )
private

Definition at line 424 of file Dependencies.cpp.

425{
426 mFileListCtrl->DeleteAllItems();
427
428 mHasMissingFiles = false;
429 mHasNonMissingFiles = false;
430 long i = 0;
431 for (const auto &aliasedFile : mAliasedFiles) {
432 const wxFileName &fileName = aliasedFile.mFileName;
433 wxLongLong byteCount = (aliasedFile.mByteCount * 124) / 100;
434 bool bOriginalExists = aliasedFile.mbOriginalExists;
435
436 if (bOriginalExists)
437 {
438 mFileListCtrl->InsertItem(i, fileName.GetFullPath());
439 mHasNonMissingFiles = true;
440 mFileListCtrl->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
441 }
442 else
443 {
444 mFileListCtrl->InsertItem(i,
445 wxString::Format( _("MISSING %s"), fileName.GetFullPath() ) );
446 mHasMissingFiles = true;
447 mFileListCtrl->SetItemState(i, 0, wxLIST_STATE_SELECTED); // Deselect.
448 mFileListCtrl->SetItemTextColour(i, *wxRED);
449 }
450 mFileListCtrl->SetItem(i, 1, Internat::FormatSize(byteCount).Translation());
451 mFileListCtrl->SetItemData(i, long(bOriginalExists));
452
453 ++i;
454 }
455
456 auto msg = kStdMsg();
459 mMessageStaticText->SetLabel(msg.Translation());
460
463}
static const TranslatableString kStdMsg()
static const TranslatableString kExtraMsgForMissingFiles()
wxButton * mCopyAllFilesButton
wxStaticText * mMessageStaticText

References _, Internat::FormatSize(), kExtraMsgForMissingFiles(), kStdMsg(), mAliasedFiles, mCopyAllFilesButton, mFileListCtrl, mHasMissingFiles, mHasNonMissingFiles, mMessageStaticText, and TranslatableString::Translation().

Referenced by OnCopySelectedFiles(), and PopulateOrExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PopulateOrExchange()

void DependencyDialog::PopulateOrExchange ( ShuttleGui S)
private

Definition at line 345 of file Dependencies.cpp.

346{
347 S.SetBorder(5);
348 S.StartVerticalLay();
349 {
350 mMessageStaticText = S.AddVariableText(kStdMsg(), false);
351
352 S.StartStatic(XO("Project Dependencies"),1);
353 {
354 mFileListCtrl = S.Id(FileListID).AddListControlReportMode({
355 { XO("Audio File"), wxLIST_FORMAT_LEFT, 220 },
356 { XO("Disk Space"), wxLIST_FORMAT_LEFT, 120 }
357 });
358 PopulateList();
359
362 .Focus()
363 .Disable(mFileListCtrl->GetSelectedItemCount() <= 0)
364 .AddButton(
365 XXO("Copy Selected Files"),
366 wxALIGN_LEFT, true);
367 }
368 S.EndStatic();
369
370 S.StartHorizontalLay(wxALIGN_CENTRE,0);
371 {
372 if (mIsSaving) {
373 S.Id(wxID_CANCEL).AddButton(XXO("Cancel Save"));
374 S.Id(wxID_NO).AddButton(XXO("Save Without Copying"));
375 }
376 else
377 S.Id(wxID_NO).AddButton(XXO("Do Not Copy"));
378
380 S.Id(wxID_YES)
381 // Enabling mCopyAllFilesButton is also done in PopulateList,
382 // but at its call above, mCopyAllFilesButton does not yet exist.
383 .Disable(mHasMissingFiles)
384 .AddButton(XXO("Copy All Files (Safer)"));
385
386 }
387 S.EndHorizontalLay();
388
389 if (mIsSaving)
390 {
391 S.StartHorizontalLay(wxALIGN_LEFT,0);
392 {
394 S.Id(FutureActionChoiceID).AddChoice(
395 XXO("Whenever a project depends on other files:"),
396 {
397 /*i18n-hint: One of the choices of what you want Audacity to do when
398 * Audacity finds a project depends on another file.*/
399 XO("Ask me") ,
400 /*i18n-hint: One of the choices of what you want Audacity to do when
401 * Audacity finds a project depends on another file.*/
402 XO("Always copy all files (safest)") ,
403 /*i18n-hint: One of the choices of what you want Audacity to do when
404 * Audacity finds a project depends on another file.*/
405 XO("Never copy any files") ,
406 },
407 0 // "Ask me"
408 );
409 }
410 S.EndHorizontalLay();
411 }
412 else
413 {
414 mFutureActionChoice = NULL;
415 }
416 }
417 S.EndVerticalLay();
418 Layout();
419 Fit();
420 SetMinSize(GetSize());
421 Center();
422}
@ CopySelectedFilesButtonID
@ FutureActionChoiceID
@ FileListID
XXO("&Cut/Copy/Paste Toolbar")
#define S(N)
Definition: ToChars.cpp:64
wxChoice * mFutureActionChoice

References CopySelectedFilesButtonID, FileListID, FutureActionChoiceID, kStdMsg(), mCopyAllFilesButton, mCopySelectedFilesButton, mFileListCtrl, mFutureActionChoice, mHasMissingFiles, mIsSaving, mMessageStaticText, PopulateList(), S, XO(), and XXO().

Here is the call graph for this function:

◆ SaveFutureActionChoice()

void DependencyDialog::SaveFutureActionChoice ( )
private

Definition at line 580 of file Dependencies.cpp.

581{
583 {
584 wxString savePref;
585 int sel = mFutureActionChoice->GetSelection();
586 switch (sel)
587 {
588 case 1: savePref = wxT("copy"); break;
589 case 2: savePref = wxT("never"); break;
590 default: savePref = wxT("ask");
591 }
593 gPrefs->Flush();
594 }
595}
wxT("CloseDown"))
ChoiceSetting FileFormatsSaveWithDependenciesSetting
FileConfig * gPrefs
Definition: Prefs.cpp:70
bool Write(const wxString &value)
Definition: Prefs.cpp:389
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143

References FileFormatsSaveWithDependenciesSetting, FileConfig::Flush(), gPrefs, mFutureActionChoice, ChoiceSetting::Write(), and wxT().

Referenced by OnCopySelectedFiles(), OnNo(), and OnYes().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mAliasedFiles

AliasedFileArray& DependencyDialog::mAliasedFiles
private

Definition at line 270 of file Dependencies.cpp.

Referenced by OnCopySelectedFiles(), OnCopyToClipboard(), and PopulateList().

◆ mCopyAllFilesButton

wxButton* DependencyDialog::mCopyAllFilesButton
private

Definition at line 278 of file Dependencies.cpp.

Referenced by PopulateList(), and PopulateOrExchange().

◆ mCopySelectedFilesButton

wxButton* DependencyDialog::mCopySelectedFilesButton
private

Definition at line 277 of file Dependencies.cpp.

Referenced by OnList(), and PopulateOrExchange().

◆ mFileListCtrl

wxListCtrl* DependencyDialog::mFileListCtrl
private

◆ mFutureActionChoice

wxChoice* DependencyDialog::mFutureActionChoice
private

Definition at line 279 of file Dependencies.cpp.

Referenced by PopulateOrExchange(), and SaveFutureActionChoice().

◆ mHasMissingFiles

bool DependencyDialog::mHasMissingFiles
private

Definition at line 272 of file Dependencies.cpp.

Referenced by PopulateList(), and PopulateOrExchange().

◆ mHasNonMissingFiles

bool DependencyDialog::mHasNonMissingFiles
private

Definition at line 273 of file Dependencies.cpp.

Referenced by OnCopySelectedFiles(), and PopulateList().

◆ mIsSaving

bool DependencyDialog::mIsSaving
private

Definition at line 271 of file Dependencies.cpp.

Referenced by OnCancel(), and PopulateOrExchange().

◆ mMessageStaticText

wxStaticText* DependencyDialog::mMessageStaticText
private

Definition at line 275 of file Dependencies.cpp.

Referenced by PopulateList(), and PopulateOrExchange().

◆ mProject

AudacityProject* DependencyDialog::mProject
private

Definition at line 269 of file Dependencies.cpp.

Referenced by OnCopySelectedFiles().


The documentation for this class was generated from the following file: