| 513 | } |
| 514 | |
| 515 | void ExtImportPrefs::OnRuleTableEdit (wxGridEvent& event) |
| 516 | { |
| 517 | int row = event.GetRow(); |
| 518 | int col = event.GetCol(); |
| 519 | auto &items = Importer::Get().GetImportItems(); |
| 520 | ExtImportItem *item = items[row].get(); |
| 521 | RuleTable->SaveEditControlValue(); |
| 522 | |
| 523 | wxString val = RuleTable->GetCellValue (row, col); |
| 524 | int fixSpaces = wxNO; |
| 525 | bool askedAboutSpaces = false; |
| 526 | wxArrayString vals; |
| 527 | wxString delims(wxT(":")); |
| 528 | Importer::Get().StringToList (val, delims, vals); |
| 529 | switch (col) |
| 530 | { |
| 531 | case 0: |
| 532 | item->extensions.clear(); |
| 533 | break; |
| 534 | case 1: |
| 535 | item->mime_types.clear(); |
| 536 | break; |
| 537 | } |
| 538 | |
| 539 | for (size_t i = 0; i < vals.size(); i++) |
| 540 | { |
| 541 | |
| 542 | wxString trimmed = vals[i]; |
| 543 | trimmed.Trim().Trim(false); |
| 544 | if (trimmed != vals[i]) |
| 545 | { |
| 546 | if (!askedAboutSpaces) |
| 547 | { |
| 548 | fixSpaces = AudacityMessageBox( |
| 549 | XO( |
| 550 | "There are space characters (spaces, newlines, tabs or linefeeds) in one of \ |
| 551 | the items. They are likely to break the pattern matching. Unless you know \ |
| 552 | what you are doing, it is recommended to trim spaces. Do you want \ |
| 553 | Audacity to trim spaces for you?"), |
| 554 | XO("Spaces detected"), |
| 555 | wxYES_NO); |
| 556 | askedAboutSpaces = true; |
| 557 | } |
| 558 | if (fixSpaces != wxYES) |
| 559 | { |
| 560 | trimmed = vals[i]; |
| 561 | } |
| 562 | else |
| 563 | { |
| 564 | vals[i] = trimmed; |
| 565 | } |
| 566 | } |
| 567 | switch (col) |
| 568 | { |
| 569 | case 0: |
| 570 | item->extensions.push_back(trimmed); |
| 571 | break; |
| 572 | case 1: |
nothing calls this directly
no test coverage detected