Fix bugs when deleting or trashing samples, and added a context menu for folders.

This commit is contained in:
apoorv569 2021-06-15 00:12:39 +05:30
parent 21c06fc555
commit f4c46a6b5f
4 changed files with 390 additions and 117 deletions

View File

@ -41,12 +41,19 @@ enum ControlIDs
SD_FontBrowseButton, SD_FontBrowseButton,
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Menu items // SampleView Menu items
MN_FavoriteSample, MN_FavoriteSample,
MN_DeleteSample, MN_DeleteSample,
MN_TrashSample, MN_TrashSample,
MN_EditTagSample, MN_EditTagSample,
// -------------------------------------------------------------------
// CollectionView Menu items
MN_CreateFolder,
MN_RemoveFolder,
MN_RemoveSample,
MN_FilterSampleView,
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Edit tags dialog controls // Edit tags dialog controls
ET_TitleCheck, ET_TitleCheck,

View File

@ -1014,10 +1014,19 @@ Database::FilterDatabaseBySampleName(wxVector<wxVector<wxVariant>>& sampleVec, c
wxVector<wxVariant> vec; wxVector<wxVariant> vec;
wxVariant icon_c, icon_gs;
icon_c << wxDataViewIconText(wxEmptyString, wxIcon("../assets/icons/icon-hive_16x16.png"));
icon_gs << wxDataViewIconText(wxEmptyString, wxIcon("../assets/icons/icon-hive_16x16-gs.png"));
if (favorite == 1) if (favorite == 1)
vec.push_back(true); vec.push_back(icon_c);
else else
vec.push_back(false); vec.push_back(icon_gs);
// if (favorite == 1)
// vec.push_back(true);
// else
// vec.push_back(false);
vec.push_back(filename); vec.push_back(filename);
vec.push_back(sample_pack); vec.push_back(sample_pack);
@ -1089,10 +1098,19 @@ Database::FilterDatabaseByFolderName(wxVector<wxVector<wxVariant>>& sampleVec, c
wxVector<wxVariant> vec; wxVector<wxVariant> vec;
wxVariant icon_c, icon_gs;
icon_c << wxDataViewIconText(wxEmptyString, wxIcon("../assets/icons/icon-hive_16x16.png"));
icon_gs << wxDataViewIconText(wxEmptyString, wxIcon("../assets/icons/icon-hive_16x16-gs.png"));
if (favorite == 1) if (favorite == 1)
vec.push_back(true); vec.push_back(icon_c);
else else
vec.push_back(false); vec.push_back(icon_gs);
// if (favorite == 1)
// vec.push_back(true);
// else
// vec.push_back(false);
vec.push_back(filename); vec.push_back(filename);
vec.push_back(sample_pack); vec.push_back(sample_pack);

View File

@ -221,7 +221,7 @@ MainFrame::MainFrame()
Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, &MainFrame::OnExpandTrash, this, BC_TrashPane); Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, &MainFrame::OnExpandTrash, this, BC_TrashPane);
Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &MainFrame::OnClickSampleView, this, BC_SampleListView); Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &MainFrame::OnClickSampleView, this, BC_SampleListView);
Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &MainFrame::OnCheckFavorite, this, BC_SampleListView); // Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &MainFrame::OnCheckFavorite, this, BC_SampleListView);
Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, &MainFrame::OnDragFromSampleView, this); Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, &MainFrame::OnDragFromSampleView, this);
m_SampleListView->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(MainFrame::OnDragAndDropToSampleListView), NULL, this); m_SampleListView->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(MainFrame::OnDragAndDropToSampleListView), NULL, this);
Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &MainFrame::OnShowSampleListViewContextMenu, this, BC_SampleListView); Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &MainFrame::OnShowSampleListViewContextMenu, this, BC_SampleListView);
@ -232,6 +232,7 @@ MainFrame::MainFrame()
Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &MainFrame::OnClickCollectionView, this, BC_CollectionView); Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &MainFrame::OnClickCollectionView, this, BC_CollectionView);
m_CollectionView->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(MainFrame::OnDragAndDropToCollectionView), NULL, this); m_CollectionView->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(MainFrame::OnDragAndDropToCollectionView), NULL, this);
Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &MainFrame::OnShowCollectionViewContextMenu, this, BC_CollectionView);
Bind(wxEVT_BUTTON, &MainFrame::OnClickCollectionAdd, this, BC_CollectionViewAdd); Bind(wxEVT_BUTTON, &MainFrame::OnClickCollectionAdd, this, BC_CollectionViewAdd);
Bind(wxEVT_BUTTON, &MainFrame::OnClickCollectionRemove, this, BC_CollectionViewRemove); Bind(wxEVT_BUTTON, &MainFrame::OnClickCollectionRemove, this, BC_CollectionViewRemove);
@ -834,15 +835,36 @@ void MainFrame::OnSlideVolume(wxScrollEvent& event)
void MainFrame::OnClickSampleView(wxDataViewEvent& event) void MainFrame::OnClickSampleView(wxDataViewEvent& event)
{ {
// Settings settings(m_ConfigFilepath, m_DatabaseFilepath); Settings settings(m_ConfigFilepath, m_DatabaseFilepath);
// Database db(*m_InfoBar); Database db(*m_InfoBar);
int selected_row = m_SampleListView->ItemToRow(event.GetItem()); int selected_row = m_SampleListView->ItemToRow(event.GetItem());
if (selected_row < 0) return; if (selected_row < 0)
return;
wxString selection = m_SampleListView->GetTextValue(selected_row, 1); wxString selection = m_SampleListView->GetTextValue(selected_row, 1);
//Get Column
wxDataViewColumn* column = m_SampleListView->GetCurrentColumn();
if (!column)
return;
// else if (column->GetTitle() != "Favorite")
// return;
// wxLogDebug("Clicked On Favorite Column!");
//Get Filename
// int selected_row = m_SampleListView->ItemToRow(event.GetItem());
// if (selected_row < 0) return;
// wxString selection;
// if(settings.IsShowFileExtension())
// selection = m_SampleListView->GetTextValue(selected_row, 1).BeforeLast('.');
// else
// selection = m_SampleListView->GetTextValue(selected_row, 1);
// wxString sample_with_extension = db.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString()); // wxString sample_with_extension = db.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
// wxString sample_without_extension = db.GetSamplePathByFilename(selection.ToStdString()); // wxString sample_without_extension = db.GetSamplePathByFilename(selection.ToStdString());
@ -854,8 +876,12 @@ void MainFrame::OnClickSampleView(wxDataViewEvent& event)
// sample_with_extension : sample_without_extension; // sample_with_extension : sample_without_extension;
wxString sample_path = GetFileNamePathAndExtension(selection).Path; wxString sample_path = GetFileNamePathAndExtension(selection).Path;
// std::string filename = GetFilePathAndName(selection).Filename; std::string filename = GetFileNamePathAndExtension(selection).Filename;
// std::string extension = GetFilePathAndName(selection).Extension; std::string extension = GetFileNamePathAndExtension(selection).Extension;
if (column->GetTitle() != "Favorite")
{
wxLogDebug("Playing sample..");
m_MediaCtrl->Load(sample_path); m_MediaCtrl->Load(sample_path);
@ -865,6 +891,146 @@ void MainFrame::OnClickSampleView(wxDataViewEvent& event)
m_Timer->Start(100, wxTIMER_CONTINUOUS); m_Timer->Start(100, wxTIMER_CONTINUOUS);
} }
} }
else
{
wxLogDebug("Adding sample to favorite..");
//Get Folder Name and location
std::string folder_name = "Favourites";
wxDataViewItem folder_selection = m_CollectionView->GetSelection();
if(folder_selection.IsOk() && m_CollectionView->IsContainer(folder_selection))
folder_name = m_CollectionView->GetItemText(folder_selection).ToStdString();
//Get Root
wxDataViewItem root = wxDataViewItem(wxNullPtr);
wxDataViewItem container;
wxDataViewItem child;
if (db.GetFavoriteColumnValueByFilename(filename) == 0)
{
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_COLOURED))),
selected_row, 0);
db.UpdateFavoriteColumn(filename, 1);
db.UpdateFavoriteFolder(filename, folder_name);
for (int i = 0; i < m_CollectionView->GetChildCount(root); i++)
{
container = m_CollectionView->GetNthChild(root, i);
if (m_CollectionView->GetItemText(container).ToStdString() == folder_name)
{
m_CollectionView->AppendItem(container, selection);
break;
}
}
wxLogDebug("Adding %s to %s", filename, folder_name);
}
else
{
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_GREYSCALE))),
selected_row, 0);
db.UpdateFavoriteColumn(filename, 0);
db.UpdateFavoriteFolder(filename, "");
for (int i = 0; i < m_CollectionView->GetChildCount(root); i++)
{
container = m_CollectionView->GetNthChild(root, i);
for (int j = 0; j < m_CollectionView->GetChildCount(container); j++)
{
child = m_CollectionView->GetNthChild(container, j);
if (m_CollectionView->GetItemText(child) == filename)
{
m_CollectionView->DeleteItem(child);
break;
}
}
}
wxLogDebug("Removing %s from %s", filename, folder_name);
}
}
}
void MainFrame::OnShowCollectionViewContextMenu(wxDataViewEvent& event)
{
Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath);
Database db(*m_InfoBar);
wxDataViewItem item = event.GetItem();
wxString selection = m_CollectionView->GetItemText(item);
wxMenu menu;
menu.Append(MN_CreateFolder, "Create new folder");
menu.Append(MN_RemoveFolder, "Remove folder");
menu.Append(MN_RemoveFolder, "Remove sample");
if (!bFiltered)
menu.Append(MN_FilterSampleView, "Filter sample view");
else
menu.Append(MN_FilterSampleView, "Clear filter");
if (item.IsOk() && m_CollectionView->IsContainer(item))
{
switch (m_CollectionView->GetPopupMenuSelectionFromUser(menu, event.GetPosition()))
{
case MN_CreateFolder:
break;
case MN_RemoveFolder:
break;
case MN_RemoveSample:
break;
case MN_FilterSampleView:
{
if (!bFiltered)
{
wxDataViewItem selected = event.GetItem();
wxString folder_name = m_CollectionView->GetItemText(selected);
try
{
wxVector<wxVector<wxVariant>> dataset;
if (db.FilterDatabaseByFolderName(dataset, folder_name.ToStdString()).empty())
{
wxLogDebug("Error! Database is empty.");
}
else
{
m_SampleListView->DeleteAllItems();
std::cout << folder_name << std::endl;
for (auto data : dataset)
{
m_SampleListView->AppendItem(data);
}
}
}
catch (...)
{
std::cerr << "Error loading data." << std::endl;
}
bFiltered = true;
}
else
{
// TODO: clear the filter
bFiltered = false;
}
}
break;
default:
return;
}
}
}
void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event) void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
{ {
@ -883,6 +1049,7 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
return; return;
wxString selection; wxString selection;
if (settings.IsShowFileExtension()) if (settings.IsShowFileExtension())
selection = m_SampleListView->GetTextValue(selected_row, 1).BeforeLast('.'); selection = m_SampleListView->GetTextValue(selected_row, 1).BeforeLast('.');
else else
@ -896,6 +1063,7 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
//true = add; false = remove; //true = add; false = remove;
bool favorite_add = false; bool favorite_add = false;
if (db.GetFavoriteColumnValueByFilename(selection.ToStdString()) == 1) if (db.GetFavoriteColumnValueByFilename(selection.ToStdString()) == 1)
menu.Append(MN_FavoriteSample, "Remove from favorites"); menu.Append(MN_FavoriteSample, "Remove from favorites");
else else
@ -924,8 +1092,8 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
//Get Tree Root And Temp Items //Get Tree Root And Temp Items
wxDataViewItem root = wxDataViewItem(wxNullPtr); wxDataViewItem root = wxDataViewItem(wxNullPtr);
wxDataViewItem itm; wxDataViewItem container;
wxDataViewItem itm2; wxDataViewItem child;
//Get All Selected Samples //Get All Selected Samples
wxDataViewItemArray samples; wxDataViewItemArray samples;
@ -938,7 +1106,8 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
{ {
//Get Filename //Get Filename
selected_row = m_SampleListView->ItemToRow(samples[k]); selected_row = m_SampleListView->ItemToRow(samples[k]);
if (selected_row < 0) continue; if (selected_row < 0)
continue;
if (settings.IsShowFileExtension()) if (settings.IsShowFileExtension())
selection = m_SampleListView->GetTextValue(selected_row, 1).BeforeLast('.'); selection = m_SampleListView->GetTextValue(selected_row, 1).BeforeLast('.');
@ -967,11 +1136,11 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
for (int i = 0; i < m_CollectionView->GetChildCount(root); i++) for (int i = 0; i < m_CollectionView->GetChildCount(root); i++)
{ {
itm = m_CollectionView->GetNthChild(root,i); container = m_CollectionView->GetNthChild(root, i);
if(m_CollectionView->GetItemText(itm).ToStdString() == folder_name) if (m_CollectionView->GetItemText(container).ToStdString() == folder_name)
{ {
m_CollectionView->AppendItem(itm,selection,-1,NULL); m_CollectionView->AppendItem(container, selection);
break; break;
} }
} }
@ -988,13 +1157,15 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
for (int i = 0; i < m_CollectionView->GetChildCount(root); i++) for (int i = 0; i < m_CollectionView->GetChildCount(root); i++)
{ {
itm = m_CollectionView->GetNthChild(root,i); container = m_CollectionView->GetNthChild(root, i);
for(int j = 0; j < m_CollectionView->GetChildCount(itm); j++)
for (int j = 0; j < m_CollectionView->GetChildCount(container); j++)
{ {
itm2 = m_CollectionView->GetNthChild(itm,j); child = m_CollectionView->GetNthChild(container, j);
if(m_CollectionView->GetItemText(itm2) == selection)
if (m_CollectionView->GetItemText(child) == selection)
{ {
m_CollectionView->DeleteItem(itm2); m_CollectionView->DeleteItem(child);
break; break;
} }
} }
@ -1030,6 +1201,10 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
wxICON_QUESTION | wxSTAY_ON_TOP | wxICON_QUESTION | wxSTAY_ON_TOP |
wxCENTER); wxCENTER);
wxDataViewItem root = wxDataViewItem(wxNullPtr);
wxDataViewItem container;
wxDataViewItem child;
if (m_SampleListView->GetSelectedItemsCount() <= 1) if (m_SampleListView->GetSelectedItemsCount() <= 1)
{ {
switch (singleMsgDialog.ShowModal()) switch (singleMsgDialog.ShowModal())
@ -1037,8 +1212,25 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
case wxID_YES: case wxID_YES:
{ {
msg = wxString::Format("Selected row: %d :: Sample: %s", selected_row, filename); msg = wxString::Format("Selected row: %d :: Sample: %s", selected_row, filename);
db.RemoveSampleFromDatabase(filename); db.RemoveSampleFromDatabase(filename);
m_SampleListView->DeleteItem(selected_row); m_SampleListView->DeleteItem(selected_row);
for (int j = 0; j < m_CollectionView->GetChildCount(root); j++)
{
container = m_CollectionView->GetNthChild(root, j);
for (int k = 0; k < m_CollectionView->GetChildCount(container); k++)
{
child = m_CollectionView->GetNthChild(container, k);
if (m_CollectionView->GetItemText(child) == filename)
{
m_CollectionView->DeleteItem(child);
break;
}
}
}
} }
break; break;
case wxID_NO: case wxID_NO:
@ -1064,6 +1256,22 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
db.RemoveSampleFromDatabase(multi_selection); db.RemoveSampleFromDatabase(multi_selection);
m_SampleListView->DeleteItem(row); m_SampleListView->DeleteItem(row);
for (int j = 0; j < m_CollectionView->GetChildCount(root); j++)
{
container = m_CollectionView->GetNthChild(root, j);
for (int k = 0; k < m_CollectionView->GetChildCount(container); k++)
{
child = m_CollectionView->GetNthChild(container, k);
if (m_CollectionView->GetItemText(child) == multi_selection)
{
m_CollectionView->DeleteItem(child);
break;
}
}
}
} }
} }
break; break;
@ -1078,6 +1286,10 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
break; break;
case MN_TrashSample: case MN_TrashSample:
{ {
wxDataViewItem root = wxDataViewItem(wxNullPtr);
wxDataViewItem container;
wxDataViewItem child;
if (db.IsTrashed(selection.BeforeLast('.').ToStdString())) if (db.IsTrashed(selection.BeforeLast('.').ToStdString()))
msg = "Already trashed.."; msg = "Already trashed..";
else else
@ -1085,6 +1297,7 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
if (m_SampleListView->GetSelectedItemsCount() <= 1) if (m_SampleListView->GetSelectedItemsCount() <= 1)
{ {
msg = "Trashing.."; msg = "Trashing..";
if (db.GetFavoriteColumnValueByFilename(selection.ToStdString())) if (db.GetFavoriteColumnValueByFilename(selection.ToStdString()))
// if (m_SampleListView->GetToggleValue(selected_row, 0)) // if (m_SampleListView->GetToggleValue(selected_row, 0))
{ {
@ -1094,9 +1307,26 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
selected_row, 0); selected_row, 0);
db.UpdateFavoriteColumn(filename, 0); db.UpdateFavoriteColumn(filename, 0);
for (int j = 0; j < m_CollectionView->GetChildCount(root); j++)
{
container = m_CollectionView->GetNthChild(root, j);
for (int k = 0; k < m_CollectionView->GetChildCount(container); k++)
{
child = m_CollectionView->GetNthChild(container, k);
if (m_CollectionView->GetItemText(child) == filename)
{
m_CollectionView->DeleteItem(child);
break;
} }
}
}
}
db.UpdateTrashColumn(filename, 1); db.UpdateTrashColumn(filename, 1);
m_TrashedItems->AppendItem(trash_root_node, selection); m_TrashedItems->AppendItem(trash_root_node, filename);
m_SampleListView->DeleteItem(selected_row); m_SampleListView->DeleteItem(selected_row);
} }
else else
@ -1128,6 +1358,22 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
item_row, 0); item_row, 0);
db.UpdateFavoriteColumn(multi_selection, 0); db.UpdateFavoriteColumn(multi_selection, 0);
for (int j = 0; j < m_CollectionView->GetChildCount(root); j++)
{
container = m_CollectionView->GetNthChild(root, j);
for (int k = 0; k < m_CollectionView->GetChildCount(container); k++)
{
child = m_CollectionView->GetNthChild(container, k);
if (m_CollectionView->GetItemText(child) == multi_selection)
{
m_CollectionView->DeleteItem(child);
break;
}
}
}
} }
db.UpdateTrashColumn(multi_selection, 1); db.UpdateTrashColumn(multi_selection, 1);
@ -1198,86 +1444,86 @@ void MainFrame::LoadDatabase()
} }
} }
void MainFrame::OnCheckFavorite(wxDataViewEvent& event) // void MainFrame::OnCheckFavorite(wxDataViewEvent& event)
{ // {
Database db(*m_InfoBar); // Database db(*m_InfoBar);
Serializer serialize(m_ConfigFilepath); // Serializer serialize(m_ConfigFilepath);
Settings settings(this,m_ConfigFilepath, m_DatabaseFilepath); // Settings settings(this,m_ConfigFilepath, m_DatabaseFilepath);
//Get Column // //Get Column
wxDataViewColumn* column = m_SampleListView->GetCurrentColumn(); // wxDataViewColumn* column = m_SampleListView->GetCurrentColumn();
if(!column) return; // if(!column) return;
else if (column->GetTitle() != "Favorite") return; // else if (column->GetTitle() != "Favorite") return;
wxLogDebug("Clicked On Favorite Column!"); // wxLogDebug("Clicked On Favorite Column!");
//Get Filename // //Get Filename
int selected_row = m_SampleListView->ItemToRow(event.GetItem()); // int selected_row = m_SampleListView->ItemToRow(event.GetItem());
if (selected_row < 0) return; // if(selected_row < 0) return;
wxString selection; // wxString selection;
if(settings.IsShowFileExtension()) // if(settings.IsShowFileExtension())
selection = m_SampleListView->GetTextValue(selected_row, 1).BeforeLast('.'); // selection = m_SampleListView->GetTextValue(selected_row, 1).BeforeLast('.');
else // else
selection = m_SampleListView->GetTextValue(selected_row, 1); // selection = m_SampleListView->GetTextValue(selected_row, 1);
//Get Folder Name and location // //Get Folder Name and location
std::string folder_name = "Favourites"; // std::string folder_name = "Favourites";
wxDataViewItem folder_selection = m_CollectionView->GetSelection(); // wxDataViewItem folder_selection = m_CollectionView->GetSelection();
if(folder_selection.IsOk() && m_CollectionView->IsContainer(folder_selection)) // if(folder_selection.IsOk() && m_CollectionView->IsContainer(folder_selection))
folder_name = m_CollectionView->GetItemText(folder_selection).ToStdString(); // folder_name = m_CollectionView->GetItemText(folder_selection).ToStdString();
//Get Root // //Get Root
wxDataViewItem root = wxDataViewItem(wxNullPtr); // wxDataViewItem root = wxDataViewItem(wxNullPtr);
wxDataViewItem itm; // wxDataViewItem container;
wxDataViewItem itm2; // wxDataViewItem child;
if(db.GetFavoriteColumnValueByFilename(selection.ToStdString()) == 0) // if(db.GetFavoriteColumnValueByFilename(selection.ToStdString()) == 0)
{ // {
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_COLOURED))), // m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_COLOURED))),
selected_row, 0); // selected_row, 0);
db.UpdateFavoriteColumn(selection.ToStdString(), 1); // db.UpdateFavoriteColumn(selection.ToStdString(), 1);
db.UpdateFavoriteFolder(selection.ToStdString(), folder_name); // db.UpdateFavoriteFolder(selection.ToStdString(), folder_name);
for(int i = 0; i < m_CollectionView->GetChildCount(root); i++) // for(int i = 0; i < m_CollectionView->GetChildCount(root); i++)
{ // {
itm = m_CollectionView->GetNthChild(root,i); // container = m_CollectionView->GetNthChild(root, i);
if(m_CollectionView->GetItemText(itm).ToStdString() == folder_name) // if(m_CollectionView->GetItemText(container).ToStdString() == folder_name)
{ // {
m_CollectionView->AppendItem(itm,selection,-1,NULL); // m_CollectionView->AppendItem(container, selection);
break; // break;
} // }
} // }
wxLogDebug("Adding %s to %s", selection, folder_name); // wxLogDebug("Adding %s to %s", selection, folder_name);
} // }
else // else
{ // {
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_GREYSCALE))), // m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_GREYSCALE))),
selected_row, 0); // selected_row, 0);
db.UpdateFavoriteColumn(selection.ToStdString(), 0); // db.UpdateFavoriteColumn(selection.ToStdString(), 0);
db.UpdateFavoriteFolder(selection.ToStdString(), ""); // db.UpdateFavoriteFolder(selection.ToStdString(), "");
for(int i = 0; i < m_CollectionView->GetChildCount(root); i++) // for(int i = 0; i < m_CollectionView->GetChildCount(root); i++)
{ // {
itm = m_CollectionView->GetNthChild(root,i); // container = m_CollectionView->GetNthChild(root, i);
for(int j = 0; j < m_CollectionView->GetChildCount(itm); j++) // for(int j = 0; j < m_CollectionView->GetChildCount(container); j++)
{ // {
itm2 = m_CollectionView->GetNthChild(itm,j); // child = m_CollectionView->GetNthChild(container, j);
if(m_CollectionView->GetItemText(itm2) == selection) // if(m_CollectionView->GetItemText(child) == selection)
{ // {
m_CollectionView->DeleteItem(itm2); // m_CollectionView->DeleteItem(child);
break; // break;
} // }
} // }
} // }
wxLogDebug("Removing %s from %s", selection, folder_name); // wxLogDebug("Removing %s from %s", selection, folder_name);
} // }
} // }
void MainFrame::OnExpandTrash(wxCollapsiblePaneEvent& event) void MainFrame::OnExpandTrash(wxCollapsiblePaneEvent& event)
{ {

View File

@ -130,6 +130,7 @@ class MainFrame : public wxFrame
bool bLoop = false; bool bLoop = false;
bool bMuted = false; bool bMuted = false;
bool bStopped = false; bool bStopped = false;
bool bFiltered = false;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
const std::string m_ConfigFilepath; const std::string m_ConfigFilepath;
@ -163,6 +164,7 @@ class MainFrame : public wxFrame
void OnDragAndDropToCollectionView(wxDropFilesEvent& event); void OnDragAndDropToCollectionView(wxDropFilesEvent& event);
void OnClickCollectionAdd(wxCommandEvent& event); void OnClickCollectionAdd(wxCommandEvent& event);
void OnClickCollectionRemove(wxCommandEvent& event); void OnClickCollectionRemove(wxCommandEvent& event);
void OnShowCollectionViewContextMenu(wxDataViewEvent& event);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// SearchCtrl event handlers // SearchCtrl event handlers