Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ExtImportPrefs Class Referencefinal

A PrefsPanel used to select extended import filter options. More...

#include <ExtImportPrefs.h>

Inheritance diagram for ExtImportPrefs:
[legend]
Collaboration diagram for ExtImportPrefs:
[legend]

Public Member Functions

 ExtImportPrefs (wxWindow *parent, wxWindowID winid)
 
 ~ExtImportPrefs ()
 
ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const override
 
bool Commit () override
 
ManualPageID HelpPageName () override
 If not empty string, the Help button is added below the panel. More...
 
void PopulateOrExchange (ShuttleGui &S) override
 
void OnShow (wxShowEvent &event)
 
void OnPluginKeyDown (wxListEvent &event)
 
void OnPluginBeginDrag (wxListEvent &event)
 
void OnRuleTableKeyDown (wxKeyEvent &event)
 
void OnRuleTableSelect (wxGridEvent &event)
 
void OnRuleTableEdit (wxGridEvent &event)
 
void OnRuleTableSelectRange (wxGridRangeSelectEvent &event)
 
void OnRuleTableCellClick (wxGridEvent &event)
 
void OnAddRule (wxCommandEvent &event)
 
void OnDelRule (wxCommandEvent &event)
 
void OnRuleMoveUp (wxCommandEvent &event)
 
void OnRuleMoveDown (wxCommandEvent &event)
 
void OnFilterMoveUp (wxCommandEvent &event)
 
void OnFilterMoveDown (wxCommandEvent &event)
 
void OnNavKey (wxNavigationKeyEvent &event)
 
void SwapRows (int row1, int row2)
 
void SwapPluginRows (int row1, int row2)
 
GridGetRuleTable ()
 
wxListCtrl * GetPluginList ()
 
wxWindow * GetDragFocus ()
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const TranslatableString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual bool Commit ()=0
 
virtual PluginPath GetPath () const override
 
virtual VendorSymbol GetVendor () const override
 
virtual wxString GetVersion () const override
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual ManualPageID HelpPageName ()
 If not empty string, the Help button is added below the panel. More...
 
virtual void Cancel ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void FakeOnPluginKeyDown (int keycode)
 
void DoOnRuleTableKeyDown (int keycode)
 
bool DoOnPluginKeyDown (int code)
 
void DoOnRuleTableSelect (int toprow)
 
void AddItemToTable (int index, const ExtImportItem *item)
 
void Populate ()
 Creates the dialog and its contents. More...
 

Private Attributes

GridRuleTable
 
wxListCtrl * PluginList
 
wxButton * AddRule
 
wxButton * DelRule
 
wxButton * MoveRuleUp
 
wxButton * MoveRuleDown
 
wxButton * MoveFilterUp
 
wxButton * MoveFilterDown
 
wxTextDataObject * dragtext1 {}
 
wxTextDataObject * dragtext2 {}
 
bool mCreateTable
 
wxWindow * mDragFocus
 
bool mFakeKeyEvent
 
bool mStopRecursiveSelection
 
int last_selected
 

Additional Inherited Members

- Public Types inherited from PrefsPanel
using Factories = std::vector< PrefsPanel::PrefsNode >
 
using Factory = std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) >
 
- Static Public Member Functions inherited from PrefsPanel
static FactoriesDefaultFactories ()
 

Detailed Description

A PrefsPanel used to select extended import filter options.

Definition at line 49 of file ExtImportPrefs.h.

Constructor & Destructor Documentation

◆ ExtImportPrefs()

ExtImportPrefs::ExtImportPrefs ( wxWindow *  parent,
wxWindowID  winid 
)

Definition at line 60 of file ExtImportPrefs.cpp.

63: PrefsPanel(parent, winid, XO("Extended Import")), RuleTable(NULL),
64 PluginList(NULL), mCreateTable (false), mDragFocus (NULL),
66{
67 Populate();
68
69 // See bug #2315 for discussion
70 // This should be reviewed and (possibly) removed after wx3.1.3.
71 Bind(wxEVT_SHOW, &ExtImportPrefs::OnShow, this);
72}
XO("Cut/Copy/Paste")
void Populate()
Creates the dialog and its contents.
void OnShow(wxShowEvent &event)
bool mStopRecursiveSelection
wxListCtrl * PluginList
wxWindow * mDragFocus
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:94

References OnShow().

Here is the call graph for this function:

◆ ~ExtImportPrefs()

ExtImportPrefs::~ExtImportPrefs ( )

Definition at line 73 of file ExtImportPrefs.cpp.

74{
75}

Member Function Documentation

◆ AddItemToTable()

void ExtImportPrefs::AddItemToTable ( int  index,
const ExtImportItem item 
)
private

Definition at line 592 of file ExtImportPrefs.cpp.

593{
594 wxString extensions, mime_types;
595 if (item->extensions.size() > 0)
596 {
597 extensions.Append (item->extensions[0]);
598 for (unsigned int i = 1; i < item->extensions.size(); i++)
599 {
600 extensions.Append (wxT(":"));
601 extensions.Append (item->extensions[i]);
602 }
603 }
604 if (item->mime_types.size() > 0)
605 {
606 mime_types.Append (item->mime_types[0]);
607 for (unsigned int i = 1; i < item->mime_types.size(); i++)
608 {
609 mime_types.Append (wxT(":"));
610 mime_types.Append (item->mime_types[i]);
611 }
612 }
613
614 RuleTable->InsertRows (index, 1);
615 RuleTable->SetCellValue (index, 0, extensions);
616#if EXTIMPORT_MIME_SUPPORT
617 RuleTable->SetCellValue (index, 1, mime_types);
618#endif
619 RuleTable->AutoSizeColumns ();
620}
wxT("CloseDown"))
wxArrayString extensions
Definition: Import.h:75
wxArrayString mime_types
Definition: Import.h:81

References ExtImportItem::extensions, ExtImportItem::mime_types, RuleTable, and wxT().

Referenced by OnAddRule(), and PopulateOrExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Commit()

bool ExtImportPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 214 of file ExtImportPrefs.cpp.

215{
218
220
221 return true;
222}
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
#define S(N)
Definition: ToChars.cpp:64
void PopulateOrExchange(ShuttleGui &S) override
static Importer & Get()
Definition: Import.cpp:102
void WriteImportItems()
Definition: Import.cpp:409
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640

References eIsSavingToPrefs, Importer::Get(), PopulateOrExchange(), S, and Importer::WriteImportItems().

Here is the call graph for this function:

◆ DoOnPluginKeyDown()

bool ExtImportPrefs::DoOnPluginKeyDown ( int  code)
private

Definition at line 299 of file ExtImportPrefs.cpp.

300{
301 if (code != WXK_UP && code != WXK_DOWN)
302 return false;
303
304 long itemIndex = -1;
305 long itemIndex2 = -1;
306 itemIndex = PluginList->GetNextItem(itemIndex,
307 wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
308 if (itemIndex == -1)
309 return false;
310
311 if (last_selected == -1)
312 return false;
313
314 auto &items = Importer::Get().GetImportItems();
315 ExtImportItem *item = items[last_selected].get();
316
317 if (code == WXK_UP && itemIndex == 0)
318 return false;
319 else if (code == WXK_DOWN && itemIndex == PluginList->GetItemCount() - 1)
320 return false;
321
322 if (code == WXK_UP)
323 {
324 itemIndex2 = itemIndex - 1;
325 }
326 else if (code == WXK_DOWN)
327 {
328 itemIndex2 = itemIndex + 1;
329 }
330 SwapPluginRows (itemIndex, itemIndex2);
331 if (mFakeKeyEvent)
332 {
333 PluginList->SetItemState (itemIndex, 0, wxLIST_STATE_SELECTED);
334 PluginList->SetItemState (itemIndex2, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
335 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
336 }
337 int fcount = item->filter_objects.size();
338 if (item->divider >= fcount)
339 {
340 item->divider = -1;
341 }
342 if (item->divider < -1)
343 item->divider = item->filter_objects.size() - 1;
344
345 return true;
346}
int divider
Definition: Import.h:64
std::vector< ImportPlugin * > filter_objects
Definition: Import.h:69
void SwapPluginRows(int row1, int row2)
ExtImportItems & GetImportItems()
Definition: Import.h:169

References ExtImportItem::divider, ExtImportItem::filter_objects, Importer::Get(), Importer::GetImportItems(), last_selected, mFakeKeyEvent, PluginList, and SwapPluginRows().

Referenced by OnPluginKeyDown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoOnRuleTableKeyDown()

void ExtImportPrefs::DoOnRuleTableKeyDown ( int  keycode)
private

Definition at line 411 of file ExtImportPrefs.cpp.

412{
413 int selrow = RuleTable->GetGridCursorRow ();
414 wxString ts;
415 if (keycode == WXK_UP)
416 {
417 if (selrow <= 0)
418 return;
419 SwapRows (selrow - 1, selrow);
420 RuleTable->MoveCursorUp (false);
421 RuleTable->SelectRow (selrow - 1);
422 }
423 else if (keycode == WXK_DOWN)
424 {
425 if (selrow == RuleTable->GetNumberRows() - 1)
426 return;
427 SwapRows (selrow, selrow + 1);
428 RuleTable->MoveCursorDown (false);
429 RuleTable->SelectRow (selrow + 1);
430 }
431}
void SwapRows(int row1, int row2)

References RuleTable, and SwapRows().

Referenced by OnRuleMoveDown(), OnRuleMoveUp(), and OnRuleTableKeyDown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoOnRuleTableSelect()

void ExtImportPrefs::DoOnRuleTableSelect ( int  toprow)
private

Definition at line 465 of file ExtImportPrefs.cpp.

466{
467 auto &items = Importer::Get().GetImportItems();
468
469 if (toprow < 0 || toprow >= (int)items.size())
470 {
471 return;
472 }
473
474 ExtImportItem *item = items[toprow].get();
475 PluginList->DeleteAllItems();
476
477 int fcount;
478 fcount = item->filters.size();
479 int shift = 0;
480 for (int i = 0; i < fcount; i++)
481 {
482 if (item->divider == i)
483 {
484 PluginList->InsertItem (i, _("Unused filters:"));
485 PluginList->SetItemData (i, -1);
486 shift = 1;
487 }
488 if (item->filter_objects[i] != NULL)
489 {
490 PluginList->InsertItem (i + shift,
491 item->filter_objects[i]->GetPluginFormatDescription().Translation());
492 }
493 else
494 {
495 PluginList->InsertItem (i + shift, item->filters[i]);
496 }
497 PluginList->SetItemData (i + shift, i);
498 }
499 if (item->divider == -1)
500 {
501 PluginList->InsertItem (fcount, _("Unused filters:"));
502 PluginList->SetItemData (fcount, -1);
503 }
504 wxListItem info;
505 info.SetId (0);
506 info.SetColumn (0);
507 info.SetStateMask (wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
508 info.SetState (wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
509 info.SetMask (wxLIST_MASK_STATE);
510 PluginList->SetItem (info);
511 PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE);
512 last_selected = toprow;
513}
#define _(s)
Definition: Internat.h:73
wxArrayString filters
Definition: Import.h:55

References _, ExtImportItem::divider, ExtImportItem::filter_objects, ExtImportItem::filters, Importer::Get(), Importer::GetImportItems(), last_selected, and PluginList.

Referenced by OnDelRule(), OnRuleTableSelect(), and OnRuleTableSelectRange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FakeOnPluginKeyDown()

void ExtImportPrefs::FakeOnPluginKeyDown ( int  keycode)
private

Definition at line 675 of file ExtImportPrefs.cpp.

676{
677 wxListEvent fakeevent(wxEVT_COMMAND_LIST_KEY_DOWN, EIPPluginList);
678 fakeevent.SetEventObject(this);
679 fakeevent.m_code = keycode;
680 mFakeKeyEvent = true;
681 GetEventHandler()->ProcessEvent (fakeevent);
682 mFakeKeyEvent = false;
683}
@ EIPPluginList

References EIPPluginList, and mFakeKeyEvent.

Referenced by OnFilterMoveDown(), and OnFilterMoveUp().

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString ExtImportPrefs::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 82 of file ExtImportPrefs.cpp.

83{
84 return XO("Preferences for ExtImport");
85}

References XO().

Here is the call graph for this function:

◆ GetDragFocus()

wxWindow * ExtImportPrefs::GetDragFocus ( )
inline

Definition at line 87 of file ExtImportPrefs.h.

87{ return mDragFocus; }

References mDragFocus.

Referenced by ExtImportPrefsDropTarget::OnDragOver(), and ExtImportPrefsDropTarget::OnDrop().

Here is the caller graph for this function:

◆ GetPluginList()

wxListCtrl * ExtImportPrefs::GetPluginList ( )
inline

Definition at line 85 of file ExtImportPrefs.h.

85{ return PluginList; }

References PluginList.

Referenced by ExtImportPrefsDropTarget::OnDragOver(), and ExtImportPrefsDropTarget::OnDrop().

Here is the caller graph for this function:

◆ GetRuleTable()

Grid * ExtImportPrefs::GetRuleTable ( )
inline

Definition at line 84 of file ExtImportPrefs.h.

84{ return RuleTable; }

References RuleTable.

Referenced by ExtImportPrefsDropTarget::OnDragOver(), and ExtImportPrefsDropTarget::OnDrop().

Here is the caller graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol ExtImportPrefs::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 77 of file ExtImportPrefs.cpp.

78{
80}
#define EXT_IMPORT_PREFS_PLUGIN_SYMBOL

References EXT_IMPORT_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

ManualPageID ExtImportPrefs::HelpPageName ( )
overridevirtual

If not empty string, the Help button is added below the panel.

Default returns empty string.

Reimplemented from PrefsPanel.

Definition at line 87 of file ExtImportPrefs.cpp.

88{
89 return "Extended_Import_Preferences";
90}

◆ OnAddRule()

void ExtImportPrefs::OnAddRule ( wxCommandEvent &  event)

Definition at line 622 of file ExtImportPrefs.cpp.

623{
624 auto &items = Importer::Get().GetImportItems();
625 auto uitem = Importer::Get().CreateDefaultImportItem();
626 auto item = uitem.get();
627 items.push_back(std::move(uitem));
628 AddItemToTable (RuleTable->GetNumberRows (), item);
629
630 RuleTable->SelectRow(RuleTable->GetNumberRows () - 1);
631 RuleTable->SetGridCursor (RuleTable->GetNumberRows () - 1, 0);
632 RuleTable->SetFocus();
633}
void AddItemToTable(int index, const ExtImportItem *item)
std::unique_ptr< ExtImportItem > CreateDefaultImportItem()
Definition: Import.cpp:470

References AddItemToTable(), Importer::CreateDefaultImportItem(), Importer::Get(), Importer::GetImportItems(), and RuleTable.

Here is the call graph for this function:

◆ OnDelRule()

void ExtImportPrefs::OnDelRule ( wxCommandEvent &  event)

Definition at line 635 of file ExtImportPrefs.cpp.

636{
637 if (last_selected < 0)
638 return;
639 auto &items = Importer::Get().GetImportItems();
640
641 int msgres = AudacityMessageBox (
642 XO("Do you really want to delete selected rule?"),
643 XO("Rule deletion confirmation"),
644 wxYES_NO,
645 RuleTable);
646 // Yes or no, there is no third!
647 if (msgres != wxYES)
648 return;
649
650 PluginList->DeleteAllItems();
651 items.erase (items.begin() + last_selected);
653 // This will change last_selected
654 RuleTable->DeleteRows (last_selected);
655 RuleTable->AutoSizeColumns ();
656 if (last_selected >= RuleTable->GetNumberRows ())
657 last_selected = RuleTable->GetNumberRows () - 1;
658 if (last_selected >= 0)
659 {
660 RuleTable->SelectRow(last_selected);
661 RuleTable->SetGridCursor (last_selected, 0);
662 }
663}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
void DoOnRuleTableSelect(int toprow)

References AudacityMessageBox(), DoOnRuleTableSelect(), Importer::Get(), Importer::GetImportItems(), last_selected, PluginList, RuleTable, and XO().

Here is the call graph for this function:

◆ OnFilterMoveDown()

void ExtImportPrefs::OnFilterMoveDown ( wxCommandEvent &  event)

Definition at line 690 of file ExtImportPrefs.cpp.

691{
692 FakeOnPluginKeyDown (WXK_DOWN);
693}
void FakeOnPluginKeyDown(int keycode)

References FakeOnPluginKeyDown().

Here is the call graph for this function:

◆ OnFilterMoveUp()

void ExtImportPrefs::OnFilterMoveUp ( wxCommandEvent &  event)

Definition at line 685 of file ExtImportPrefs.cpp.

686{
687 FakeOnPluginKeyDown (WXK_UP);
688}

References FakeOnPluginKeyDown().

Here is the call graph for this function:

◆ OnNavKey()

void ExtImportPrefs::OnNavKey ( wxNavigationKeyEvent &  event)

◆ OnPluginBeginDrag()

void ExtImportPrefs::OnPluginBeginDrag ( wxListEvent &  event)

Definition at line 375 of file ExtImportPrefs.cpp.

376{
377 wxDropSource dragSource(this);
378 dragtext2->SetText(wxT(""));
379 dragSource.SetData(*dragtext2);
381 if( mDragFocus == NULL )
382 return;
383 wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove);
384 mDragFocus = NULL;
385 switch (result)
386 {
387 case wxDragCopy:
388 case wxDragMove:
389 case wxDragNone:
390 return;
391 break;
392 default:
393 break;
394 }
395}
wxTextDataObject * dragtext2

References dragtext2, mDragFocus, PluginList, and wxT().

Here is the call graph for this function:

◆ OnPluginKeyDown()

void ExtImportPrefs::OnPluginKeyDown ( wxListEvent &  event)

Definition at line 236 of file ExtImportPrefs.cpp.

237{
238 for (int i = 0; i < 1; i++)
239 {
240#ifdef __WXMAC__
241 if (!mFakeKeyEvent && !wxGetKeyState(WXK_COMMAND))
242 break;
243#else
244 if (!mFakeKeyEvent && !wxGetKeyState(WXK_CONTROL))
245 break;
246#endif
247
248 if (DoOnPluginKeyDown (event.GetKeyCode()))
249 event.Skip();
250 }
251}
bool DoOnPluginKeyDown(int code)

References DoOnPluginKeyDown(), and mFakeKeyEvent.

Here is the call graph for this function:

◆ OnRuleMoveDown()

void ExtImportPrefs::OnRuleMoveDown ( wxCommandEvent &  event)

Definition at line 670 of file ExtImportPrefs.cpp.

671{
672 DoOnRuleTableKeyDown (WXK_DOWN);
673}
void DoOnRuleTableKeyDown(int keycode)

References DoOnRuleTableKeyDown().

Here is the call graph for this function:

◆ OnRuleMoveUp()

void ExtImportPrefs::OnRuleMoveUp ( wxCommandEvent &  event)

Definition at line 665 of file ExtImportPrefs.cpp.

666{
667 DoOnRuleTableKeyDown (WXK_UP);
668}

References DoOnRuleTableKeyDown().

Here is the call graph for this function:

◆ OnRuleTableCellClick()

void ExtImportPrefs::OnRuleTableCellClick ( wxGridEvent &  event)

Definition at line 696 of file ExtImportPrefs.cpp.

697{
698 int row = event.GetRow();
699 RuleTable->SelectRow (row, false);
700 RuleTable->SetGridCursor (row, 0);
701
702 wxDropSource dragSource(this);
703 dragtext1->SetText(wxT(""));
704 dragSource.SetData(*dragtext1);
706 wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove);
707 mDragFocus = NULL;
708 switch (result)
709 {
710 case wxDragCopy: /* copy the data */
711 case wxDragMove:
712 case wxDragNone:
713 return;
714 break;
715 default: /* do nothing */ break;
716 }
717
718 event.Skip();
719}
wxTextDataObject * dragtext1

References dragtext1, mDragFocus, RuleTable, and wxT().

Here is the call graph for this function:

◆ OnRuleTableEdit()

void ExtImportPrefs::OnRuleTableEdit ( wxGridEvent &  event)

Definition at line 515 of file ExtImportPrefs.cpp.

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:
573 item->mime_types.push_back(trimmed);
574 break;
575 }
576 }
577 if (fixSpaces == wxYES)
578 {
579 wxString vals_as_string;
580 for (size_t i = 0; i < vals.size(); i++)
581 {
582 if (i > 0)
583 vals_as_string.Append (wxT(":"));
584 vals_as_string.Append (vals[i]);
585 }
586 RuleTable->SetCellValue (row, col, vals_as_string);
587 }
588
589 RuleTable->AutoSizeColumns ();
590}
void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod=wxTOKEN_RET_EMPTY_ALL)
Definition: Import.cpp:290

References AudacityMessageBox(), ExtImportItem::extensions, Importer::Get(), Importer::GetImportItems(), ExtImportItem::mime_types, RuleTable, Importer::StringToList(), wxT(), and XO().

Here is the call graph for this function:

◆ OnRuleTableKeyDown()

void ExtImportPrefs::OnRuleTableKeyDown ( wxKeyEvent &  event)

Definition at line 397 of file ExtImportPrefs.cpp.

398{
399 int mods = event.GetModifiers();
400 if (mods & wxMOD_CMD && (event.GetKeyCode() == WXK_UP ||
401 event.GetKeyCode() == WXK_DOWN))
402 {
403 DoOnRuleTableKeyDown (event.GetKeyCode());
404 }
405 else
406 {
407 event.Skip();
408 }
409}

References DoOnRuleTableKeyDown().

Here is the call graph for this function:

◆ OnRuleTableSelect()

void ExtImportPrefs::OnRuleTableSelect ( wxGridEvent &  event)

Definition at line 433 of file ExtImportPrefs.cpp.

434{
435 int toprow;
436 event.Skip();
437 if (!event.Selecting() || mStopRecursiveSelection)
438 return;
439
440 toprow = event.GetRow();
441 if (toprow < 0)
442 return;
443
444 DoOnRuleTableSelect (toprow);
445}

References DoOnRuleTableSelect(), and mStopRecursiveSelection.

Here is the call graph for this function:

◆ OnRuleTableSelectRange()

void ExtImportPrefs::OnRuleTableSelectRange ( wxGridRangeSelectEvent &  event)

Definition at line 447 of file ExtImportPrefs.cpp.

448{
449 int toprow;
450 event.Skip();
451 if (!event.Selecting() || mStopRecursiveSelection)
452 return;
453
454 toprow = event.GetTopRow();
455 if (toprow < 0)
456 return;
457
458 DoOnRuleTableSelect (toprow);
460 RuleTable->SelectRow (toprow);
462 RuleTable->SetGridCursor (toprow, 0);
463}

References DoOnRuleTableSelect(), mStopRecursiveSelection, and RuleTable.

Here is the call graph for this function:

◆ OnShow()

void ExtImportPrefs::OnShow ( wxShowEvent &  event)

Definition at line 226 of file ExtImportPrefs.cpp.

227{
228 event.Skip();
229 if (event.IsShown())
230 {
231 RuleTable->Refresh();
232 PluginList->Refresh();
233 }
234}

References PluginList, and RuleTable.

Referenced by ExtImportPrefs().

Here is the caller graph for this function:

◆ Populate()

void ExtImportPrefs::Populate ( )
private

Creates the dialog and its contents.

Definition at line 93 of file ExtImportPrefs.cpp.

94{
95 // Ensure Importer has current items
97
98 //------------------------- Main section --------------------
99 // Now construct the GUI itself.
100 // Use 'eIsCreatingFromPrefs' so that the GUI is
101 // initialised with values from gPrefs.
104 // ----------------------- End of main section --------------
105}
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
void ReadImportItems()
Definition: Import.cpp:298

References eIsCreatingFromPrefs, Importer::Get(), PopulateOrExchange(), Importer::ReadImportItems(), and S.

Here is the call graph for this function:

◆ PopulateOrExchange()

void ExtImportPrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 107 of file ExtImportPrefs.cpp.

108{
109 S.SetBorder(2);
110 S.StartScroller();
111
112 S.TieCheckBox(XXO("A&ttempt to use filter in OpenFile dialog first"),
113 {wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"),
114 true});
115 S.StartStatic(XO("Rules to choose import filters"), 1);
116 {
117 S.SetSizerProportion(1);
118 S.StartHorizontalLay (wxEXPAND, 1);
119 {
120 bool fillRuleTable = false;
121 if (RuleTable == NULL)
122 {
124
125 RuleTable->SetColLabelSize(RuleTable->GetDefaultRowSize());
126#if EXTIMPORT_MIME_SUPPORT
127 RuleTable->CreateGrid (0, 2, wxGrid::wxGridSelectRows);
128#else
129 RuleTable->CreateGrid (0, 1, wxGrid::wxGridSelectRows);
130#endif
131 RuleTable->DisableDragColMove ();
132 RuleTable->DisableDragRowSize ();
133 RuleTable->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
134 RuleTable->SetColLabelValue (0, _("File extensions"));
135#if EXTIMPORT_MIME_SUPPORT
136 RuleTable->SetColLabelValue (1, _("Mime-types"));
137#endif
138 RuleTable->SetRowLabelSize (0);
139 RuleTable->SetSelectionMode (wxGrid::wxGridSelectRows);
140 // call SetMinSize to enable scrolling on large content
141 RuleTable->Fit();
142 RuleTable->SetMinSize(RuleTable->GetSize());
143
144 ExtImportPrefsDropTarget *dragtarget1 {};
145 RuleTable->SetDropTarget (
146 dragtarget1 = safenew ExtImportPrefsDropTarget(
147 dragtext1 = safenew wxTextDataObject(wxT(""))
148 )
149 );
150 dragtarget1->SetPrefs (this);
151
152 RuleTable->EnableDragCell (true);
153 fillRuleTable = true;
154 }
155 S.Position(wxEXPAND | wxALL)
156 .AddWindow(RuleTable);
157
158 PluginList = S.Id(EIPPluginList).AddListControl(
159 { { XO("Importer order"), wxLIST_FORMAT_LEFT,
160 wxLIST_AUTOSIZE_USEHEADER } },
161 wxLC_REPORT | wxLC_SINGLE_SEL
162 );
163
164 if (fillRuleTable)
165 {
166 ExtImportPrefsDropTarget *dragtarget2 {};
167 PluginList->SetDropTarget (
168 dragtarget2 = safenew ExtImportPrefsDropTarget(
169 dragtext2 = safenew wxTextDataObject(wxT(""))
170 )
171 );
172 dragtarget2->SetPrefs (this);
173
174 auto &items = Importer::Get().GetImportItems();
175 {
176 int i = -1;
177 for (const auto &item : items)
178 AddItemToTable (++i, item.get());
179 }
180 if (!items.empty())
181 {
182 RuleTable->SelectRow(0);
183 RuleTable->SetGridCursor(0,0);
184 }
185 }
186 }
187 S.EndHorizontalLay();
188 S.StartHorizontalLay (wxSHRINK, 0);
189 {
190 MoveRuleUp = S.Id (EIPMoveRuleUp).AddButton(XXO("Move rule &up"));
191 MoveRuleDown = S.Id (EIPMoveRuleDown).AddButton(
192 XXO("Move rule &down"));
193 MoveFilterUp = S.Id (EIPMoveFilterUp).AddButton(
194 XXO("Move f&ilter up"));
195 MoveFilterDown = S.Id (EIPMoveFilterDown).AddButton(
196 XXO("Move &filter down"));
197 }
198 S.EndHorizontalLay();
199 S.StartHorizontalLay (wxSHRINK, 0);
200 {
201 AddRule = S.Id (EIPAddRule).AddButton(XXO("&Add new rule"));
202 DelRule = S.Id (EIPDelRule).AddButton(XXO("De&lete selected rule"));
203 }
204 S.EndHorizontalLay();
205 }
206 S.EndStatic();
207 S.EndScroller();
208
209 Layout();
210 Fit();
211 SetMinSize(GetSize());
212}
@ EIPRuleTable
@ EIPAddRule
@ EIPMoveRuleDown
@ EIPDelRule
@ EIPMoveFilterDown
@ EIPMoveFilterUp
@ EIPMoveRuleUp
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:9
wxButton * MoveFilterUp
wxButton * MoveRuleUp
wxButton * MoveFilterDown
wxButton * DelRule
wxButton * MoveRuleDown
wxButton * AddRule
static FormatterContext EmptyContext()
Supplies an accessible grid based on wxGrid.
Definition: Grid.h:190

