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

Method OnRuleTableEdit

src/prefs/ExtImportPrefs.cpp:515–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513}
514
515void 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 \
551the items. They are likely to break the pattern matching. Unless you know \
552what you are doing, it is recommended to trim spaces. Do you want \
553Audacity 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:

Callers

nothing calls this directly

Calls 9

GetFunction · 0.85
AudacityMessageBoxFunction · 0.85
StringToListMethod · 0.80
getMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45
TrimMethod · 0.45
push_backMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected