Audacity  2.2.2
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:
PrefsPanel wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 ExtImportPrefs (wxWindow *parent, wxWindowID winid)
 
 ~ExtImportPrefs ()
 
bool Commit () override
 
wxString HelpPageName () override
 
void PopulateOrExchange (ShuttleGui &S) override
 
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 wxString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
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 wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 

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
 

Detailed Description

A PrefsPanel used to select extended import filter options.

Definition at line 46 of file ExtImportPrefs.h.

Constructor & Destructor Documentation

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

Definition at line 59 of file ExtImportPrefs.cpp.

62 : PrefsPanel(parent, winid, _("Extended Import")), RuleTable(NULL),
63  PluginList(NULL), mCreateTable (false), mDragFocus (NULL),
65 {
66  Populate();
67 }
wxWindow * mDragFocus
bool mStopRecursiveSelection
void Populate()
Creates the dialog and its contents.
PrefsPanel(wxWindow *parent, wxWindowID winid, const wxString &title)
Definition: PrefsPanel.h:48
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxListCtrl * PluginList
ExtImportPrefs::~ExtImportPrefs ( )

Definition at line 69 of file ExtImportPrefs.cpp.

70 {
71 }

Member Function Documentation

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

Definition at line 554 of file ExtImportPrefs.cpp.

References ExtImportItem::extensions, ExtImportItem::mime_types, and RuleTable.

Referenced by OnAddRule(), and PopulateOrExchange().

555 {
556  wxString extensions, mime_types;
557  if (item->extensions.Count() > 0)
558  {
559  extensions.Append (item->extensions[0]);
560  for (unsigned int i = 1; i < item->extensions.Count(); i++)
561  {
562  extensions.Append (wxT(":"));
563  extensions.Append (item->extensions[i]);
564  }
565  }
566  if (item->mime_types.Count() > 0)
567  {
568  mime_types.Append (item->mime_types[0]);
569  for (unsigned int i = 1; i < item->mime_types.Count(); i++)
570  {
571  mime_types.Append (wxT(":"));
572  mime_types.Append (item->mime_types[i]);
573  }
574  }
575 
576  RuleTable->InsertRows (index, 1);
577  RuleTable->SetCellValue (index, 0, extensions);
578 #if EXTIMPORT_MIME_SUPPORT
579  RuleTable->SetCellValue (index, 1, mime_types);
580 #endif
581  RuleTable->AutoSizeColumns ();
582 }
wxArrayString mime_types
Definition: Import.h:85
wxArrayString extensions
Definition: Import.h:79
bool ExtImportPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 193 of file ExtImportPrefs.cpp.

References eIsSavingToPrefs, and PopulateOrExchange().

194 {
195  ShuttleGui S(this, eIsSavingToPrefs);
197 
198  return true;
199 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
void PopulateOrExchange(ShuttleGui &S) override
bool ExtImportPrefs::DoOnPluginKeyDown ( int  code)
private

Definition at line 264 of file ExtImportPrefs.cpp.

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

Referenced by OnPluginKeyDown().

265 {
266  if (code != WXK_UP && code != WXK_DOWN)
267  return false;
268 
269  long itemIndex = -1;
270  long itemIndex2 = -1;
271  itemIndex = PluginList->GetNextItem(itemIndex,
272  wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
273  if (itemIndex == -1)
274  return false;
275 
276  if (last_selected == -1)
277  return false;
278 
279  auto &items = Importer::Get().GetImportItems();
280  ExtImportItem *item = items[last_selected].get();
281 
282  if (code == WXK_UP && itemIndex == 0)
283  return false;
284  else if (code == WXK_DOWN && itemIndex == PluginList->GetItemCount() - 1)
285  return false;
286 
287  if (code == WXK_UP)
288  {
289  itemIndex2 = itemIndex - 1;
290  }
291  else if (code == WXK_DOWN)
292  {
293  itemIndex2 = itemIndex + 1;
294  }
295  SwapPluginRows (itemIndex, itemIndex2);
296  if (mFakeKeyEvent)
297  {
298  PluginList->SetItemState (itemIndex, 0, wxLIST_STATE_SELECTED);
299  PluginList->SetItemState (itemIndex2, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
300  }
301  int fcount = item->filter_objects.size();
302  if (item->divider >= fcount)
303  {
304  item->divider = -1;
305  }
306  if (item->divider < -1)
307  item->divider = item->filter_objects.size() - 1;
308 
309  return true;
310 }
ExtImportItems & GetImportItems()
Definition: Import.h:131
void SwapPluginRows(int row1, int row2)
wxListCtrl * PluginList
std::vector< ImportPlugin * > filter_objects
Definition: Import.h:73
static Importer & Get()
Definition: Import.cpp:71
int divider
Definition: Import.h:68
void ExtImportPrefs::DoOnRuleTableKeyDown ( int  keycode)
private

Definition at line 375 of file ExtImportPrefs.cpp.

References RuleTable, and SwapRows().

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

376 {
377  int selrow = RuleTable->GetGridCursorRow ();
378  wxString ts;
379  if (keycode == WXK_UP)
380  {
381  if (selrow <= 0)
382  return;
383  SwapRows (selrow - 1, selrow);
384  RuleTable->MoveCursorUp (false);
385  RuleTable->SelectRow (selrow - 1);
386  }
387  else if (keycode == WXK_DOWN)
388  {
389  if (selrow == RuleTable->GetNumberRows() - 1)
390  return;
391  SwapRows (selrow, selrow + 1);
392  RuleTable->MoveCursorDown (false);
393  RuleTable->SelectRow (selrow + 1);
394  }
395 }
void SwapRows(int row1, int row2)
void ExtImportPrefs::DoOnRuleTableSelect ( int  toprow)
private

Definition at line 429 of file ExtImportPrefs.cpp.

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

Referenced by OnRuleTableSelect(), and OnRuleTableSelectRange().

430 {
431  auto &items = Importer::Get().GetImportItems();
432 
433  if (toprow < 0 || toprow > (int)items.size())
434  {
435  return;
436  }
437 
438  ExtImportItem *item = items[toprow].get();
439  PluginList->DeleteAllItems();
440 
441  int fcount;
442  fcount = item->filters.Count();
443  int shift = 0;
444  for (int i = 0; i < fcount; i++)
445  {
446  if (item->divider == i)
447  {
448  PluginList->InsertItem (i, _("Unused filters:"));
449  PluginList->SetItemData (i, -1);
450  shift = 1;
451  }
452  if (item->filter_objects[i] != NULL)
453  {
454  PluginList->InsertItem (i + shift,
455  item->filter_objects[i]->GetPluginFormatDescription());
456  }
457  else
458  {
459  PluginList->InsertItem (i + shift, item->filters[i]);
460  }
461  PluginList->SetItemData (i + shift, i);
462  }
463  if (item->divider == -1)
464  {
465  PluginList->InsertItem (fcount, _("Unused filters:"));
466  PluginList->SetItemData (fcount, -1);
467  }
468  wxListItem info;
469  info.SetId (0);
470  info.SetColumn (0);
471  info.SetStateMask (wxLIST_STATE_SELECTED);
472  info.SetState (wxLIST_STATE_SELECTED);
473  info.SetMask (wxLIST_MASK_STATE);
474  PluginList->SetItem (info);
475  PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE);
476  last_selected = toprow;
477 }
wxArrayString filters
Definition: Import.h:59
ExtImportItems & GetImportItems()
Definition: Import.h:131
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxListCtrl * PluginList
std::vector< ImportPlugin * > filter_objects
Definition: Import.h:73
static Importer & Get()
Definition: Import.cpp:71
int divider
Definition: Import.h:68
void ExtImportPrefs::FakeOnPluginKeyDown ( int  keycode)
private

Definition at line 631 of file ExtImportPrefs.cpp.

References EIPPluginList, and mFakeKeyEvent.

Referenced by OnFilterMoveDown(), and OnFilterMoveUp().

632 {
633  wxListEvent fakeevent(wxEVT_COMMAND_LIST_KEY_DOWN, EIPPluginList);
634  fakeevent.SetEventObject(this);
635  fakeevent.m_code = keycode;
636  mFakeKeyEvent = true;
637  GetEventHandler()->ProcessEvent (fakeevent);
638  mFakeKeyEvent = false;
639 }
wxWindow* ExtImportPrefs::GetDragFocus ( )
inline

Definition at line 77 of file ExtImportPrefs.h.

References mDragFocus.

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

77 { return mDragFocus; }
wxWindow * mDragFocus
wxListCtrl* ExtImportPrefs::GetPluginList ( )
inline

Definition at line 75 of file ExtImportPrefs.h.

References PluginList.

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

75 { return PluginList; }
wxListCtrl * PluginList
Grid* ExtImportPrefs::GetRuleTable ( )
inline

Definition at line 74 of file ExtImportPrefs.h.

References RuleTable.

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

74 { return RuleTable; }
wxString ExtImportPrefs::HelpPageName ( )
overridevirtual

Reimplemented from PrefsPanel.

Definition at line 677 of file ExtImportPrefs.cpp.

678 {
679  return "Extended_Import_Preferences";
680 }
void ExtImportPrefs::OnAddRule ( wxCommandEvent &  event)

Definition at line 584 of file ExtImportPrefs.cpp.

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

585 {
586  auto &items = Importer::Get().GetImportItems();
587  auto uitem = Importer::Get().CreateDefaultImportItem();
588  auto item = uitem.get();
589  items.push_back(std::move(uitem));
590  AddItemToTable (RuleTable->GetNumberRows (), item);
591 
592  RuleTable->SelectRow(RuleTable->GetNumberRows () - 1);
593  RuleTable->SetGridCursor (RuleTable->GetNumberRows () - 1, 0);
594  RuleTable->SetFocus();
595 }
void AddItemToTable(int index, const ExtImportItem *item)
ExtImportItems & GetImportItems()
Definition: Import.h:131
static Importer & Get()
Definition: Import.cpp:71
std::unique_ptr< ExtImportItem > CreateDefaultImportItem()
Definition: Import.cpp:310
void ExtImportPrefs::OnDelRule ( wxCommandEvent &  event)

Definition at line 597 of file ExtImportPrefs.cpp.

References _(), AudacityMessageBox(), Importer::Get(), Importer::GetImportItems(), last_selected, and RuleTable.

598 {
599  if (last_selected < 0)
600  return;
601  auto &items = Importer::Get().GetImportItems();
602 
603  int msgres = AudacityMessageBox (_("Do you really want to delete selected rule?"),
604  _("Rule deletion confirmation"), wxYES_NO, RuleTable);
605  // Yes or no, there is no third!
606  if (msgres != wxYES)
607  return;
608 
609  RuleTable->DeleteRows (last_selected);
610  items.erase (items.begin() + last_selected);
611  RuleTable->AutoSizeColumns ();
612  if (last_selected >= RuleTable->GetNumberRows ())
613  last_selected = RuleTable->GetNumberRows () - 1;
614  if (last_selected >= 0)
615  {
616  RuleTable->SelectRow(last_selected);
617  RuleTable->SetGridCursor (last_selected, 0);
618  }
619 }
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
ExtImportItems & GetImportItems()
Definition: Import.h:131
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
static Importer & Get()
Definition: Import.cpp:71
void ExtImportPrefs::OnFilterMoveDown ( wxCommandEvent &  event)

Definition at line 646 of file ExtImportPrefs.cpp.

References FakeOnPluginKeyDown().

647 {
648  FakeOnPluginKeyDown (WXK_DOWN);
649 }
void FakeOnPluginKeyDown(int keycode)
void ExtImportPrefs::OnFilterMoveUp ( wxCommandEvent &  event)

Definition at line 641 of file ExtImportPrefs.cpp.

References FakeOnPluginKeyDown().

642 {
643  FakeOnPluginKeyDown (WXK_UP);
644 }
void FakeOnPluginKeyDown(int keycode)
void ExtImportPrefs::OnNavKey ( wxNavigationKeyEvent &  event)
void ExtImportPrefs::OnPluginBeginDrag ( wxListEvent &  event)

Definition at line 339 of file ExtImportPrefs.cpp.

References dragtext2, mDragFocus, and PluginList.

340 {
341  wxDropSource dragSource(this);
342  dragtext2->SetText(wxT(""));
343  dragSource.SetData(*dragtext2);
345  if( mDragFocus == NULL )
346  return;
347  wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove);
348  mDragFocus = NULL;
349  switch (result)
350  {
351  case wxDragCopy:
352  case wxDragMove:
353  case wxDragNone:
354  return;
355  break;
356  default:
357  break;
358  }
359 }
wxWindow * mDragFocus
wxTextDataObject * dragtext2
wxListCtrl * PluginList
void ExtImportPrefs::OnPluginKeyDown ( wxListEvent &  event)

Definition at line 201 of file ExtImportPrefs.cpp.

References DoOnPluginKeyDown(), and mFakeKeyEvent.

202 {
203  for (int i = 0; i < 1; i++)
204  {
205 #ifdef __WXMAC__
206  if (!mFakeKeyEvent && !wxGetKeyState(WXK_COMMAND))
207  break;
208 #else
209  if (!mFakeKeyEvent && !wxGetKeyState(WXK_CONTROL))
210  break;
211 #endif
212 
213  if (DoOnPluginKeyDown (event.GetKeyCode()))
214  event.Skip();
215  }
216 }
bool DoOnPluginKeyDown(int code)
void ExtImportPrefs::OnRuleMoveDown ( wxCommandEvent &  event)

Definition at line 626 of file ExtImportPrefs.cpp.

References DoOnRuleTableKeyDown().

627 {
628  DoOnRuleTableKeyDown (WXK_DOWN);
629 }
void DoOnRuleTableKeyDown(int keycode)
void ExtImportPrefs::OnRuleMoveUp ( wxCommandEvent &  event)

Definition at line 621 of file ExtImportPrefs.cpp.

References DoOnRuleTableKeyDown().

622 {
623  DoOnRuleTableKeyDown (WXK_UP);
624 }
void DoOnRuleTableKeyDown(int keycode)
void ExtImportPrefs::OnRuleTableCellClick ( wxGridEvent &  event)

Definition at line 652 of file ExtImportPrefs.cpp.

References dragtext1, mDragFocus, and RuleTable.

653 {
654  int row = event.GetRow();
655  RuleTable->SelectRow (row, false);
656  RuleTable->SetGridCursor (row, 0);
657 
658  wxDropSource dragSource(this);
659  dragtext1->SetText(wxT(""));
660  dragSource.SetData(*dragtext1);
662  wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove);
663  mDragFocus = NULL;
664  switch (result)
665  {
666  case wxDragCopy: /* copy the data */
667  case wxDragMove:
668  case wxDragNone:
669  return;
670  break;
671  default: /* do nothing */ break;
672  }
673 
674  event.Skip();
675 }
wxWindow * mDragFocus
wxTextDataObject * dragtext1
void ExtImportPrefs::OnRuleTableEdit ( wxGridEvent &  event)

Definition at line 479 of file ExtImportPrefs.cpp.

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

480 {
481  int row = event.GetRow();
482  int col = event.GetCol();
483  auto &items = Importer::Get().GetImportItems();
484  ExtImportItem *item = items[row].get();
485  RuleTable->SaveEditControlValue();
486 
487  wxString val = RuleTable->GetCellValue (row, col);
488  int fixSpaces = wxNO;
489  bool askedAboutSpaces = false;
490  wxArrayString vals;
491  wxString delims(wxT(":"));
492  Importer::Get().StringToList (val, delims, vals);
493  switch (col)
494  {
495  case 0:
496  item->extensions.Clear();
497  break;
498  case 1:
499  item->mime_types.Clear();
500  break;
501  }
502 
503  for (size_t i = 0; i < vals.Count(); i++)
504  {
505 
506  wxString trimmed = vals[i];
507  trimmed.Trim().Trim(false);
508  if (trimmed.Cmp(vals[i]) != 0)
509  {
510  if (!askedAboutSpaces)
511  {
512  fixSpaces = AudacityMessageBox(_(
513 "There are space characters (spaces, newlines, tabs or linefeeds) in one of \
514 the items. They are likely to break the pattern matching. Unless you know \
515 what you are doing, it is recommended to trim spaces. Do you want \
516 Audacity to trim spaces for you?"
517  ),_("Spaces detected"), wxYES_NO);
518  askedAboutSpaces = true;
519  }
520  if (fixSpaces != wxYES)
521  {
522  trimmed = vals[i];
523  }
524  else
525  {
526  vals[i] = trimmed;
527  }
528  }
529  switch (col)
530  {
531  case 0:
532  item->extensions.Add (trimmed);
533  break;
534  case 1:
535  item->mime_types.Add (trimmed);
536  break;
537  }
538  }
539  if (fixSpaces == wxYES)
540  {
541  wxString vals_as_string;
542  for (size_t i = 0; i < vals.Count(); i++)
543  {
544  if (i > 0)
545  vals_as_string.Append (wxT(":"));
546  vals_as_string.Append (vals[i]);
547  }
548  RuleTable->SetCellValue (row, col, vals_as_string);
549  }
550 
551  RuleTable->AutoSizeColumns ();
552 }
void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod=wxTOKEN_RET_EMPTY_ALL)
Definition: Import.cpp:132
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
ExtImportItems & GetImportItems()
Definition: Import.h:131
wxArrayString mime_types
Definition: Import.h:85
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxArrayString extensions
Definition: Import.h:79
static Importer & Get()
Definition: Import.cpp:71
void ExtImportPrefs::OnRuleTableKeyDown ( wxKeyEvent &  event)

Definition at line 361 of file ExtImportPrefs.cpp.

References DoOnRuleTableKeyDown().

362 {
363  int mods = event.GetModifiers();
364  if (mods & wxMOD_CMD && (event.GetKeyCode() == WXK_UP ||
365  event.GetKeyCode() == WXK_DOWN))
366  {
367  DoOnRuleTableKeyDown (event.GetKeyCode());
368  }
369  else
370  {
371  event.Skip();
372  }
373 }
void DoOnRuleTableKeyDown(int keycode)
void ExtImportPrefs::OnRuleTableSelect ( wxGridEvent &  event)

Definition at line 397 of file ExtImportPrefs.cpp.

References DoOnRuleTableSelect(), and mStopRecursiveSelection.

398 {
399  int toprow;
400  event.Skip();
401  if (!event.Selecting() || mStopRecursiveSelection)
402  return;
403 
404  toprow = event.GetRow();
405  if (toprow < 0)
406  return;
407 
408  DoOnRuleTableSelect (toprow);
409 }
bool mStopRecursiveSelection
void DoOnRuleTableSelect(int toprow)
void ExtImportPrefs::OnRuleTableSelectRange ( wxGridRangeSelectEvent &  event)

Definition at line 411 of file ExtImportPrefs.cpp.

References DoOnRuleTableSelect(), mStopRecursiveSelection, and RuleTable.