References _, AddItemToTable(), AddRule, DelRule, dragtext1, dragtext2, EIPAddRule, EIPDelRule, EIPMoveFilterDown, EIPMoveFilterUp, EIPMoveRuleDown, EIPMoveRuleUp, EIPPluginList, EIPRuleTable, FormatterContext::EmptyContext(), Importer::Get(), Importer::GetImportItems(), MoveFilterDown, MoveFilterUp, MoveRuleDown, MoveRuleUp, PluginList, RuleTable, S, safenew, wxT(), XO(), and XXO().

Referenced by Commit(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SwapPluginRows()

void ExtImportPrefs::SwapPluginRows ( int  row1,
int  row2 
)

Definition at line 253 of file ExtImportPrefs.cpp.

254{
255 wxString t, t2;
256 long d, d2;
257 ImportPlugin *ip1, *ip2;
258
259 auto &items = Importer::Get().GetImportItems();
260 ExtImportItem *item = NULL;
261 if( last_selected >= 0 )
262 item = items[last_selected].get();
263
264 t = PluginList->GetItemText (row1);
265 d = PluginList->GetItemData (row1);
266 d2 = PluginList->GetItemData (row2);
267 PluginList->SetItemText (row1, PluginList->GetItemText (row2));
268 PluginList->SetItemText (row2, t);
269 if (d == -1 || d2 == -1)
270 {
271 PluginList->SetItemData (row1, PluginList->GetItemData (row2));
272 PluginList->SetItemData (row2, d);
273 if( !item )
274 return;
275 if (d == -1)
276 {
277 item->divider = row2;
278 }
279 else if (d2 == -1)
280 {
281 item->divider = row1;
282 }
283 }
284 else
285 {
286 if( !item )
287 return;
288 ip1 = item->filter_objects[d];
289 ip2 = item->filter_objects[d2];
290 item->filter_objects[d] = ip2;
291 item->filter_objects[d2] = ip1;
292 t = item->filters[d];
293 t2 = item->filters[d2];
294 item->filters[d] = t2;
295 item->filters[d2] = t;
296 }
297}
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
Definition: ImportPlugin.h:67

References ExtImportItem::divider, ExtImportItem::filter_objects, ExtImportItem::filters, Importer::Get(), Importer::GetImportItems(), last_selected, and PluginList.

Referenced by DoOnPluginKeyDown(), and ExtImportPrefsDropTarget::OnDragOver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SwapRows()

void ExtImportPrefs::SwapRows ( int  row1,
int  row2 
)

Definition at line 349 of file ExtImportPrefs.cpp.

350{
351 int t;
352 wxString ts;
353 if (row1 == row2)
354 return;
355 if (row1 > row2)
356 {
357 t = row1;
358 row1 = row2;
359 row2 = t;
360 }
361 auto &items = Importer::Get().GetImportItems();
362
363 auto &t1 = items[row1];
364 auto &t2 = items[row2];
365 std::swap(t1, t2);
366
367 for (int i = 0; i < RuleTable->GetNumberCols(); i++)
368 {
369 ts = RuleTable->GetCellValue (row2, i);
370 RuleTable->SetCellValue (row2, i, RuleTable->GetCellValue (row1, i));
371 RuleTable->SetCellValue (row1, i, ts);
372 }
373}
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:628

References Importer::Get(), Importer::GetImportItems(), RuleTable, and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by DoOnRuleTableKeyDown(), and ExtImportPrefsDropTarget::OnDragOver().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ AddRule

wxButton* ExtImportPrefs::AddRule
private

Definition at line 94 of file ExtImportPrefs.h.

Referenced by PopulateOrExchange().

◆ DelRule

wxButton* ExtImportPrefs::DelRule
private

Definition at line 95 of file ExtImportPrefs.h.

Referenced by PopulateOrExchange().

◆ dragtext1

wxTextDataObject* ExtImportPrefs::dragtext1 {}
private

Definition at line 101 of file ExtImportPrefs.h.

Referenced by OnRuleTableCellClick(), and PopulateOrExchange().

◆ dragtext2

wxTextDataObject* ExtImportPrefs::dragtext2 {}
private

Definition at line 102 of file ExtImportPrefs.h.

Referenced by OnPluginBeginDrag(), and PopulateOrExchange().

◆ last_selected

int ExtImportPrefs::last_selected
private

◆ mCreateTable

bool ExtImportPrefs::mCreateTable
private

Definition at line 104 of file ExtImportPrefs.h.

◆ mDragFocus

wxWindow* ExtImportPrefs::mDragFocus
private

Definition at line 105 of file ExtImportPrefs.h.

Referenced by GetDragFocus(), OnPluginBeginDrag(), and OnRuleTableCellClick().

◆ mFakeKeyEvent

bool ExtImportPrefs::mFakeKeyEvent
private

Definition at line 106 of file ExtImportPrefs.h.

Referenced by DoOnPluginKeyDown(), FakeOnPluginKeyDown(), and OnPluginKeyDown().

◆ MoveFilterDown

wxButton* ExtImportPrefs::MoveFilterDown
private

Definition at line 99 of file ExtImportPrefs.h.

Referenced by PopulateOrExchange().

◆ MoveFilterUp

wxButton* ExtImportPrefs::MoveFilterUp
private

Definition at line 98 of file ExtImportPrefs.h.

Referenced by PopulateOrExchange().

◆ MoveRuleDown

wxButton* ExtImportPrefs::MoveRuleDown
private

Definition at line 97 of file ExtImportPrefs.h.

Referenced by PopulateOrExchange().

◆ MoveRuleUp

wxButton* ExtImportPrefs::MoveRuleUp
private

Definition at line 96 of file ExtImportPrefs.h.

Referenced by PopulateOrExchange().

◆ mStopRecursiveSelection

bool ExtImportPrefs::mStopRecursiveSelection
private

Definition at line 107 of file ExtImportPrefs.h.

Referenced by OnRuleTableSelect(), and OnRuleTableSelectRange().

◆ PluginList

wxListCtrl* ExtImportPrefs::PluginList
private

◆ RuleTable

Grid* ExtImportPrefs::RuleTable
private

The documentation for this class was generated from the following files: