| 625 | } |
| 626 | |
| 627 | void 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 | |
| 669 | void LabelDialog::OnExport(wxCommandEvent & WXUNUSED(event)) |
| 670 | { |
nothing calls this directly
no test coverage detected