Audacity  3.0.3
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 244 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 566 of file Dependencies.cpp.

567 {
568  if (mIsSaving)
569  {
570  int ret = AudacityMessageBox(
571  XO(
572 "If you proceed, your project will not be saved to disk. Is this what you want?"),
573  XO("Cancel Save"),
574  wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT, this);
575  if (ret != wxYES)
576  return;
577  }
578 
579  EndModal(wxID_CANCEL);
580 }

References AudacityMessageBox(), mIsSaving, and XO.

Here is the call graph for this function:

◆ OnCopySelectedFiles()

void DependencyDialog::OnCopySelectedFiles ( wxCommandEvent &  evt)
private

Definition at line 509 of file Dependencies.cpp.

510 {
511  AliasedFileArray aliasedFilesToDelete, remainingAliasedFiles;
512 
513  long i = 0;
514  for( const auto &file : mAliasedFiles ) {
515  if (mFileListCtrl->GetItemState(i, wxLIST_STATE_SELECTED))
516  aliasedFilesToDelete.push_back( file );
517  else
518  remainingAliasedFiles.push_back( file );
519  ++i;
520  }
521 
522  // provides STRONG-GUARANTEE
523  RemoveDependencies(mProject, aliasedFilesToDelete);
524 
525  // COMMIT OPERATIONS needing NOFAIL-GUARANTEE:
526  mAliasedFiles.swap( remainingAliasedFiles );
527  PopulateList();
528 
529  if (mAliasedFiles.empty() || !mHasNonMissingFiles)
530  {
532  EndModal(wxID_NO); // Don't need to remove dependencies
533  }
534 }

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 544 of file Dependencies.cpp.

545 {
546  TranslatableString Files;
547  for (const auto &aliasedFile : mAliasedFiles) {
548  const wxFileName & fileName = aliasedFile.mFileName;
549  wxLongLong byteCount = (aliasedFile.mByteCount * 124) / 100;
550  bool bOriginalExists = aliasedFile.mbOriginalExists;
551  // All fields quoted, as e.g. size may contain a comma in the number.
552  Files += XO( "\"%s\", \"%s\", \"%s\"\n").Format(
553  fileName.GetFullPath(),
554  Internat::FormatSize( byteCount),
555  bOriginalExists ? XO("OK") : XO("Missing") );
556  }
557 
558  // copy data onto clipboard
559  if (wxTheClipboard->Open()) {
560  // Clipboard owns the data you give it
561  wxTheClipboard->SetData(safenew wxTextDataObject(Files.Translation()));
562  wxTheClipboard->Close();
563  }
564 }

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 467 of file Dependencies.cpp.

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

References mCopySelectedFilesButton, and mFileListCtrl.

◆ OnNo()

void DependencyDialog::OnNo ( wxCommandEvent &  evt)
private

Definition at line 497 of file Dependencies.cpp.

498 {
500  EndModal(wxID_NO);
501 }

References SaveFutureActionChoice().

Here is the call graph for this function:

◆ OnRightClick()

void DependencyDialog::OnRightClick ( wxListEvent &  evt)
private

Definition at line 536 of file Dependencies.cpp.

537 {
538  static_cast<void>(event);
539  wxMenu menu;
540  menu.Append(CopyNamesToClipboardID, _("&Copy Names to Clipboard"));
541  PopupMenu(&menu);
542 }

References _, and CopyNamesToClipboardID.

◆ OnSize()

void DependencyDialog::OnSize ( wxSizeEvent &  evt)
private

Definition at line 484 of file Dependencies.cpp.

485 {
486  int fileListCtrlWidth, fileListCtrlHeight;
487  mFileListCtrl->GetSize(&fileListCtrlWidth, &fileListCtrlHeight);
488 
489  // File path is column 0. File size is column 1.
490  // File size column is always 120 px wide.
491  // Also subtract 8 from file path column width for borders.
492  mFileListCtrl->SetColumnWidth(0, fileListCtrlWidth - 120 - 8);
493  mFileListCtrl->SetColumnWidth(1, 120);
495 }

References mFileListCtrl, and OnSize().

Here is the call graph for this function:

◆ OnYes()

void DependencyDialog::OnYes ( wxCommandEvent &  evt)
private

Definition at line 503 of file Dependencies.cpp.

504 {
506  EndModal(wxID_YES);
507 }

References SaveFutureActionChoice().

Here is the call graph for this function:

◆ PopulateList()

void DependencyDialog::PopulateList ( )
private

Definition at line 426 of file Dependencies.cpp.

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

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 347 of file Dependencies.cpp.

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

References ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddChoice(), ShuttleGuiBase::AddListControlReportMode(), ShuttleGuiBase::AddVariableText(), CopySelectedFilesButtonID, ShuttleGui::Disable(), ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::EndVerticalLay(), FileListID, ShuttleGui::Focus(), FutureActionChoiceID, ShuttleGui::Id(), kStdMsg(), mCopyAllFilesButton, mCopySelectedFilesButton, mFileListCtrl, mFutureActionChoice, mHasMissingFiles, mIsSaving, mMessageStaticText, PopulateList(), ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::StartVerticalLay(), XO, and XXO.

Here is the call graph for this function:

◆ SaveFutureActionChoice()

void DependencyDialog::SaveFutureActionChoice ( )
private

Definition at line 582 of file Dependencies.cpp.

583 {
585  {
586  wxString savePref;
587  int sel = mFutureActionChoice->GetSelection();
588  switch (sel)
589  {
590  case 1: savePref = wxT("copy"); break;
591  case 2: savePref = wxT("never"); break;
592  default: savePref = wxT("ask");
593  }
595  gPrefs->Flush();
596  }
597 }

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

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 272 of file Dependencies.cpp.

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

◆ mCopyAllFilesButton

wxButton* DependencyDialog::mCopyAllFilesButton
private

Definition at line 280 of file Dependencies.cpp.

Referenced by PopulateList(), and PopulateOrExchange().

◆ mCopySelectedFilesButton

wxButton* DependencyDialog::mCopySelectedFilesButton
private

Definition at line 279 of file Dependencies.cpp.

Referenced by OnList(), and PopulateOrExchange().

◆ mFileListCtrl

wxListCtrl* DependencyDialog::mFileListCtrl
private

◆ mFutureActionChoice

wxChoice* DependencyDialog::mFutureActionChoice
private

Definition at line 281 of file Dependencies.cpp.

Referenced by PopulateOrExchange(), and SaveFutureActionChoice().

◆ mHasMissingFiles

bool DependencyDialog::mHasMissingFiles
private

Definition at line 274 of file Dependencies.cpp.

Referenced by PopulateList(), and PopulateOrExchange().

◆ mHasNonMissingFiles

bool DependencyDialog::mHasNonMissingFiles
private

Definition at line 275 of file Dependencies.cpp.

Referenced by OnCopySelectedFiles(), and PopulateList().

◆ mIsSaving

bool DependencyDialog::mIsSaving
private

Definition at line 273 of file Dependencies.cpp.

Referenced by OnCancel(), and PopulateOrExchange().

◆ mMessageStaticText

wxStaticText* DependencyDialog::mMessageStaticText
private

Definition at line 277 of file Dependencies.cpp.

Referenced by PopulateList(), and PopulateOrExchange().

◆ mProject

AudacityProject* DependencyDialog::mProject
private

Definition at line 271 of file Dependencies.cpp.

Referenced by OnCopySelectedFiles().


The documentation for this class was generated from the following file:
DependencyDialog::mMessageStaticText
wxStaticText * mMessageStaticText
Definition: Dependencies.cpp:277
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
DependencyDialog::SaveFutureActionChoice
void SaveFutureActionChoice()
Definition: Dependencies.cpp:582
ShuttleGuiBase::AddChoice
wxChoice * AddChoice(const TranslatableString &Prompt, const TranslatableStrings &choices, int Selected=-1)
Definition: ShuttleGui.cpp:398
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1184
ShuttleGui::Focus
ShuttleGui & Focus(bool focused=true)
Definition: ShuttleGui.h:644
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
DependencyDialog::mFutureActionChoice
wxChoice * mFutureActionChoice
Definition: Dependencies.cpp:281
ChoiceSetting::Write
bool Write(const wxString &value)
Definition: Prefs.cpp:318
DependencyDialog::mHasNonMissingFiles
bool mHasNonMissingFiles
Definition: Dependencies.cpp:275
XO
#define XO(s)
Definition: Internat.h:31
FileListID
@ FileListID
Definition: Dependencies.cpp:288
DependencyDialog::mIsSaving
bool mIsSaving
Definition: Dependencies.cpp:273
kStdMsg
static const TranslatableString kStdMsg()
Definition: Dependencies.cpp:333
OnSize
static void OnSize(wxSizeEvent &evt)
Definition: VSTEffect.cpp:2784
DependencyDialog::mCopySelectedFilesButton
wxButton * mCopySelectedFilesButton
Definition: Dependencies.cpp:279
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2274
FutureActionChoiceID
@ FutureActionChoiceID
Definition: Dependencies.cpp:291
DependencyDialog::mCopyAllFilesButton
wxButton * mCopyAllFilesButton
Definition: Dependencies.cpp:280
XXO
#define XXO(s)
Definition: Internat.h:44
DependencyDialog::PopulateList
void PopulateList()
Definition: Dependencies.cpp:426
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1177
CopyNamesToClipboardID
@ CopyNamesToClipboardID
Definition: Dependencies.cpp:290
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1167
ShuttleGui::Disable
ShuttleGui & Disable(bool disabled=true)
Definition: ShuttleGui.h:650
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1203
Internat::FormatSize
static TranslatableString FormatSize(wxLongLong size)
Convert a number to a string while formatting it in bytes, KB, MB, GB.
Definition: Internat.cpp:204
DependencyDialog::mFileListCtrl
wxListCtrl * mFileListCtrl
Definition: Dependencies.cpp:278
AliasedFileArray
std::list< AliasedFile > AliasedFileArray
Definition: Dependencies.h:52
PopupMenu
Definition: PopupMenuTable.h:108
ShuttleGuiBase::AddButton
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:360
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
kExtraMsgForMissingFiles
static const TranslatableString kExtraMsgForMissingFiles()
Definition: Dependencies.cpp:340
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
FileFormatsSaveWithDependenciesSetting
ChoiceSetting FileFormatsSaveWithDependenciesSetting
Definition: FileFormats.cpp:368
DependencyDialog::mAliasedFiles
AliasedFileArray & mAliasedFiles
Definition: Dependencies.cpp:272
_
#define _(s)
Definition: Internat.h:75
ShuttleGuiBase::AddListControlReportMode
wxListCtrl * AddListControlReportMode(std::initializer_list< const ListControlColumn > columns={}, long listControlStyles=0)
Definition: ShuttleGui.cpp:802
RemoveDependencies
static void RemoveDependencies(AudacityProject *project, AliasedFileArray &aliasedFiles)
Definition: Dependencies.cpp:164
CopySelectedFilesButtonID
@ CopySelectedFilesButtonID
Definition: Dependencies.cpp:289
TranslatableString::Translation
wxString Translation() const
Definition: TranslatableString.h:79
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:489
ShuttleGuiBase::AddVariableText
wxStaticText * AddVariableText(const TranslatableString &Str, bool bCenter=false, int PositionFlags=0, int wrapWidth=0)
Definition: ShuttleGui.cpp:463
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
safenew
#define safenew
Definition: MemoryX.h:10
DependencyDialog::mHasMissingFiles
bool mHasMissingFiles
Definition: Dependencies.cpp:274
DependencyDialog::mProject
AudacityProject * mProject
Definition: Dependencies.cpp:271