mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-30 15:49:41 +02:00
Second big batch of Extended Import Filtering improvements
* /ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice preference enables the override (backward-compatibel behaviour), and it is now false by default * File names (and mime types) and patterns are Lower()'ed before being fed to wxMatchWild(), now matching should be case-insensitive * Now empty rule elements (empty list of extensions, empty list of mime types) will match anything (just as if they had one "*" element) * "Extended Import" preferences tab is now next to "Import/Export" tab * Preferences now use Grid class (the one used in Tag editor) instead of default wxGrid. Tabbing now works correctly. * First attempt to add Drag'n'Drop re-ordering for Rule table. Seems to be working. * Cleaned up a couple of cruft code comments. * Separate buttons (with hotkeys) for moving rules and filters up and down (ctrl+up/down still works) * Moved some code into helper funcions (can be called from both button and keyboard event handlers) * Grid is now configured in PopulateOrExchange (the same way it is in Tags.cpp) * Keep selection while moving table rows and list items * Detect trailing/leading spaces in rule condition and offer to trim them
This commit is contained in:
parent
d298bf57d9
commit
b6972df871
@ -339,6 +339,10 @@ int Importer::Import(wxString fName,
|
||||
wxString mime_type = wxT("*");
|
||||
|
||||
// First, add user-selected filter
|
||||
bool usersSelectionOverrides;
|
||||
gPrefs->Read(wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"), &usersSelectionOverrides, false);
|
||||
if (usersSelectionOverrides)
|
||||
{
|
||||
importPluginNode = mImportPluginList->GetFirst();
|
||||
while(importPluginNode)
|
||||
{
|
||||
@ -350,6 +354,7 @@ int Importer::Import(wxString fName,
|
||||
}
|
||||
importPluginNode = importPluginNode->GetNext();
|
||||
}
|
||||
}
|
||||
bool foundItem = false;
|
||||
|
||||
for (size_t i = 0; i < mExtImportItems->Count(); i++)
|
||||
@ -358,20 +363,24 @@ int Importer::Import(wxString fName,
|
||||
bool matches_ext = false, matches_mime = false;
|
||||
for (size_t j = 0; j < item->extensions.Count(); j++)
|
||||
{
|
||||
if (wxMatchWild (item->extensions[j],fName, false))
|
||||
if (wxMatchWild (item->extensions[j].Lower(),fName.Lower(), false))
|
||||
{
|
||||
matches_ext = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (item->extensions.Count() == 0)
|
||||
matches_ext = true;
|
||||
for (size_t j = 0; matches_ext && j < item->mime_types.Count(); j++)
|
||||
{
|
||||
if (wxMatchWild (item->mime_types[j],mime_type, false))
|
||||
if (wxMatchWild (item->mime_types[j].Lower(),mime_type.Lower(), false))
|
||||
{
|
||||
matches_mime = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (item->mime_types.Count() == 0)
|
||||
matches_mime = true;
|
||||
if (matches_ext && matches_mime)
|
||||
{
|
||||
for (size_t j = 0; j < item->filter_objects.Count() && (item->divider < 0 || (int) j < item->divider); j++)
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <wx/defs.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/msgdlg.h>
|
||||
#include <wx/dnd.h>
|
||||
|
||||
#include "ExtImportPrefs.h"
|
||||
#include "../Audacity.h"
|
||||
@ -31,23 +32,34 @@ enum ExtImportPrefsControls
|
||||
EIPPluginList = 20000,
|
||||
EIPRuleTable,
|
||||
EIPAddRule,
|
||||
EIPDelRule
|
||||
EIPDelRule,
|
||||
EIPMoveRuleUp,
|
||||
EIPMoveRuleDown,
|
||||
EIPMoveFilterUp,
|
||||
EIPMoveFilterDown
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(ExtImportPrefs, PrefsPanel)
|
||||
EVT_LIST_KEY_DOWN(EIPPluginList,ExtImportPrefs::OnPluginKeyDown)
|
||||
EVT_KEY_DOWN (ExtImportPrefs::OnRuleTableKeyDown)
|
||||
EVT_GRID_CELL_LEFT_CLICK (ExtImportPrefs::OnRuleTableCellClick)
|
||||
EVT_GRID_EDITOR_HIDDEN (ExtImportPrefs::OnRuleTableEdit)
|
||||
EVT_GRID_SELECT_CELL (ExtImportPrefs::OnRuleTableSelect)
|
||||
EVT_GRID_RANGE_SELECT (ExtImportPrefs::OnRuleTableSelectRange)
|
||||
EVT_BUTTON(EIPAddRule,ExtImportPrefs::OnAddRule)
|
||||
EVT_BUTTON(EIPDelRule,ExtImportPrefs::OnDelRule)
|
||||
EVT_BUTTON(EIPMoveRuleUp,ExtImportPrefs::OnRuleMoveUp)
|
||||
EVT_BUTTON(EIPMoveRuleDown,ExtImportPrefs::OnRuleMoveDown)
|
||||
EVT_BUTTON(EIPMoveFilterUp,ExtImportPrefs::OnFilterMoveUp)
|
||||
EVT_BUTTON(EIPMoveFilterDown,ExtImportPrefs::OnFilterMoveDown)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
ExtImportPrefs::ExtImportPrefs(wxWindow * parent)
|
||||
: PrefsPanel(parent, _("Extended Import"))
|
||||
: PrefsPanel(parent, _("Extended Import")), RuleTable(NULL), PluginList(NULL), last_selected (-1), mCreateTable (false)
|
||||
{
|
||||
last_selected = -1;
|
||||
dragtext = new wxTextDataObject(wxT(""));
|
||||
dragtarget = new RuleTableDropTarget(dragtext);
|
||||
dragtarget->SetPrefs (this);
|
||||
Populate();
|
||||
}
|
||||
|
||||
@ -64,6 +76,25 @@ void ExtImportPrefs::Populate()
|
||||
// initialised with values from gPrefs.
|
||||
ShuttleGui S(this, eIsCreatingFromPrefs);
|
||||
PopulateOrExchange(S);
|
||||
// ----------------------- End of main section --------------
|
||||
}
|
||||
|
||||
void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
{
|
||||
S.SetBorder(2);
|
||||
|
||||
S.TieCheckBox(_("Filter chosen in OpenFile dialog overrides any rules"), wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"), false);
|
||||
S.StartStatic(_("Rules to choose import filters"), 1);
|
||||
{
|
||||
S.SetSizerProportion(1);
|
||||
S.StartHorizontalLay (wxEXPAND, 1);
|
||||
{
|
||||
bool fillRuleTable = false;
|
||||
if (RuleTable == NULL)
|
||||
{
|
||||
RuleTable = new Grid(S.GetParent(),EIPRuleTable);
|
||||
|
||||
RuleTable->SetColLabelSize(RuleTable->GetDefaultRowSize());
|
||||
#if EXTIMPORT_MIME_SUPPORT
|
||||
RuleTable->CreateGrid (0, 2, wxGrid::wxGridSelectRows);
|
||||
#else
|
||||
@ -71,6 +102,7 @@ void ExtImportPrefs::Populate()
|
||||
#endif
|
||||
RuleTable->DisableDragColMove ();
|
||||
RuleTable->DisableDragRowSize ();
|
||||
RuleTable->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
|
||||
RuleTable->SetColLabelValue (0, _("File extensions"));
|
||||
#if EXTIMPORT_MIME_SUPPORT
|
||||
RuleTable->SetColLabelValue (1, _("Mime-types"));
|
||||
@ -79,34 +111,41 @@ void ExtImportPrefs::Populate()
|
||||
RuleTable->SetSelectionMode (wxGrid::wxGridSelectRows);
|
||||
RuleTable->AutoSizeColumns ();
|
||||
|
||||
ExtImportItems *items = wxGetApp().mImporter->GetImportItems();
|
||||
RuleTable->SetDropTarget (dragtarget);
|
||||
fillRuleTable = true;
|
||||
}
|
||||
S.AddWindow(RuleTable, wxEXPAND | wxALL);
|
||||
|
||||
for (unsigned int i = 0; i < items->Count(); i++)
|
||||
AddItemToTable (i, &(*items)[i]);
|
||||
// ----------------------- End of main section --------------
|
||||
}
|
||||
|
||||
void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
{
|
||||
S.SetBorder(2);
|
||||
|
||||
S.StartStatic(_("Rules to choose import filters"), 1);
|
||||
{
|
||||
S.SetSizerProportion(1);
|
||||
S.StartHorizontalLay (wxEXPAND, 1);
|
||||
{
|
||||
RuleTable = S.Id(EIPRuleTable).AddGrid ();
|
||||
RuleTable->SetWindowStyle (wxBORDER_SUNKEN);
|
||||
PluginList = S.Id(EIPPluginList).AddListControl ();
|
||||
PluginList->SetSingleStyle (wxLC_REPORT, true);
|
||||
PluginList->SetSingleStyle (wxLC_SINGLE_SEL, true);
|
||||
PluginList->InsertColumn (0, _("Importer order"));
|
||||
|
||||
if (fillRuleTable)
|
||||
{
|
||||
ExtImportItems *items = wxGetApp().mImporter->GetImportItems();
|
||||
for (unsigned int i = 0; i < items->Count(); i++)
|
||||
AddItemToTable (i, &(*items)[i]);
|
||||
if (items->Count() > 0)
|
||||
{
|
||||
RuleTable->SelectRow(0);
|
||||
RuleTable->SetGridCursor(0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
S.EndHorizontalLay();
|
||||
S.StartHorizontalLay (wxSHRINK, 0);
|
||||
{
|
||||
AddRule = S.Id (EIPAddRule).AddButton (_("Add new rule"));
|
||||
DelRule = S.Id (EIPDelRule).AddButton (_("Delete selected rule"));
|
||||
MoveRuleUp = S.Id (EIPMoveRuleUp).AddButton (_("Move selected rule &up"));
|
||||
MoveRuleDown = S.Id (EIPMoveRuleDown).AddButton (_("Move selected rule &down"));
|
||||
MoveFilterUp = S.Id (EIPMoveFilterUp).AddButton (_("Move selected f&ilter up"));
|
||||
MoveFilterDown = S.Id (EIPMoveFilterDown).AddButton (_("Move selected &filter down"));
|
||||
}
|
||||
S.EndHorizontalLay();
|
||||
S.StartHorizontalLay (wxSHRINK, 0);
|
||||
{
|
||||
AddRule = S.Id (EIPAddRule).AddButton (_("&Add new rule"));
|
||||
DelRule = S.Id (EIPDelRule).AddButton (_("De&lete selected rule"));
|
||||
}
|
||||
S.EndHorizontalLay();
|
||||
}
|
||||
@ -136,27 +175,32 @@ void ExtImportPrefs::OnPluginKeyDown(wxListEvent& event)
|
||||
break;
|
||||
#endif
|
||||
|
||||
int code = event.GetKeyCode();
|
||||
if (DoOnPluginKeyDown (event.GetKeyCode()))
|
||||
event.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
bool ExtImportPrefs::DoOnPluginKeyDown (int code)
|
||||
{
|
||||
if (code != WXK_UP && code != WXK_DOWN)
|
||||
break;
|
||||
return false;
|
||||
|
||||
long itemIndex = -1;
|
||||
itemIndex = PluginList->GetNextItem(itemIndex,
|
||||
wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (itemIndex == -1)
|
||||
break;
|
||||
return false;
|
||||
|
||||
if (last_selected == -1)
|
||||
break;
|
||||
return false;
|
||||
|
||||
ExtImportItems *items = wxGetApp().mImporter->GetImportItems();
|
||||
ExtImportItem *item = &(*items)[last_selected];
|
||||
|
||||
if (code == WXK_UP && itemIndex == 0)
|
||||
break;
|
||||
return false;
|
||||
else if (code == WXK_DOWN && itemIndex == PluginList->GetItemCount() - 1)
|
||||
break;
|
||||
return false;
|
||||
|
||||
wxString t, t2;
|
||||
long d, d2;
|
||||
@ -192,6 +236,8 @@ void ExtImportPrefs::OnPluginKeyDown(wxListEvent& event)
|
||||
item->filters[d] = t2;
|
||||
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)
|
||||
{
|
||||
@ -224,6 +270,8 @@ void ExtImportPrefs::OnPluginKeyDown(wxListEvent& event)
|
||||
item->filters[d] = t2;
|
||||
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();
|
||||
if (item->divider >= fcount)
|
||||
@ -232,8 +280,34 @@ void ExtImportPrefs::OnPluginKeyDown(wxListEvent& event)
|
||||
}
|
||||
if (item->divider < -1)
|
||||
item->divider = item->filter_objects.Count() - 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ExtImportPrefs::SwapRows (int row1, int row2)
|
||||
{
|
||||
int t;
|
||||
ExtImportItem *t1, *t2;
|
||||
wxString ts;
|
||||
if (row1 == row2)
|
||||
return;
|
||||
if (row1 > row2)
|
||||
{
|
||||
t = row1;
|
||||
row1 = row2;
|
||||
row2 = t;
|
||||
}
|
||||
ExtImportItems *items = wxGetApp().mImporter->GetImportItems();
|
||||
t1 = items->Detach(row1);
|
||||
t2 = items->Detach(row1);
|
||||
items->Insert (t1, row1);
|
||||
items->Insert (t2, row1);
|
||||
for (int i = 0; i < RuleTable->GetNumberCols(); i++)
|
||||
{
|
||||
ts = RuleTable->GetCellValue (row2, i);
|
||||
RuleTable->SetCellValue (row2, i, RuleTable->GetCellValue (row1, i));
|
||||
RuleTable->SetCellValue (row1, i, ts);
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void ExtImportPrefs::OnRuleTableKeyDown(wxKeyEvent& event)
|
||||
@ -241,45 +315,35 @@ void ExtImportPrefs::OnRuleTableKeyDown(wxKeyEvent& event)
|
||||
int mods = event.GetModifiers();
|
||||
if (mods & wxMOD_CMD && (event.GetKeyCode() == WXK_UP || event.GetKeyCode() == WXK_DOWN))
|
||||
{
|
||||
DoOnRuleTableKeyDown (event.GetKeyCode());
|
||||
}
|
||||
else
|
||||
{
|
||||
event.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
void ExtImportPrefs::DoOnRuleTableKeyDown (int keycode)
|
||||
{
|
||||
ExtImportItems *items = wxGetApp().mImporter->GetImportItems();
|
||||
ExtImportItem *t1, *t2;
|
||||
int selrow = RuleTable->GetGridCursorRow ();
|
||||
wxString ts;
|
||||
if (event.GetKeyCode() == WXK_UP)
|
||||
if (keycode == WXK_UP)
|
||||
{
|
||||
if (selrow == 0)
|
||||
return;
|
||||
t1 = items->Detach(selrow - 1);
|
||||
t2 = items->Detach(selrow - 1);
|
||||
items->Insert (t1, selrow - 1);
|
||||
items->Insert (t2, selrow - 1);
|
||||
for (int i = 0; i < RuleTable->GetNumberCols(); i++)
|
||||
{
|
||||
ts = RuleTable->GetCellValue (selrow, i);
|
||||
RuleTable->SetCellValue (selrow, i, RuleTable->GetCellValue (selrow - 1, i));
|
||||
RuleTable->SetCellValue (selrow - 1, i, ts);
|
||||
}
|
||||
SwapRows (selrow - 1, selrow);
|
||||
RuleTable->MoveCursorUp (false);
|
||||
RuleTable->SelectRow (selrow - 1);
|
||||
}
|
||||
else if (event.GetKeyCode() == WXK_DOWN)
|
||||
else if (keycode == WXK_DOWN)
|
||||
{
|
||||
if (selrow == RuleTable->GetNumberRows() - 1)
|
||||
return;
|
||||
t1 = items->Detach(selrow);
|
||||
t2 = items->Detach(selrow);
|
||||
items->Insert (t2, selrow);
|
||||
items->Insert (t1, selrow);
|
||||
for (int i = 0; i < RuleTable->GetNumberCols(); i++)
|
||||
{
|
||||
ts = RuleTable->GetCellValue (selrow, i);
|
||||
RuleTable->SetCellValue (selrow, i, RuleTable->GetCellValue (selrow + 1, i));
|
||||
RuleTable->SetCellValue (selrow + 1, i, ts);
|
||||
}
|
||||
SwapRows (selrow, selrow + 1);
|
||||
RuleTable->MoveCursorDown (false);
|
||||
RuleTable->SelectRow (selrow + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void ExtImportPrefs::OnRuleTableSelect (wxGridEvent& event)
|
||||
@ -334,6 +398,13 @@ void ExtImportPrefs::DoOnRuleTableSelect (int toprow)
|
||||
PluginList->InsertItem (fcount, _("Unused filters:"));
|
||||
PluginList->SetItemData (fcount, -1);
|
||||
}
|
||||
wxListItem info;
|
||||
info.SetId (0);
|
||||
info.SetColumn (0);
|
||||
info.SetStateMask (wxLIST_STATE_SELECTED);
|
||||
info.SetState (wxLIST_STATE_SELECTED);
|
||||
info.SetMask (wxLIST_MASK_STATE);
|
||||
PluginList->SetItem (info);
|
||||
PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE);
|
||||
last_selected = toprow;
|
||||
}
|
||||
@ -345,19 +416,70 @@ void ExtImportPrefs::OnRuleTableEdit (wxGridEvent& event)
|
||||
ExtImportItems *items = wxGetApp().mImporter->GetImportItems();
|
||||
ExtImportItem *item = &(*items)[row];
|
||||
RuleTable->SaveEditControlValue();
|
||||
|
||||
wxString val = RuleTable->GetCellValue (row, col);
|
||||
int fixSpaces = wxNO;
|
||||
bool askedAboutSpaces = false;
|
||||
wxArrayString vals;
|
||||
wxString delims(wxT(":"));
|
||||
wxGetApp().mImporter->StringToList (val, delims, vals);
|
||||
switch (col)
|
||||
{
|
||||
case 0:
|
||||
item->extensions.Clear();
|
||||
wxGetApp().mImporter->StringToList (val, delims, item->extensions);
|
||||
break;
|
||||
case 1:
|
||||
item->mime_types.Clear();
|
||||
wxGetApp().mImporter->StringToList (val, delims, item->mime_types);
|
||||
break;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < vals.Count(); i++)
|
||||
{
|
||||
wxString trimmed = vals[i];
|
||||
trimmed.Trim();
|
||||
trimmed.Trim(true);
|
||||
if (trimmed.Cmp(vals[i]) != 0)
|
||||
{
|
||||
if (!askedAboutSpaces)
|
||||
{
|
||||
fixSpaces = wxMessageBox(_(
|
||||
"There are space characters (spaces, newlines, tabs or linefeeds) in one of \
|
||||
the items. They are likely to break the pattern matching. Unless you know \
|
||||
what you are doing, it is recommended to trim spaces. Do you want \
|
||||
Audacity to trim spaces for you?"
|
||||
),_("Spaces detected"), wxYES_NO);
|
||||
}
|
||||
if (fixSpaces != wxYES)
|
||||
{
|
||||
trimmed = vals[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
vals[i] = trimmed;
|
||||
}
|
||||
}
|
||||
switch (col)
|
||||
{
|
||||
case 0:
|
||||
item->extensions.Add (trimmed);
|
||||
break;
|
||||
case 1:
|
||||
item->mime_types.Add (trimmed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fixSpaces == wxYES)
|
||||
{
|
||||
wxString vals_as_string;
|
||||
for (size_t i = 0; i < vals.Count(); i++)
|
||||
{
|
||||
if (i > 0)
|
||||
vals_as_string.Append (wxT(":"));
|
||||
vals_as_string.Append (vals[i]);
|
||||
}
|
||||
RuleTable->SetCellValue (row, col, vals_as_string);
|
||||
}
|
||||
|
||||
RuleTable->AutoSizeColumns ();
|
||||
}
|
||||
|
||||
@ -426,6 +548,112 @@ void ExtImportPrefs::OnDelRule(wxCommandEvent& event)
|
||||
}
|
||||
}
|
||||
|
||||
void ExtImportPrefs::OnRuleMoveUp(wxCommandEvent& event)
|
||||
{
|
||||
DoOnRuleTableKeyDown (WXK_UP);
|
||||
}
|
||||
|
||||
void ExtImportPrefs::OnRuleMoveDown(wxCommandEvent& event)
|
||||
{
|
||||
DoOnRuleTableKeyDown (WXK_DOWN);
|
||||
}
|
||||
|
||||
void ExtImportPrefs::OnFilterMoveUp(wxCommandEvent& event)
|
||||
{
|
||||
DoOnPluginKeyDown (WXK_UP);
|
||||
}
|
||||
|
||||
void ExtImportPrefs::OnFilterMoveDown(wxCommandEvent& event)
|
||||
{
|
||||
DoOnPluginKeyDown (WXK_DOWN);
|
||||
}
|
||||
|
||||
|
||||
void ExtImportPrefs::OnRuleTableCellClick (wxGridEvent& event)
|
||||
{
|
||||
int row = event.GetRow();
|
||||
if (RuleTable->GetGridCursorRow () == row)
|
||||
{
|
||||
wxDropSource dragSource(this);
|
||||
dragtext->SetText(wxT(""));
|
||||
dragSource.SetData(*dragtext);
|
||||
wxDragResult result = dragSource.DoDragDrop(TRUE);
|
||||
switch (result)
|
||||
{
|
||||
case wxDragCopy: /* copy the data */
|
||||
case wxDragMove:
|
||||
case wxDragNone:
|
||||
return;
|
||||
break;
|
||||
default: /* do nothing */ break;
|
||||
}
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
RuleTableDropTarget::RuleTableDropTarget (wxDataObject *dataObject)
|
||||
{
|
||||
SetDataObject (dataObject);
|
||||
mPrefs = NULL;
|
||||
}
|
||||
|
||||
RuleTableDropTarget::~RuleTableDropTarget ()
|
||||
{
|
||||
}
|
||||
|
||||
void RuleTableDropTarget::SetPrefs (ExtImportPrefs *prefs)
|
||||
{
|
||||
mPrefs = prefs;
|
||||
}
|
||||
|
||||
wxDragResult RuleTableDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
|
||||
bool RuleTableDropTarget::OnDrop(wxCoord x, wxCoord y)
|
||||
{
|
||||
if (mPrefs == NULL)
|
||||
return false;
|
||||
int row = mPrefs->RuleTable->YToRow (y);
|
||||
if (row == wxNOT_FOUND)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxDragResult RuleTableDropTarget::OnEnter(wxCoord x, wxCoord y, wxDragResult def)
|
||||
{
|
||||
return OnDragOver(x, y, def);
|
||||
}
|
||||
wxDragResult RuleTableDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult def)
|
||||
{
|
||||
if (mPrefs == NULL)
|
||||
return wxDragNone;
|
||||
int row = mPrefs->RuleTable->YToRow (y - mPrefs->RuleTable->GetColLabelSize ());
|
||||
if (row == wxNOT_FOUND)
|
||||
return wxDragNone;
|
||||
|
||||
int cRow = mPrefs->RuleTable->GetGridCursorRow ();
|
||||
wxRect cRect = mPrefs->RuleTable->CellToRect(cRow, 0);
|
||||
if (row != cRow)
|
||||
{
|
||||
mPrefs->SwapRows (cRow, row);
|
||||
mPrefs->RuleTable->SetGridCursor (row, 0);
|
||||
mPrefs->RuleTable->SelectRow (row);
|
||||
}
|
||||
return wxDragCopy;
|
||||
}
|
||||
|
||||
void RuleTableDropTarget::OnLeave()
|
||||
{
|
||||
}
|
||||
|
||||
void RuleTableDropTarget::SetDataObject(wxDataObject* data)
|
||||
{
|
||||
this->m_dataObject = data;
|
||||
}
|
||||
|
||||
// Indentation settings for Vim and Emacs and unique identifier for Arch, a
|
||||
// version control system. Please do not modify past this point.
|
||||
//
|
||||
|
@ -12,8 +12,9 @@
|
||||
#define __AUDACITY_EXT_IMPORT_PREFS__
|
||||
|
||||
#include <wx/defs.h>
|
||||
|
||||
#include <wx/dnd.h>
|
||||
#include <wx/window.h>
|
||||
#include "../widgets/Grid.h"
|
||||
|
||||
#include "../ShuttleGui.h"
|
||||
|
||||
@ -23,6 +24,23 @@
|
||||
#include "../import/ImportPlugin.h"
|
||||
|
||||
class wxListEvent;
|
||||
class ExtImportPrefs;
|
||||
|
||||
class RuleTableDropTarget: public wxDropTarget
|
||||
{
|
||||
public:
|
||||
RuleTableDropTarget (wxDataObject *dataObject = 0);
|
||||
~RuleTableDropTarget ();
|
||||
wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
|
||||
bool OnDrop(wxCoord x, wxCoord y);
|
||||
wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def);
|
||||
wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
||||
void OnLeave();
|
||||
void SetDataObject(wxDataObject* data);
|
||||
void SetPrefs (ExtImportPrefs *prefs);
|
||||
private:
|
||||
ExtImportPrefs *mPrefs;
|
||||
};
|
||||
|
||||
class ExtImportPrefs:public PrefsPanel
|
||||
{
|
||||
@ -36,23 +54,40 @@ class ExtImportPrefs:public PrefsPanel
|
||||
void OnRuleTableSelect(wxGridEvent& event);
|
||||
void OnRuleTableEdit(wxGridEvent& event);
|
||||
void OnRuleTableSelectRange(wxGridRangeSelectEvent& event);
|
||||
/* void OnRuleTableKeyDown(wxListEvent& event);
|
||||
void OnRuleTableFocus(wxListEvent& event);
|
||||
void OnRuleTableActivate(wxListEvent& event);
|
||||
void OnRuleTableRightClick(wxListEvent& 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);
|
||||
|
||||
Grid *RuleTable;
|
||||
|
||||
private:
|
||||
|
||||
wxGrid *RuleTable;
|
||||
wxListCtrl *PluginList;
|
||||
|
||||
wxButton *AddRule;
|
||||
wxButton *DelRule;
|
||||
wxButton *MoveRuleUp;
|
||||
wxButton *MoveRuleDown;
|
||||
wxButton *MoveFilterUp;
|
||||
wxButton *MoveFilterDown;
|
||||
|
||||
wxTextDataObject *dragtext;
|
||||
RuleTableDropTarget *dragtarget;
|
||||
|
||||
bool mCreateTable;
|
||||
|
||||
int last_selected;
|
||||
|
||||
void DoOnRuleTableKeyDown (int keycode);
|
||||
bool DoOnPluginKeyDown (int code);
|
||||
void DoOnRuleTableSelect (int toprow);
|
||||
void AddItemToTable (int index, ExtImportItem *item);
|
||||
void Populate();
|
||||
|
@ -99,6 +99,7 @@ PrefsDialog::PrefsDialog(wxWindow * parent)
|
||||
w = new GUIPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new TracksPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new ImportExportPrefs(mCategories);mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new ExtImportPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new ProjectsPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new LibraryPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new SpectrumPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
@ -113,8 +114,6 @@ PrefsDialog::PrefsDialog(wxWindow * parent)
|
||||
// w = new BatchPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new KeyConfigPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new MousePrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
|
||||
w = new ExtImportPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
}
|
||||
S.EndHorizontalLay();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user