More optimizations and add ability to restore trashed item.
This commit is contained in:
parent
e8f74758ff
commit
2167914464
210
src/Browser.cpp
210
src/Browser.cpp
|
|
@ -413,37 +413,42 @@ void Browser::OnDragAndDropToSampleListView(wxDropFilesEvent& event)
|
|||
wxBusyCursor busy_cursor;
|
||||
wxWindowDisabler window_disabler;
|
||||
|
||||
wxString name;
|
||||
wxArrayString files;
|
||||
wxString filepath;
|
||||
wxArrayString filepath_array;
|
||||
wxProgressDialog* progressDialog = new wxProgressDialog("Adding files..", "Adding files, please wait...",
|
||||
event.GetNumberOfFiles(), this,
|
||||
wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_CAN_ABORT |
|
||||
wxPD_AUTO_HIDE);
|
||||
|
||||
progressDialog->CenterOnParent(wxBOTH);
|
||||
|
||||
for (int i = 0; i < event.GetNumberOfFiles(); i++)
|
||||
{
|
||||
name = dropped[i];
|
||||
if (wxFileExists(name))
|
||||
filepath = dropped[i];
|
||||
|
||||
if (wxFileExists(filepath))
|
||||
{
|
||||
files.push_back(name);
|
||||
filepath_array.push_back(filepath);
|
||||
}
|
||||
else if (wxDirExists(name))
|
||||
else if (wxDirExists(filepath))
|
||||
{
|
||||
wxDir::GetAllFiles(name, &files);
|
||||
wxDir::GetAllFiles(filepath, &filepath_array);
|
||||
}
|
||||
|
||||
progressDialog->Pulse("Reading Samples",NULL);
|
||||
}
|
||||
|
||||
progressDialog->SetRange(files.size());
|
||||
for (size_t i = 0; i < files.size(); i++)
|
||||
progressDialog->SetRange(filepath_array.size());
|
||||
|
||||
for (size_t i = 0; i < filepath_array.size(); i++)
|
||||
{
|
||||
Browser::AddSamples(files[i]);
|
||||
progressDialog->Update(i, wxString::Format("Adding %s", files[i].AfterLast('/')));
|
||||
Browser::AddSamples(filepath_array[i]);
|
||||
progressDialog->Update(i, wxString::Format("Adding %s", filepath_array[i].AfterLast('/')));
|
||||
|
||||
if(progressDialog->WasCancelled())
|
||||
break;
|
||||
}
|
||||
|
||||
progressDialog->Destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -455,40 +460,42 @@ void Browser::OnAutoImportDir()
|
|||
wxBusyCursor busy_cursor;
|
||||
wxWindowDisabler window_disabler;
|
||||
|
||||
wxString dir = settings.GetImportDirPath();
|
||||
wxString name;
|
||||
wxArrayString files;
|
||||
wxString dir_path = settings.GetImportDirPath();
|
||||
wxString filepath;
|
||||
wxArrayString filepath_array;
|
||||
|
||||
size_t number_of_files = wxDir::GetAllFiles(dir, &files, wxEmptyString, wxDIR_DEFAULT);
|
||||
size_t number_of_files = wxDir::GetAllFiles(dir_path, &filepath_array, wxEmptyString, wxDIR_DEFAULT);
|
||||
|
||||
wxProgressDialog* progressDialog = new wxProgressDialog("Adding files..", "Adding files, please wait...",
|
||||
(int)number_of_files, this,
|
||||
wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_CAN_ABORT |
|
||||
wxPD_AUTO_HIDE);
|
||||
|
||||
progressDialog->CenterOnParent(wxBOTH);
|
||||
|
||||
for ( size_t i = 0; i < number_of_files; i++)
|
||||
{
|
||||
name = files[i];
|
||||
if (wxFileExists(name))
|
||||
filepath = filepath_array[i];
|
||||
|
||||
if (wxFileExists(filepath))
|
||||
{
|
||||
files.push_back(name);
|
||||
filepath_array.push_back(filepath);
|
||||
}
|
||||
else if (wxDirExists(name))
|
||||
else if (wxDirExists(filepath))
|
||||
{
|
||||
wxDir::GetAllFiles(name, &files);
|
||||
wxDir::GetAllFiles(filepath, &filepath_array);
|
||||
}
|
||||
|
||||
progressDialog->Pulse("Reading Samples",NULL);
|
||||
}
|
||||
|
||||
progressDialog->SetRange(files.size());
|
||||
progressDialog->SetRange(filepath_array.size());
|
||||
|
||||
for (size_t i = 0; i < files.size(); i++)
|
||||
for (size_t i = 0; i < filepath_array.size(); i++)
|
||||
{
|
||||
Browser::AddSamples(files[i]);
|
||||
Browser::AddSamples(filepath_array[i]);
|
||||
|
||||
progressDialog->Update(i, wxString::Format("Adding %s", files[i].AfterLast('/')));
|
||||
progressDialog->Update(i, wxString::Format("Adding %s", filepath_array[i].AfterLast('/')));
|
||||
|
||||
if(progressDialog->WasCancelled())
|
||||
break;
|
||||
|
|
@ -515,66 +522,72 @@ void LogDragResult(wxDragResult result)
|
|||
|
||||
void Browser::OnDragFromDirCtrl(wxTreeEvent& event)
|
||||
{
|
||||
wxFileDataObject data;
|
||||
data.AddFile(m_DirCtrl->GetPath(event.GetItem()));
|
||||
wxFileDataObject file_data;
|
||||
file_data.AddFile(m_DirCtrl->GetPath(event.GetItem()));
|
||||
|
||||
wxDropSource drag_source(this);
|
||||
drag_source.SetData(data);
|
||||
wxDropSource drop_source(this);
|
||||
drop_source.SetData(file_data);
|
||||
|
||||
LogDragResult(drag_source.DoDragDrop());
|
||||
LogDragResult(drop_source.DoDragDrop());
|
||||
}
|
||||
|
||||
void Browser::OnDragFromSampleView(wxDataViewEvent& event)
|
||||
{
|
||||
Settings settings(m_ConfigFilepath, m_DatabaseFilepath);
|
||||
Database db(*m_InfoBar);
|
||||
// Settings settings(m_ConfigFilepath, m_DatabaseFilepath);
|
||||
// Database db(*m_InfoBar);
|
||||
|
||||
int selected_row = m_SampleListView->ItemToRow(event.GetItem());
|
||||
|
||||
if (selected_row < 0) return;
|
||||
|
||||
wxString selection = m_SampleListView->GetTextValue(selected_row, 1);
|
||||
wxString sample_with_extension = db.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||
wxString sample_without_extension = db.GetSamplePathByFilename(selection.ToStdString());
|
||||
|
||||
std::string extension = settings.IsShowFileExtension() ?
|
||||
db.GetSampleFileExtension(selection.ToStdString()) :
|
||||
db.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||
// wxString sample_with_extension = db.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||
// wxString sample_without_extension = db.GetSamplePathByFilename(selection.ToStdString());
|
||||
|
||||
wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
||||
sample_with_extension : sample_without_extension;
|
||||
// std::string extension = settings.IsShowFileExtension() ?
|
||||
// db.GetSampleFileExtension(selection.ToStdString()) :
|
||||
// db.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||
|
||||
wxFileDataObject* data = new wxFileDataObject();
|
||||
// wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
||||
// sample_with_extension : sample_without_extension;
|
||||
|
||||
data->AddFile(sample);
|
||||
event.SetDataObject(data);
|
||||
wxString sample_path = GetFileNamePathAndExtension(selection).Path;
|
||||
|
||||
wxLogDebug("Started dragging '%s'.", sample);
|
||||
wxFileDataObject* fileData = new wxFileDataObject();
|
||||
|
||||
fileData->AddFile(sample_path);
|
||||
event.SetDataObject(fileData);
|
||||
|
||||
wxLogDebug("Started dragging '%s'.", sample_path);
|
||||
}
|
||||
|
||||
void Browser::OnClickPlay(wxCommandEvent& event)
|
||||
{
|
||||
bStopped = false;
|
||||
|
||||
Settings settings(m_ConfigFilepath, m_DatabaseFilepath);
|
||||
Database db(*m_InfoBar);
|
||||
// Settings settings(m_ConfigFilepath, m_DatabaseFilepath);
|
||||
// Database db(*m_InfoBar);
|
||||
|
||||
int selected_row = m_SampleListView->GetSelectedRow();
|
||||
|
||||
if (selected_row < 0) return;
|
||||
|
||||
wxString selection = m_SampleListView->GetTextValue(selected_row, 1);
|
||||
wxString sample_with_extension = db.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||
wxString sample_without_extension = db.GetSamplePathByFilename(selection.ToStdString());
|
||||
|
||||
std::string extension = settings.IsShowFileExtension() ?
|
||||
db.GetSampleFileExtension(selection.ToStdString()) :
|
||||
db.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||
// wxString sample_with_extension = db.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||
// wxString sample_without_extension = db.GetSamplePathByFilename(selection.ToStdString());
|
||||
|
||||
wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
||||
sample_with_extension : sample_without_extension;
|
||||
// std::string extension = settings.IsShowFileExtension() ?
|
||||
// db.GetSampleFileExtension(selection.ToStdString()) :
|
||||
// db.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||
|
||||
m_MediaCtrl->Load(sample);
|
||||
// wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
||||
// sample_with_extension : sample_without_extension;
|
||||
|
||||
wxString sample_path = GetFileNamePathAndExtension(selection).Path;
|
||||
|
||||
m_MediaCtrl->Load(sample_path);
|
||||
m_MediaCtrl->Play();
|
||||
|
||||
m_Timer->Start(100, wxTIMER_CONTINUOUS);
|
||||
|
|
@ -677,8 +690,8 @@ void Browser::OnSlideVolume(wxScrollEvent& event)
|
|||
|
||||
void Browser::OnClickSampleView(wxDataViewEvent& event)
|
||||
{
|
||||
Settings settings(m_ConfigFilepath, m_DatabaseFilepath);
|
||||
Database db(*m_InfoBar);
|
||||
// Settings settings(m_ConfigFilepath, m_DatabaseFilepath);
|
||||
// Database db(*m_InfoBar);
|
||||
|
||||
int selected_row = m_SampleListView->ItemToRow(event.GetItem());
|
||||
|
||||
|
|
@ -686,17 +699,21 @@ void Browser::OnClickSampleView(wxDataViewEvent& event)
|
|||
|
||||
wxString selection = m_SampleListView->GetTextValue(selected_row, 1);
|
||||
|
||||
wxString sample_with_extension = db.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||
wxString sample_without_extension = db.GetSamplePathByFilename(selection.ToStdString());
|
||||
// wxString sample_with_extension = db.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||
// wxString sample_without_extension = db.GetSamplePathByFilename(selection.ToStdString());
|
||||
|
||||
std::string extension = settings.IsShowFileExtension() ?
|
||||
db.GetSampleFileExtension(selection.ToStdString()) :
|
||||
db.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||
// std::string extension = settings.IsShowFileExtension() ?
|
||||
// db.GetSampleFileExtension(selection.ToStdString()) :
|
||||
// db.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||
|
||||
wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
||||
sample_with_extension : sample_without_extension;
|
||||
// wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
||||
// sample_with_extension : sample_without_extension;
|
||||
|
||||
m_MediaCtrl->Load(sample);
|
||||
wxString sample_path = GetFileNamePathAndExtension(selection).Path;
|
||||
// std::string filename = GetFilePathAndName(selection).Filename;
|
||||
// std::string extension = GetFilePathAndName(selection).Extension;
|
||||
|
||||
m_MediaCtrl->Load(sample_path);
|
||||
|
||||
if (bAutoplay)
|
||||
{
|
||||
|
|
@ -708,7 +725,7 @@ void Browser::OnClickSampleView(wxDataViewEvent& event)
|
|||
void Browser::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
|
||||
{
|
||||
TagEditor* tagEditor;
|
||||
Settings settings(m_ConfigFilepath, m_DatabaseFilepath);
|
||||
// Settings settings(m_ConfigFilepath, m_DatabaseFilepath);
|
||||
Database db(*m_InfoBar);
|
||||
|
||||
wxString msg;
|
||||
|
|
@ -723,17 +740,21 @@ void Browser::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
|
|||
|
||||
wxString selection = m_SampleListView->GetTextValue(selected_row, 1);
|
||||
|
||||
wxString sample_with_extension = db.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||
wxString sample_without_extension = db.GetSamplePathByFilename(selection.ToStdString());
|
||||
// wxString sample_with_extension = db.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||
// wxString sample_without_extension = db.GetSamplePathByFilename(selection.ToStdString());
|
||||
|
||||
std::string extension = settings.IsShowFileExtension() ?
|
||||
db.GetSampleFileExtension(selection.ToStdString()) :
|
||||
db.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||
// std::string extension = settings.IsShowFileExtension() ?
|
||||
// db.GetSampleFileExtension(selection.ToStdString()) :
|
||||
// db.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||
|
||||
wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
||||
sample_with_extension : sample_without_extension;
|
||||
// wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
||||
// sample_with_extension : sample_without_extension;
|
||||
|
||||
std::string filename = sample.AfterLast('/').BeforeLast('.').ToStdString();
|
||||
// std::string filename = sample.AfterLast('/').BeforeLast('.').ToStdString();
|
||||
|
||||
wxString sample_path = GetFileNamePathAndExtension(selection).Path;
|
||||
std::string filename = GetFileNamePathAndExtension(selection).Filename;
|
||||
std::string extension = GetFileNamePathAndExtension(selection).Extension;
|
||||
|
||||
wxMenu menu;
|
||||
|
||||
|
|
@ -798,7 +819,7 @@ void Browser::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
|
|||
"%s from database? "
|
||||
"Warning this change is "
|
||||
"permanent, and cannot be "
|
||||
"undone.", sample.AfterLast('/')),
|
||||
"undone.", sample_path.AfterLast('/')),
|
||||
wxMessageBoxCaptionStr,
|
||||
wxYES_NO | wxNO_DEFAULT |
|
||||
wxICON_QUESTION | wxSTAY_ON_TOP |
|
||||
|
|
@ -908,7 +929,7 @@ void Browser::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
|
|||
break;
|
||||
case MN_EditTagSample:
|
||||
{
|
||||
tagEditor = new TagEditor(this, (std::string&)sample, *m_InfoBar);
|
||||
tagEditor = new TagEditor(this, static_cast<std::string>(sample_path), *m_InfoBar);
|
||||
|
||||
switch (tagEditor->ShowModal())
|
||||
{
|
||||
|
|
@ -1092,7 +1113,21 @@ void Browser::OnClickCollectionRemove(wxCommandEvent& event)
|
|||
|
||||
void Browser::OnClickRestoreTrashItem(wxCommandEvent& event)
|
||||
{
|
||||
wxMessageBox("// TODO", "Trash bin", wxOK | wxCENTER, this, wxDefaultCoord, wxDefaultCoord);
|
||||
Database db(*m_InfoBar);
|
||||
|
||||
wxTreeItemId selection_id = m_TrashedItems->GetSelection();
|
||||
wxString selection = m_TrashedItems->GetItemText(selection_id);
|
||||
|
||||
wxString path = GetFileNamePathAndExtension(selection).Path;
|
||||
std::string extension = GetFileNamePathAndExtension(selection).Extension;
|
||||
std::string filename = GetFileNamePathAndExtension(selection).Filename;
|
||||
|
||||
db.UpdateTrashColumn(filename, 0);
|
||||
|
||||
RefreshDatabase();
|
||||
|
||||
// TODO: Don't let other trashed items re-added again
|
||||
m_TrashedItems->Delete(selection_id);
|
||||
}
|
||||
|
||||
void Browser::OnDoSearch(wxCommandEvent& event)
|
||||
|
|
@ -1176,4 +1211,31 @@ void Browser::RefreshDatabase()
|
|||
// m_FsWatcher->SetOwner(this);
|
||||
// }
|
||||
|
||||
FileInfo Browser::GetFileNamePathAndExtension(const wxString& selected, bool checkExtension, bool doGetFilename)
|
||||
{
|
||||
Database db(*m_InfoBar);
|
||||
Settings settings(m_ConfigFilepath, m_DatabaseFilepath);
|
||||
|
||||
wxString path;
|
||||
std::string extension, filename;
|
||||
|
||||
wxString filename_with_extension = db.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||
wxString filename_without_extension = db.GetSamplePathByFilename(selected.ToStdString());
|
||||
|
||||
if (checkExtension)
|
||||
{
|
||||
extension = settings.IsShowFileExtension() ?
|
||||
db.GetSampleFileExtension(selected.ToStdString()) :
|
||||
db.GetSampleFileExtension(selected.BeforeLast('.').ToStdString());
|
||||
}
|
||||
|
||||
path = selected.Contains(wxString::Format(".%s", extension)) ?
|
||||
filename_with_extension : filename_without_extension;
|
||||
|
||||
if (doGetFilename)
|
||||
filename = path.AfterLast('/').BeforeLast('.').ToStdString();
|
||||
|
||||
return { path, extension, filename };
|
||||
}
|
||||
|
||||
Browser::~Browser(){}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,13 @@
|
|||
#include <taglib/fileref.h>
|
||||
#include <taglib/tstring.h>
|
||||
|
||||
struct FileInfo
|
||||
{
|
||||
wxString Path;
|
||||
std::string Extension;
|
||||
std::string Filename;
|
||||
};
|
||||
|
||||
class Browser : public wxPanel
|
||||
{
|
||||
public:
|
||||
|
|
@ -178,6 +185,12 @@ class Browser : public wxPanel
|
|||
void LoadConfigFile();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Getters
|
||||
FileInfo GetFileNamePathAndExtension(const wxString& selected,
|
||||
bool checkExtension = true, bool doGetFilename = true);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Directory watchers
|
||||
bool CreateWatcherIfNecessary();
|
||||
void CreateWatcher();
|
||||
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ void Database::InsertSample(int favorite, std::string filename,
|
|||
}
|
||||
}
|
||||
|
||||
void Database::UpdateFolder(std::string folderName)
|
||||
void Database::UpdateFolder(const std::string& folderName)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -209,7 +209,7 @@ void Database::UpdateFolder(std::string folderName)
|
|||
}
|
||||
}
|
||||
|
||||
void Database::UpdateFavoriteFolderDatabase(std::string filename, std::string folderName)
|
||||
void Database::UpdateFavoriteFolderDatabase(const std::string& filename, const std::string& folderName)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -248,7 +248,7 @@ void Database::UpdateFavoriteFolderDatabase(std::string filename, std::string fo
|
|||
}
|
||||
}
|
||||
|
||||
void Database::UpdateFavoriteColumn(std::string filename, int value)
|
||||
void Database::UpdateFavoriteColumn(const std::string& filename, int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -287,7 +287,7 @@ void Database::UpdateFavoriteColumn(std::string filename, int value)
|
|||
}
|
||||
}
|
||||
|
||||
void Database::UpdateSamplePack(std::string filename, std::string samplePack)
|
||||
void Database::UpdateSamplePack(const std::string& filename, const std::string& samplePack)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -326,7 +326,7 @@ void Database::UpdateSamplePack(std::string filename, std::string samplePack)
|
|||
}
|
||||
}
|
||||
|
||||
void Database::UpdateSampleType(std::string filename, std::string type)
|
||||
void Database::UpdateSampleType(const std::string& filename, const std::string& type)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -365,7 +365,7 @@ void Database::UpdateSampleType(std::string filename, std::string type)
|
|||
}
|
||||
}
|
||||
|
||||
std::string Database::GetSampleType(std::string filename)
|
||||
std::string Database::GetSampleType(const std::string& filename)
|
||||
{
|
||||
std::string type;
|
||||
|
||||
|
|
@ -382,14 +382,15 @@ std::string Database::GetSampleType(std::string filename)
|
|||
if (sqlite3_step(m_Stmt) == SQLITE_ROW)
|
||||
{
|
||||
wxLogInfo("Record found, fetching..");
|
||||
type = std::string(reinterpret_cast< const char* >(sqlite3_column_text(m_Stmt, 0)));
|
||||
|
||||
type = std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 0)));
|
||||
}
|
||||
|
||||
rc = sqlite3_finalize(m_Stmt);
|
||||
|
||||
if (rc != SQLITE_OK)
|
||||
{
|
||||
wxMessageDialog msgDialog(NULL, "Error! Cannot get favorite column value from table.",
|
||||
wxMessageDialog msgDialog(NULL, "Error! Cannot get sample type column value from table.",
|
||||
"Error", wxOK | wxICON_ERROR);
|
||||
msgDialog.ShowModal();
|
||||
sqlite3_free(m_ErrMsg);
|
||||
|
|
@ -409,7 +410,7 @@ std::string Database::GetSampleType(std::string filename)
|
|||
return type;
|
||||
}
|
||||
|
||||
int Database::GetFavoriteColumnValueByFilename(std::string filename)
|
||||
int Database::GetFavoriteColumnValueByFilename(const std::string& filename)
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
|
|
@ -453,7 +454,7 @@ int Database::GetFavoriteColumnValueByFilename(std::string filename)
|
|||
return value;
|
||||
}
|
||||
|
||||
void Database::RemoveSampleFromDatabase(std::string filename)
|
||||
void Database::RemoveSampleFromDatabase(const std::string& filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -492,7 +493,7 @@ void Database::RemoveSampleFromDatabase(std::string filename)
|
|||
}
|
||||
}
|
||||
|
||||
std::string Database::GetSamplePathByFilename(std::string filename)
|
||||
std::string Database::GetSamplePathByFilename(const std::string& filename)
|
||||
{
|
||||
std::string path;
|
||||
|
||||
|
|
@ -509,7 +510,7 @@ std::string Database::GetSamplePathByFilename(std::string filename)
|
|||
if (sqlite3_step(m_Stmt) == SQLITE_ROW)
|
||||
{
|
||||
wxLogInfo("Record found, fetching..");
|
||||
path = std::string(reinterpret_cast< const char* >(sqlite3_column_text(m_Stmt, 0)));
|
||||
path = std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 0)));
|
||||
}
|
||||
|
||||
rc = sqlite3_finalize(m_Stmt);
|
||||
|
|
@ -536,7 +537,7 @@ std::string Database::GetSamplePathByFilename(std::string filename)
|
|||
return path;
|
||||
}
|
||||
|
||||
std::string Database::GetSampleFileExtension(std::string filename)
|
||||
std::string Database::GetSampleFileExtension(const std::string& filename)
|
||||
{
|
||||
std::string extension;
|
||||
|
||||
|
|
@ -553,7 +554,7 @@ std::string Database::GetSampleFileExtension(std::string filename)
|
|||
if (sqlite3_step(m_Stmt) == SQLITE_ROW)
|
||||
{
|
||||
wxLogInfo("Record found, fetching..");
|
||||
extension = std::string(reinterpret_cast< const char* >(sqlite3_column_text(m_Stmt, 0)));
|
||||
extension = std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 0)));
|
||||
}
|
||||
|
||||
rc = sqlite3_finalize(m_Stmt);
|
||||
|
|
@ -675,7 +676,8 @@ Database::LoadDatabase(wxVector<wxVector<wxVariant>>& vecSet,
|
|||
return vecSet;
|
||||
}
|
||||
|
||||
wxVector<wxVector<wxVariant>> Database::FilterDatabaseBySampleName(wxVector<wxVector<wxVariant>>& sampleVec, std::string sampleName)
|
||||
wxVector<wxVector<wxVariant>>
|
||||
Database::FilterDatabaseBySampleName(wxVector<wxVector<wxVariant>>& sampleVec, const std::string& sampleName)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -701,8 +703,8 @@ wxVector<wxVector<wxVariant>> Database::FilterDatabaseBySampleName(wxVector<wxVe
|
|||
{
|
||||
wxLogInfo("Record found, fetching..");
|
||||
int favorite = sqlite3_column_int(m_Stmt, 0);
|
||||
wxString filename = wxString(std::string(reinterpret_cast< const char* >(sqlite3_column_text(m_Stmt, 1))));
|
||||
wxString sample_pack = wxString(std::string(reinterpret_cast< const char* >(sqlite3_column_text(m_Stmt, 2))));
|
||||
wxString filename = wxString(std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 1))));
|
||||
wxString sample_pack = wxString(std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 2))));
|
||||
wxString sample_type = std::string(reinterpret_cast<const char *>(sqlite3_column_text(m_Stmt, 3)));
|
||||
int channels = sqlite3_column_int(m_Stmt, 4);
|
||||
int length = sqlite3_column_int(m_Stmt, 5);
|
||||
|
|
@ -749,7 +751,7 @@ wxVector<wxVector<wxVariant>> Database::FilterDatabaseBySampleName(wxVector<wxVe
|
|||
return sampleVec;
|
||||
}
|
||||
|
||||
bool Database::HasSample(std::string filename)
|
||||
bool Database::HasSample(const std::string& filename)
|
||||
{
|
||||
std::string sample;
|
||||
bool haveSample = false;
|
||||
|
|
@ -766,7 +768,7 @@ bool Database::HasSample(std::string filename)
|
|||
if (sqlite3_step(m_Stmt) == SQLITE_ROW)
|
||||
{
|
||||
wxLogInfo("Record found, fetching..");
|
||||
sample = std::string(reinterpret_cast< const char* >(sqlite3_column_text(m_Stmt, 0)));
|
||||
sample = std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 0)));
|
||||
haveSample = true;
|
||||
}
|
||||
|
||||
|
|
@ -796,7 +798,7 @@ bool Database::HasSample(std::string filename)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Database::IsTrashed(std::string filename)
|
||||
bool Database::IsTrashed(const std::string& filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -840,7 +842,7 @@ bool Database::IsTrashed(std::string filename)
|
|||
return false;
|
||||
}
|
||||
|
||||
void Database::UpdateTrashColumn(std::string filename, int value)
|
||||
void Database::UpdateTrashColumn(const std::string& filename, int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,29 +40,29 @@ class Database
|
|||
|
||||
// -------------------------------------------------------------------
|
||||
// Update database
|
||||
void UpdateFavoriteColumn(std::string filename, int value);
|
||||
void UpdateFolder(std::string folderName);
|
||||
void UpdateFavoriteFolderDatabase(std::string filename,
|
||||
std::string folderName);
|
||||
void UpdateTrashColumn(std::string filename, int value);
|
||||
void UpdateSamplePack(std::string filename, std::string samplePack);
|
||||
void UpdateSampleType(std::string filename, std::string type);
|
||||
void UpdateFavoriteColumn(const std::string& filename, int value);
|
||||
void UpdateFolder(const std::string& folderName);
|
||||
void UpdateFavoriteFolderDatabase(const std::string& filename,
|
||||
const std::string& folderName);
|
||||
void UpdateTrashColumn(const std::string& filename, int value);
|
||||
void UpdateSamplePack(const std::string& filename, const std::string& samplePack);
|
||||
void UpdateSampleType(const std::string& filename, const std::string& type);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Get from database
|
||||
std::string GetSampleType(std::string filename);
|
||||
int GetFavoriteColumnValueByFilename(std::string filename);
|
||||
std::string GetSamplePathByFilename(std::string filename);
|
||||
std::string GetSampleFileExtension(std::string filename);
|
||||
std::string GetSampleType(const std::string& filename);
|
||||
int GetFavoriteColumnValueByFilename(const std::string& filename);
|
||||
std::string GetSamplePathByFilename(const std::string& filename);
|
||||
std::string GetSampleFileExtension(const std::string& filename);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Check database
|
||||
bool HasSample(std::string filename);
|
||||
bool IsTrashed(std::string filename);
|
||||
bool HasSample(const std::string& filename);
|
||||
bool IsTrashed(const std::string& filename);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Remove from database
|
||||
void RemoveSampleFromDatabase(std::string filename);
|
||||
void RemoveSampleFromDatabase(const std::string& filename);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
wxVector<wxVector<wxVariant>>
|
||||
|
|
@ -71,5 +71,5 @@ class Database
|
|||
wxTreeCtrl& trash_tree, wxTreeItemId& trash_item, bool show_extension);
|
||||
wxVector<wxVector<wxVariant>>
|
||||
FilterDatabaseBySampleName(wxVector<wxVector<wxVariant>> &sampleVec,
|
||||
std::string sampleName);
|
||||
const std::string& sampleName);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "Database.hpp"
|
||||
#include "TagEditorDialog.hpp"
|
||||
|
||||
TagEditor::TagEditor(wxWindow* window, std::string& filename, wxInfoBar& info_bar)
|
||||
TagEditor::TagEditor(wxWindow* window, const std::string& filename, wxInfoBar& info_bar)
|
||||
: wxDialog(window, wxID_ANY, "Edit tags", wxDefaultPosition,
|
||||
wxSize(640, 360), wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP),
|
||||
m_Window(window), m_Filename(filename), m_InfoBar(info_bar), tags(filename)
|
||||
|
|
@ -217,6 +217,8 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
|||
|
||||
std::string sampleType = db.GetSampleType(m_Filename);
|
||||
|
||||
std::string filename = wxString(m_Filename).AfterLast('/').BeforeLast('.').ToStdString();
|
||||
|
||||
wxString warning_msg = "Are you sure you want save these changes?";
|
||||
wxMessageDialog* msgDialog = new wxMessageDialog(this, warning_msg,
|
||||
"Edit tags", wxCENTRE |
|
||||
|
|
@ -277,7 +279,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
|||
if (m_SampleTypeCheck->GetValue() && m_SampleTypeChoice->GetStringSelection() != sampleType)
|
||||
{
|
||||
wxLogDebug("Changing type tag..");
|
||||
db.UpdateSampleType(m_Filename, type.ToStdString());
|
||||
db.UpdateSampleType(filename, type.ToStdString());
|
||||
|
||||
info_msg = wxString::Format("Successfully changed type tag to %s", type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@
|
|||
class TagEditor : public wxDialog
|
||||
{
|
||||
public:
|
||||
TagEditor(wxWindow* window, std::string& filename, wxInfoBar& info_bar);
|
||||
TagEditor(wxWindow* window, const std::string& filename, wxInfoBar& info_bar);
|
||||
~TagEditor();
|
||||
|
||||
private:
|
||||
// -------------------------------------------------------------------
|
||||
wxWindow* m_Window;
|
||||
std::string& m_Filename;
|
||||
const std::string m_Filename;
|
||||
|
||||
wxInfoBar& m_InfoBar;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue