MCPcopy Create free account
hub / github.com/audacity/audacity / OnImport

Method OnImport

src/LabelDialog.cpp:627–667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

625}
626
627void LabelDialog::OnImport(wxCommandEvent & WXUNUSED(event))
628{
629 // Ask user for a filename
630 wxString fileName =
631 SelectFile(FileNames::Operation::Open,
632 XO("Select a text file containing labels"),
633 wxEmptyString, // Path
634 wxT(""), // Name
635 wxT(""), // Extension
636 { LabelTrack::AllSupportedFiles, FileNames::TextFiles, LabelTrack::SubripFiles, FileNames::AllFiles },
637 wxRESIZE_BORDER, // Flags
638 this); // Parent
639
640 // They gave us one...
641 if (!fileName.empty()) {
642 LabelFormat format = LabelTrack::FormatForFileName(fileName);
643
644 wxTextFile f;
645
646 // Get at the data
647 f.Open(fileName);
648 if (!f.IsOpened()) {
649 AudacityMessageBox(
650 XO("Could not open file: %s").Format( fileName ) );
651 }
652 else {
653 // Create a temporary label track and load the labels
654 // into it
655 auto lt = std::make_shared<LabelTrack>();
656 lt->Import(f, format);
657
658 // Add the labels to our collection
659 AddLabels(lt.get());
660
661 // Done with the temporary track
662 }
663
664 // Repopulate the grid
665 TransferDataToWindow();
666 }
667}
668
669void LabelDialog::OnExport(wxCommandEvent & WXUNUSED(event))
670{

Callers

nothing calls this directly

Calls 7

SelectFileFunction · 0.85
AudacityMessageBoxFunction · 0.85
IsOpenedMethod · 0.80
emptyMethod · 0.45
OpenMethod · 0.45
ImportMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected