1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 15:49:36 +02:00

Extended import filtering fixes

* Fix PluginList item selection movement (Linux)
 Removed some unneeded code that b0rked item selection
 in PluginList on Linux.
* Fix RuleTable multi-item drag selection.
 Used undocumented EnableDragCell() method for that,
 but now it is not possible to select multiple items
 by dragging. It is still necessary to select an item
 before you can drag it (because click-event occurs
 after selection is changed and you can not select
 an item without moving it otherwise).
* Fix indentation
 Converted tabs to 3-spaces.
 Wrapped everything at 80th column.
This commit is contained in:
LRN1986 2010-04-23 17:55:27 +00:00
parent 2ff846817f
commit a36aeba850

View File

@ -29,14 +29,14 @@
enum ExtImportPrefsControls enum ExtImportPrefsControls
{ {
EIPPluginList = 20000, EIPPluginList = 20000,
EIPRuleTable, EIPRuleTable,
EIPAddRule, EIPAddRule,
EIPDelRule, EIPDelRule,
EIPMoveRuleUp, EIPMoveRuleUp,
EIPMoveRuleDown, EIPMoveRuleDown,
EIPMoveFilterUp, EIPMoveFilterUp,
EIPMoveFilterDown EIPMoveFilterDown
}; };
BEGIN_EVENT_TABLE(ExtImportPrefs, PrefsPanel) BEGIN_EVENT_TABLE(ExtImportPrefs, PrefsPanel)
@ -55,7 +55,8 @@ BEGIN_EVENT_TABLE(ExtImportPrefs, PrefsPanel)
END_EVENT_TABLE() END_EVENT_TABLE()
ExtImportPrefs::ExtImportPrefs(wxWindow * parent) ExtImportPrefs::ExtImportPrefs(wxWindow * parent)
: PrefsPanel(parent, _("Extended Import")), RuleTable(NULL), PluginList(NULL), mCreateTable (false), last_selected (-1) : PrefsPanel(parent, _("Extended Import")), RuleTable(NULL),
PluginList(NULL), mCreateTable (false), last_selected (-1)
{ {
dragtext = new wxTextDataObject(wxT("")); dragtext = new wxTextDataObject(wxT(""));
dragtarget = new RuleTableDropTarget(dragtext); dragtarget = new RuleTableDropTarget(dragtext);
@ -83,18 +84,20 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
{ {
S.SetBorder(2); S.SetBorder(2);
S.TieCheckBox(_("Filter chosen in OpenFile dialog overrides any rules"), wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"), false); S.TieCheckBox(_("Filter chosen in OpenFile dialog overrides any rules"),
wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"),
false);
S.StartStatic(_("Rules to choose import filters"), 1); S.StartStatic(_("Rules to choose import filters"), 1);
{ {
S.SetSizerProportion(1); S.SetSizerProportion(1);
S.StartHorizontalLay (wxEXPAND, 1); S.StartHorizontalLay (wxEXPAND, 1);
{ {
bool fillRuleTable = false; bool fillRuleTable = false;
if (RuleTable == NULL) if (RuleTable == NULL)
{ {
RuleTable = new Grid(S.GetParent(),EIPRuleTable); RuleTable = new Grid(S.GetParent(),EIPRuleTable);
RuleTable->SetColLabelSize(RuleTable->GetDefaultRowSize()); RuleTable->SetColLabelSize(RuleTable->GetDefaultRowSize());
#if EXTIMPORT_MIME_SUPPORT #if EXTIMPORT_MIME_SUPPORT
RuleTable->CreateGrid (0, 2, wxGrid::wxGridSelectRows); RuleTable->CreateGrid (0, 2, wxGrid::wxGridSelectRows);
#else #else
@ -112,14 +115,15 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
RuleTable->AutoSizeColumns (); RuleTable->AutoSizeColumns ();
RuleTable->SetDropTarget (dragtarget); RuleTable->SetDropTarget (dragtarget);
RuleTable->EnableDragCell (true);
fillRuleTable = true; fillRuleTable = true;
} }
S.AddWindow(RuleTable, wxEXPAND | wxALL); S.AddWindow(RuleTable, wxEXPAND | wxALL);
PluginList = S.Id(EIPPluginList).AddListControl (); PluginList = S.Id(EIPPluginList).AddListControl ();
PluginList->SetSingleStyle (wxLC_REPORT, true); PluginList->SetSingleStyle (wxLC_REPORT, true);
PluginList->SetSingleStyle (wxLC_SINGLE_SEL, true); PluginList->SetSingleStyle (wxLC_SINGLE_SEL, true);
PluginList->InsertColumn (0, _("Importer order")); PluginList->InsertColumn (0, _("Importer order"));
if (fillRuleTable) if (fillRuleTable)
{ {
@ -132,22 +136,25 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
RuleTable->SetGridCursor(0,0); RuleTable->SetGridCursor(0,0);
} }
} }
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
S.StartHorizontalLay (wxSHRINK, 0); S.StartHorizontalLay (wxSHRINK, 0);
{ {
MoveRuleUp = S.Id (EIPMoveRuleUp).AddButton (_("Move rule &up")); MoveRuleUp = S.Id (EIPMoveRuleUp).AddButton (_("Move rule &up"));
MoveRuleDown = S.Id (EIPMoveRuleDown).AddButton (_("Move rule &down")); MoveRuleDown = S.Id (EIPMoveRuleDown).AddButton
MoveFilterUp = S.Id (EIPMoveFilterUp).AddButton (_("Move f&ilter up")); (_("Move rule &down"));
MoveFilterDown = S.Id (EIPMoveFilterDown).AddButton (_("Move &filter down")); MoveFilterUp = S.Id (EIPMoveFilterUp).AddButton
} (_("Move f&ilter up"));
S.EndHorizontalLay(); MoveFilterDown = S.Id (EIPMoveFilterDown).AddButton
S.StartHorizontalLay (wxSHRINK, 0); (_("Move &filter down"));
{ }
AddRule = S.Id (EIPAddRule).AddButton (_("&Add new rule")); S.EndHorizontalLay();
DelRule = S.Id (EIPDelRule).AddButton (_("De&lete selected rule")); S.StartHorizontalLay (wxSHRINK, 0);
} {
S.EndHorizontalLay(); AddRule = S.Id (EIPAddRule).AddButton (_("&Add new rule"));
DelRule = S.Id (EIPDelRule).AddButton (_("De&lete selected rule"));
}
S.EndHorizontalLay();
} }
S.EndStatic(); S.EndStatic();
Layout(); Layout();
@ -176,23 +183,23 @@ void ExtImportPrefs::OnPluginKeyDown(wxListEvent& event)
#endif #endif
if (DoOnPluginKeyDown (event.GetKeyCode())) if (DoOnPluginKeyDown (event.GetKeyCode()))
event.Skip(); event.Skip();
} }
} }
bool ExtImportPrefs::DoOnPluginKeyDown (int code) bool ExtImportPrefs::DoOnPluginKeyDown (int code)
{ {
if (code != WXK_UP && code != WXK_DOWN) if (code != WXK_UP && code != WXK_DOWN)
return false; return false;
long itemIndex = -1; long itemIndex = -1;
itemIndex = PluginList->GetNextItem(itemIndex, itemIndex = PluginList->GetNextItem(itemIndex,
wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (itemIndex == -1) if (itemIndex == -1)
return false; return false;
if (last_selected == -1) if (last_selected == -1)
return false; return false;
ExtImportItems *items = wxGetApp().mImporter->GetImportItems(); ExtImportItems *items = wxGetApp().mImporter->GetImportItems();
ExtImportItem *item = &(*items)[last_selected]; ExtImportItem *item = &(*items)[last_selected];
@ -210,11 +217,13 @@ bool ExtImportPrefs::DoOnPluginKeyDown (int code)
t = PluginList->GetItemText (itemIndex); t = PluginList->GetItemText (itemIndex);
d = PluginList->GetItemData (itemIndex); d = PluginList->GetItemData (itemIndex);
d2 = PluginList->GetItemData (itemIndex - 1); d2 = PluginList->GetItemData (itemIndex - 1);
PluginList->SetItemText (itemIndex, PluginList->GetItemText (itemIndex - 1)); PluginList->SetItemText (itemIndex, PluginList->GetItemText (
itemIndex - 1));
PluginList->SetItemText (itemIndex - 1, t); PluginList->SetItemText (itemIndex - 1, t);
if (d == -1 || d2 == -1) if (d == -1 || d2 == -1)
{ {
PluginList->SetItemData (itemIndex, PluginList->GetItemData (itemIndex - 1)); PluginList->SetItemData (itemIndex, PluginList->GetItemData (
itemIndex - 1));
PluginList->SetItemData (itemIndex - 1, d); PluginList->SetItemData (itemIndex - 1, d);
if (d == -1) if (d == -1)
{ {
@ -236,19 +245,19 @@ bool ExtImportPrefs::DoOnPluginKeyDown (int code)
item->filters[d] = t2; item->filters[d] = t2;
item->filters[d2] = t; item->filters[d2] = t;
} }
PluginList->SetItemState (itemIndex - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
PluginList->SetItemState (itemIndex, 0, wxLIST_STATE_SELECTED);
} }
else if (code == WXK_DOWN) else if (code == WXK_DOWN)
{ {
t = PluginList->GetItemText (itemIndex); t = PluginList->GetItemText (itemIndex);
d = PluginList->GetItemData (itemIndex); d = PluginList->GetItemData (itemIndex);
d2 = PluginList->GetItemData (itemIndex + 1); d2 = PluginList->GetItemData (itemIndex + 1);
PluginList->SetItemText (itemIndex, PluginList->GetItemText (itemIndex + 1)); PluginList->SetItemText (itemIndex, PluginList->GetItemText (
itemIndex + 1));
PluginList->SetItemText (itemIndex + 1, t); PluginList->SetItemText (itemIndex + 1, t);
if (d == -1 || d2 == -1) if (d == -1 || d2 == -1)
{ {
PluginList->SetItemData (itemIndex, PluginList->GetItemData (itemIndex + 1)); PluginList->SetItemData (itemIndex, PluginList->GetItemData (
itemIndex + 1));
PluginList->SetItemData (itemIndex + 1, d); PluginList->SetItemData (itemIndex + 1, d);
if (d == -1) if (d == -1)
{ {
@ -270,8 +279,6 @@ bool ExtImportPrefs::DoOnPluginKeyDown (int code)
item->filters[d] = t2; item->filters[d] = t2;
item->filters[d2] = t; item->filters[d2] = t;
} }
PluginList->SetItemState (itemIndex + 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
PluginList->SetItemState (itemIndex, 0, wxLIST_STATE_SELECTED);
} }
int fcount = item->filter_objects.Count(); int fcount = item->filter_objects.Count();
if (item->divider >= fcount) if (item->divider >= fcount)
@ -313,7 +320,8 @@ void ExtImportPrefs::SwapRows (int row1, int row2)
void ExtImportPrefs::OnRuleTableKeyDown(wxKeyEvent& event) void ExtImportPrefs::OnRuleTableKeyDown(wxKeyEvent& event)
{ {
int mods = event.GetModifiers(); int mods = event.GetModifiers();
if (mods & wxMOD_CMD && (event.GetKeyCode() == WXK_UP || event.GetKeyCode() == WXK_DOWN)) if (mods & wxMOD_CMD && (event.GetKeyCode() == WXK_UP ||
event.GetKeyCode() == WXK_DOWN))
{ {
DoOnRuleTableKeyDown (event.GetKeyCode()); DoOnRuleTableKeyDown (event.GetKeyCode());
} }
@ -385,7 +393,8 @@ void ExtImportPrefs::DoOnRuleTableSelect (int toprow)
} }
if (item->filter_objects[i] != NULL) if (item->filter_objects[i] != NULL)
{ {
PluginList->InsertItem (i + shift, item->filter_objects[i]->GetPluginFormatDescription()); PluginList->InsertItem (i + shift,
item->filter_objects[i]->GetPluginFormatDescription());
} }
else else
{ {
@ -607,7 +616,8 @@ void RuleTableDropTarget::SetPrefs (ExtImportPrefs *prefs)
mPrefs = prefs; mPrefs = prefs;
} }
wxDragResult RuleTableDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def) wxDragResult RuleTableDropTarget::OnData(wxCoord x, wxCoord y,
wxDragResult def)
{ {
return def; return def;
} }
@ -623,15 +633,18 @@ bool RuleTableDropTarget::OnDrop(wxCoord x, wxCoord y)
return true; return true;
} }
wxDragResult RuleTableDropTarget::OnEnter(wxCoord x, wxCoord y, wxDragResult def) wxDragResult RuleTableDropTarget::OnEnter(wxCoord x, wxCoord y,
wxDragResult def)
{ {
return OnDragOver(x, y, def); return OnDragOver(x, y, def);
} }
wxDragResult RuleTableDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult def) wxDragResult RuleTableDropTarget::OnDragOver(wxCoord x, wxCoord y,
wxDragResult def)
{ {
if (mPrefs == NULL) if (mPrefs == NULL)
return wxDragNone; return wxDragNone;
int row = mPrefs->RuleTable->YToRow (y - mPrefs->RuleTable->GetColLabelSize ()); int row = mPrefs->RuleTable->YToRow (y -
mPrefs->RuleTable->GetColLabelSize ());
if (row == wxNOT_FOUND) if (row == wxNOT_FOUND)
return wxDragNone; return wxDragNone;