412 {
413  int toprow;
414  event.Skip();
415  if (!event.Selecting() || mStopRecursiveSelection)
416  return;
417 
418  toprow = event.GetTopRow();
419  if (toprow < 0)
420  return;
421 
422  DoOnRuleTableSelect (toprow);
424  RuleTable->SelectRow (toprow);
425  mStopRecursiveSelection = false;
426  RuleTable->SetGridCursor (toprow, 0);
427 }
bool mStopRecursiveSelection
void DoOnRuleTableSelect(int toprow)
void ExtImportPrefs::Populate ( )
private

Creates the dialog and its contents.

Definition at line 74 of file ExtImportPrefs.cpp.

References eIsCreatingFromPrefs, and PopulateOrExchange().

75 {
76  //------------------------- Main section --------------------
77  // Now construct the GUI itself.
78  // Use 'eIsCreatingFromPrefs' so that the GUI is
79  // initialised with values from gPrefs.
82  // ----------------------- End of main section --------------
83 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
void PopulateOrExchange(ShuttleGui &S) override
void ExtImportPrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 85 of file ExtImportPrefs.cpp.

References _(), ShuttleGuiBase::AddButton(), AddItemToTable(), ShuttleGuiBase::AddListControl(), AddRule, ShuttleGuiBase::AddWindow(), DelRule, dragtext1, dragtext2, EIPAddRule, EIPDelRule, EIPMoveFilterDown, EIPMoveFilterUp, EIPMoveRuleDown, EIPMoveRuleUp, EIPPluginList, EIPRuleTable, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndScroller(), ShuttleGuiBase::EndStatic(), Importer::Get(), Importer::GetImportItems(), ShuttleGuiBase::GetParent(), ShuttleGui::Id(), MoveFilterDown, MoveFilterUp, MoveRuleDown, MoveRuleUp, PluginList, RuleTable, safenew, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::SetSizerProportion(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartScroller(), ShuttleGuiBase::StartStatic(), and ShuttleGuiBase::TieCheckBox().

Referenced by Commit(), and Populate().

86 {
87  S.SetBorder(2);
88  S.StartScroller();
89 
90  S.TieCheckBox(_("A&ttempt to use filter in OpenFile dialog first"),
91  wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"),
92  true);
93  S.StartStatic(_("Rules to choose import filters"), 1);
94  {
95  S.SetSizerProportion(1);
96  S.StartHorizontalLay (wxEXPAND, 1);
97  {
98  bool fillRuleTable = false;
99  if (RuleTable == NULL)
100  {
102 
103  RuleTable->SetColLabelSize(RuleTable->GetDefaultRowSize());
104 #if EXTIMPORT_MIME_SUPPORT
105  RuleTable->CreateGrid (0, 2, wxGrid::wxGridSelectRows);
106 #else
107  RuleTable->CreateGrid (0, 1, wxGrid::wxGridSelectRows);
108 #endif
109  RuleTable->DisableDragColMove ();
110  RuleTable->DisableDragRowSize ();
111  RuleTable->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
112  RuleTable->SetColLabelValue (0, _("File extensions"));
113 #if EXTIMPORT_MIME_SUPPORT
114  RuleTable->SetColLabelValue (1, _("Mime-types"));
115 #endif
116  RuleTable->SetRowLabelSize (0);
117  RuleTable->SetSelectionMode (wxGrid::wxGridSelectRows);
118  // call SetMinSize to enable scrolling on large content
119  RuleTable->Fit();
120  RuleTable->SetMinSize(RuleTable->GetSize());
121 
122  ExtImportPrefsDropTarget *dragtarget1 {};
123  RuleTable->SetDropTarget (
124  dragtarget1 = safenew ExtImportPrefsDropTarget(
125  dragtext1 = safenew wxTextDataObject(wxT(""))
126  )
127  );
128  dragtarget1->SetPrefs (this);
129 
130  RuleTable->EnableDragCell (true);
131  fillRuleTable = true;
132  }
133  S.AddWindow(RuleTable, wxEXPAND | wxALL);
134 
136 
137  if (fillRuleTable)
138  {
139  PluginList->SetSingleStyle (wxLC_REPORT, true);
140  PluginList->SetSingleStyle (wxLC_SINGLE_SEL, true);
141  PluginList->InsertColumn (0, _("Importer order"));
142 
143  ExtImportPrefsDropTarget *dragtarget2 {};
144  PluginList->SetDropTarget (
145  dragtarget2 = safenew ExtImportPrefsDropTarget(
146  dragtext2 = safenew wxTextDataObject(wxT(""))
147  )
148  );
149  dragtarget2->SetPrefs (this);
150 
151  PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE_USEHEADER);
152 
153  auto &items = Importer::Get().GetImportItems();
154  {
155  int i = -1;
156  for (const auto &item : items)
157  AddItemToTable (++i, item.get());
158  }
159  if (!items.empty())
160  {
161  RuleTable->SelectRow(0);
162  RuleTable->SetGridCursor(0,0);
163  }
164  }
165  }
166  S.EndHorizontalLay();
167  S.StartHorizontalLay (wxSHRINK, 0);
168  {
169  MoveRuleUp = S.Id (EIPMoveRuleUp).AddButton (_("Move rule &up"));
171  (_("Move rule &down"));
173  (_("Move f&ilter up"));
175  (_("Move &filter down"));
176  }
177  S.EndHorizontalLay();
178  S.StartHorizontalLay (wxSHRINK, 0);
179  {
180  AddRule = S.Id (EIPAddRule).AddButton (_("&Add new rule"));
181  DelRule = S.Id (EIPDelRule).AddButton (_("De&lete selected rule"));
182  }
183  S.EndHorizontalLay();
184  }
185  S.EndStatic();
186  S.EndScroller();
187 
188  Layout();
189  Fit();
190  SetMinSize(GetSize());
191 }
void AddItemToTable(int index, const ExtImportItem *item)
wxWindow * AddWindow(wxWindow *pWindow, int Flags=wxALIGN_CENTRE|wxALL)
Definition: ShuttleGui.cpp:288
wxButton * MoveRuleDown
wxButton * MoveFilterDown
ExtImportItems & GetImportItems()
Definition: Import.h:131
void EndScroller()
Definition: ShuttleGui.cpp:828
wxListCtrl * AddListControl()
Definition: ShuttleGui.cpp:661
wxTextDataObject * dragtext2
void SetSizerProportion(int iProp)
Definition: ShuttleGui.h:289
#define safenew
Definition: Audacity.h:230
void EndHorizontalLay()
wxButton * AddRule
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:795
wxWindow * GetParent()
Definition: ShuttleGui.h:294
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
wxButton * MoveFilterUp
ShuttleGui & Id(int id)
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxListCtrl * PluginList
wxCheckBox * TieCheckBox(const wxString &Prompt, WrappedType &WrappedRef)
wxButton * MoveRuleUp
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:763
wxTextDataObject * dragtext1
wxButton * DelRule
Supplies an accessible grid based on wxGrid.
Definition: Grid.h:193
static Importer & Get()
Definition: Import.cpp:71
void SetBorder(int Border)
Definition: ShuttleGui.h:286
wxButton * AddButton(const wxString &Text, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:341
void ExtImportPrefs::SwapPluginRows ( int  row1,
int  row2 
)

Definition at line 218 of file ExtImportPrefs.cpp.

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

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

219 {
220  wxString t, t2;
221  long d, d2;
222  ImportPlugin *ip1, *ip2;
223 
224  auto &items = Importer::Get().GetImportItems();
225  ExtImportItem *item = NULL;
226  if( last_selected >= 0 )
227  item = items[last_selected].get();
228 
229  t = PluginList->GetItemText (row1);
230  d = PluginList->GetItemData (row1);
231  d2 = PluginList->GetItemData (row2);
232  PluginList->SetItemText (row1, PluginList->GetItemText (row2));
233  PluginList->SetItemText (row2, t);
234  if (d == -1 || d2 == -1)
235  {
236  PluginList->SetItemData (row1, PluginList->GetItemData (row2));
237  PluginList->SetItemData (row2, d);
238  if( !item )
239  return;
240  if (d == -1)
241  {
242  item->divider = row2;
243  }
244  else if (d2 == -1)
245  {
246  item->divider = row1;
247  }
248  }
249  else
250  {
251  if( !item )
252  return;
253  ip1 = item->filter_objects[d];
254  ip2 = item->filter_objects[d2];
255  item->filter_objects[d] = ip2;
256  item->filter_objects[d2] = ip1;
257  t = item->filters[d];
258  t2 = item->filters[d2];
259  item->filters[d] = t2;
260  item->filters[d2] = t;
261  }
262 }
wxArrayString filters
Definition: Import.h:59
ExtImportItems & GetImportItems()
Definition: Import.h:131
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
Definition: ImportPlugin.h:73
wxListCtrl * PluginList
std::vector< ImportPlugin * > filter_objects
Definition: Import.h:73
static Importer & Get()
Definition: Import.cpp:71
int divider
Definition: Import.h:68
void ExtImportPrefs::SwapRows ( int  row1,
int  row2 
)

Definition at line 313 of file ExtImportPrefs.cpp.

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

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

314 {
315  int t;
316  wxString ts;
317  if (row1 == row2)
318  return;
319  if (row1 > row2)
320  {
321  t = row1;
322  row1 = row2;
323  row2 = t;
324  }
325  auto &items = Importer::Get().GetImportItems();
326 
327  auto &t1 = items[row1];
328  auto &t2 = items[row2];
329  std::swap(t1, t2);
330 
331  for (int i = 0; i < RuleTable->GetNumberCols(); i++)
332  {
333  ts = RuleTable->GetCellValue (row2, i);
334  RuleTable->SetCellValue (row2, i, RuleTable->GetCellValue (row1, i));
335  RuleTable->SetCellValue (row1, i, ts);
336  }
337 }
ExtImportItems & GetImportItems()
Definition: Import.h:131
static Importer & Get()
Definition: Import.cpp:71

Member Data Documentation

wxButton* ExtImportPrefs::AddRule
private

Definition at line 84 of file ExtImportPrefs.h.

Referenced by PopulateOrExchange().

wxButton* ExtImportPrefs::DelRule
private

Definition at line 85 of file ExtImportPrefs.h.

Referenced by PopulateOrExchange().

wxTextDataObject* ExtImportPrefs::dragtext1 {}
private

Definition at line 91 of file ExtImportPrefs.h.

Referenced by OnRuleTableCellClick(), and PopulateOrExchange().

wxTextDataObject* ExtImportPrefs::dragtext2 {}
private

Definition at line 92 of file ExtImportPrefs.h.

Referenced by OnPluginBeginDrag(), and PopulateOrExchange().

int ExtImportPrefs::last_selected
private

Definition at line 99 of file ExtImportPrefs.h.

Referenced by DoOnPluginKeyDown(), DoOnRuleTableSelect(), OnDelRule(), and SwapPluginRows().

bool ExtImportPrefs::mCreateTable
private

Definition at line 94 of file ExtImportPrefs.h.

wxWindow* ExtImportPrefs::mDragFocus
private

Definition at line 95 of file ExtImportPrefs.h.

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

bool ExtImportPrefs::mFakeKeyEvent
private

Definition at line 96 of file ExtImportPrefs.h.

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

wxButton* ExtImportPrefs::MoveFilterDown
private

Definition at line 89 of file ExtImportPrefs.h.

Referenced by PopulateOrExchange().

wxButton* ExtImportPrefs::MoveFilterUp
private

Definition at line 88 of file ExtImportPrefs.h.

Referenced by PopulateOrExchange().

wxButton* ExtImportPrefs::MoveRuleDown
private

Definition at line 87 of file ExtImportPrefs.h.

Referenced by PopulateOrExchange().

wxButton* ExtImportPrefs::MoveRuleUp
private

Definition at line 86 of file ExtImportPrefs.h.

Referenced by PopulateOrExchange().

bool ExtImportPrefs::mStopRecursiveSelection
private

Definition at line 97 of file ExtImportPrefs.h.

Referenced by OnRuleTableSelect(), and OnRuleTableSelectRange().

wxListCtrl* ExtImportPrefs::PluginList
private
Grid* ExtImportPrefs::RuleTable
private

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