Added feature to rename a hive and more renaming.
This commit is contained in:
parent
09a3b03658
commit
2c88863a71
|
|
@ -50,7 +50,7 @@ enum ControlIDs
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Hives Menu items
|
// Hives Menu items
|
||||||
MN_CreateHive,
|
MN_RenameHive,
|
||||||
MN_DeleteHive,
|
MN_DeleteHive,
|
||||||
MN_RemoveSample,
|
MN_RemoveSample,
|
||||||
MN_FilterSampleView,
|
MN_FilterSampleView,
|
||||||
|
|
|
||||||
101
src/Database.cpp
101
src/Database.cpp
|
|
@ -38,7 +38,7 @@ void Database::CreateTableSamples()
|
||||||
"BITRATE INT NOT NULL,"
|
"BITRATE INT NOT NULL,"
|
||||||
"PATH TEXT NOT NULL,"
|
"PATH TEXT NOT NULL,"
|
||||||
"TRASHED INT NOT NULL,"
|
"TRASHED INT NOT NULL,"
|
||||||
"FOLDER TEXT NOT NULL);";
|
"HIVE TEXT NOT NULL);";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -82,7 +82,7 @@ void Database::CreateTableSamples()
|
||||||
void Database::CreateTableHives()
|
void Database::CreateTableHives()
|
||||||
{
|
{
|
||||||
/* Create SQL statement */
|
/* Create SQL statement */
|
||||||
std::string collections = "CREATE TABLE IF NOT EXISTS COLLECTIONS(FOLDERNAME TEXT NOT NULL);";
|
std::string hives = "CREATE TABLE IF NOT EXISTS HIVES(HIVE TEXT NOT NULL);";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -96,11 +96,11 @@ void Database::CreateTableHives()
|
||||||
wxLogDebug("Opening DB..");
|
wxLogDebug("Opening DB..");
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = sqlite3_exec(m_Database, collections.c_str(), NULL, 0, &m_ErrMsg);
|
rc = sqlite3_exec(m_Database, hives.c_str(), NULL, 0, &m_ErrMsg);
|
||||||
|
|
||||||
if (rc != SQLITE_OK)
|
if (rc != SQLITE_OK)
|
||||||
{
|
{
|
||||||
wxMessageDialog msgDialog(NULL, "Error! Cannot create table collections.",
|
wxMessageDialog msgDialog(NULL, "Error! Cannot create table hives.",
|
||||||
"Error", wxOK | wxICON_ERROR);
|
"Error", wxOK | wxICON_ERROR);
|
||||||
msgDialog.ShowModal();
|
msgDialog.ShowModal();
|
||||||
sqlite3_free(m_ErrMsg);
|
sqlite3_free(m_ErrMsg);
|
||||||
|
|
@ -140,7 +140,7 @@ void Database::InsertIntoSamples(std::vector<Sample> samples)
|
||||||
|
|
||||||
std::string insert = "INSERT INTO SAMPLES (FAVORITE, FILENAME, \
|
std::string insert = "INSERT INTO SAMPLES (FAVORITE, FILENAME, \
|
||||||
EXTENSION, SAMPLEPACK, TYPE, CHANNELS, LENGTH, \
|
EXTENSION, SAMPLEPACK, TYPE, CHANNELS, LENGTH, \
|
||||||
SAMPLERATE, BITRATE, PATH, TRASHED, FOLDER) \
|
SAMPLERATE, BITRATE, PATH, TRASHED, HIVE) \
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||||
|
|
||||||
rc = sqlite3_prepare_v2(m_Database, insert.c_str(), insert.size(), &m_Stmt, NULL);
|
rc = sqlite3_prepare_v2(m_Database, insert.c_str(), insert.size(), &m_Stmt, NULL);
|
||||||
|
|
@ -168,7 +168,7 @@ void Database::InsertIntoSamples(std::vector<Sample> samples)
|
||||||
type = sample.GetType();
|
type = sample.GetType();
|
||||||
path = sample.GetPath();
|
path = sample.GetPath();
|
||||||
|
|
||||||
std::string folder = "Favourites";
|
std::string hive = "Favorites";
|
||||||
|
|
||||||
rc = sqlite3_bind_int(m_Stmt, 1, sample.GetFavorite());
|
rc = sqlite3_bind_int(m_Stmt, 1, sample.GetFavorite());
|
||||||
rc = sqlite3_bind_text(m_Stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC);
|
rc = sqlite3_bind_text(m_Stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC);
|
||||||
|
|
@ -181,7 +181,7 @@ void Database::InsertIntoSamples(std::vector<Sample> samples)
|
||||||
rc = sqlite3_bind_int(m_Stmt, 9, sample.GetBitrate());
|
rc = sqlite3_bind_int(m_Stmt, 9, sample.GetBitrate());
|
||||||
rc = sqlite3_bind_text(m_Stmt, 10, path.c_str(), path.size(), SQLITE_STATIC);
|
rc = sqlite3_bind_text(m_Stmt, 10, path.c_str(), path.size(), SQLITE_STATIC);
|
||||||
rc = sqlite3_bind_int(m_Stmt, 11, sample.GetTrashed());
|
rc = sqlite3_bind_int(m_Stmt, 11, sample.GetTrashed());
|
||||||
rc = sqlite3_bind_text(m_Stmt, 12, folder.c_str(), folder.size(), SQLITE_STATIC);
|
rc = sqlite3_bind_text(m_Stmt, 12, hive.c_str(), hive.size(), SQLITE_STATIC);
|
||||||
|
|
||||||
rc = sqlite3_step(m_Stmt);
|
rc = sqlite3_step(m_Stmt);
|
||||||
rc = sqlite3_clear_bindings(m_Stmt);
|
rc = sqlite3_clear_bindings(m_Stmt);
|
||||||
|
|
@ -235,7 +235,7 @@ void Database::InsertIntoSamples(std::vector<Sample> samples)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::InsertIntoHives(const std::string& folderName)
|
void Database::InsertIntoHives(const std::string& hiveName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -249,7 +249,7 @@ void Database::InsertIntoHives(const std::string& folderName)
|
||||||
wxLogDebug("Opening DB..");
|
wxLogDebug("Opening DB..");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string insert = "INSERT INTO COLLECTIONS(FOLDERNAME) VALUES(?);";
|
std::string insert = "INSERT INTO HIVES(HIVE) VALUES(?);";
|
||||||
|
|
||||||
rc = sqlite3_prepare_v2(m_Database, insert.c_str(), insert.size(), &m_Stmt, NULL);
|
rc = sqlite3_prepare_v2(m_Database, insert.c_str(), insert.size(), &m_Stmt, NULL);
|
||||||
|
|
||||||
|
|
@ -276,10 +276,10 @@ void Database::InsertIntoHives(const std::string& folderName)
|
||||||
// type = sample.GetType();
|
// type = sample.GetType();
|
||||||
// path = sample.GetPath();
|
// path = sample.GetPath();
|
||||||
|
|
||||||
// std::string folder = "Favourites";
|
// std::string hive = "Favourites";
|
||||||
|
|
||||||
// rc = sqlite3_bind_int(m_Stmt, 1, sample.GetFavorite());
|
// rc = sqlite3_bind_int(m_Stmt, 1, sample.GetFavorite());
|
||||||
rc = sqlite3_bind_text(m_Stmt, 1, folderName.c_str(), folderName.size(), SQLITE_STATIC);
|
rc = sqlite3_bind_text(m_Stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC);
|
||||||
|
|
||||||
rc = sqlite3_step(m_Stmt);
|
rc = sqlite3_step(m_Stmt);
|
||||||
// rc = sqlite3_clear_bindings(m_Stmt);
|
// rc = sqlite3_clear_bindings(m_Stmt);
|
||||||
|
|
@ -333,17 +333,18 @@ void Database::InsertIntoHives(const std::string& folderName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::UpdateFolder(const std::string& folderName)
|
void Database::UpdateHive(const std::string& hiveOldName, const std::string& hiveNewName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rc = sqlite3_open("sample.hive", &m_Database);
|
rc = sqlite3_open("sample.hive", &m_Database);
|
||||||
|
|
||||||
std::string update = "UPDATE SAMPLES SET FOLDER = ?;";
|
std::string update = "UPDATE HIVES SET HIVE = ? WHERE HIVE = ?;";
|
||||||
|
|
||||||
rc = sqlite3_prepare_v2(m_Database, update.c_str(), update.size(), &m_Stmt, NULL);
|
rc = sqlite3_prepare_v2(m_Database, update.c_str(), update.size(), &m_Stmt, NULL);
|
||||||
|
|
||||||
rc = sqlite3_bind_text(m_Stmt, 1, folderName.c_str(), folderName.size(), SQLITE_STATIC);
|
rc = sqlite3_bind_text(m_Stmt, 1, hiveNewName.c_str(), hiveNewName.size(), SQLITE_STATIC);
|
||||||
|
rc = sqlite3_bind_text(m_Stmt, 2, hiveOldName.c_str(), hiveOldName.size(), SQLITE_STATIC);
|
||||||
|
|
||||||
if (sqlite3_step(m_Stmt) != SQLITE_DONE)
|
if (sqlite3_step(m_Stmt) != SQLITE_DONE)
|
||||||
{
|
{
|
||||||
|
|
@ -355,14 +356,14 @@ void Database::UpdateFolder(const std::string& folderName)
|
||||||
if (rc != SQLITE_OK)
|
if (rc != SQLITE_OK)
|
||||||
{
|
{
|
||||||
wxMessageDialog msgDialog(NULL,
|
wxMessageDialog msgDialog(NULL,
|
||||||
"Error! Cannot insert folder into table.",
|
"Error! Cannot update hive name.",
|
||||||
"Error", wxOK | wxICON_ERROR);
|
"Error", wxOK | wxICON_ERROR);
|
||||||
msgDialog.ShowModal();
|
msgDialog.ShowModal();
|
||||||
sqlite3_free(m_ErrMsg);
|
sqlite3_free(m_ErrMsg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxLogInfo("Folder inserted successfully. %s", m_ErrMsg);
|
wxLogInfo("Hive updated successfully. %s", m_ErrMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_close(m_Database);
|
sqlite3_close(m_Database);
|
||||||
|
|
@ -373,17 +374,17 @@ void Database::UpdateFolder(const std::string& folderName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::UpdateHiveName(const std::string& filename, const std::string& folderName)
|
void Database::UpdateHiveName(const std::string& filename, const std::string& hiveName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rc = sqlite3_open("sample.hive", &m_Database);
|
rc = sqlite3_open("sample.hive", &m_Database);
|
||||||
|
|
||||||
std::string update = "UPDATE SAMPLES SET FOLDER = ? WHERE FILENAME = ?;";
|
std::string update = "UPDATE SAMPLES SET HIVE = ? WHERE FILENAME = ?;";
|
||||||
|
|
||||||
rc = sqlite3_prepare_v2(m_Database, update.c_str(), update.size(), &m_Stmt, NULL);
|
rc = sqlite3_prepare_v2(m_Database, update.c_str(), update.size(), &m_Stmt, NULL);
|
||||||
|
|
||||||
rc = sqlite3_bind_text(m_Stmt, 1, folderName.c_str(), folderName.size(), SQLITE_STATIC);
|
rc = sqlite3_bind_text(m_Stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC);
|
||||||
rc = sqlite3_bind_text(m_Stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC);
|
rc = sqlite3_bind_text(m_Stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC);
|
||||||
|
|
||||||
if (sqlite3_step(m_Stmt) == SQLITE_ROW)
|
if (sqlite3_step(m_Stmt) == SQLITE_ROW)
|
||||||
|
|
@ -620,13 +621,13 @@ int Database::GetFavoriteColumnValueByFilename(const std::string& filename)
|
||||||
|
|
||||||
std::string Database::GetHiveByFilename(const std::string& filename)
|
std::string Database::GetHiveByFilename(const std::string& filename)
|
||||||
{
|
{
|
||||||
std::string folder;
|
std::string hive;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rc = sqlite3_open("sample.hive", &m_Database);
|
rc = sqlite3_open("sample.hive", &m_Database);
|
||||||
|
|
||||||
std::string select = "SELECT FOLDER FROM SAMPLES WHERE FILENAME = ?;";
|
std::string select = "SELECT HIVE FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
rc = sqlite3_prepare_v2(m_Database, select.c_str(), select.size(), &m_Stmt, NULL);
|
rc = sqlite3_prepare_v2(m_Database, select.c_str(), select.size(), &m_Stmt, NULL);
|
||||||
|
|
||||||
|
|
@ -636,14 +637,14 @@ std::string Database::GetHiveByFilename(const std::string& filename)
|
||||||
{
|
{
|
||||||
wxLogInfo("Record found, fetching..");
|
wxLogInfo("Record found, fetching..");
|
||||||
|
|
||||||
folder = std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 0)));
|
hive = std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = sqlite3_finalize(m_Stmt);
|
rc = sqlite3_finalize(m_Stmt);
|
||||||
|
|
||||||
if (rc != SQLITE_OK)
|
if (rc != SQLITE_OK)
|
||||||
{
|
{
|
||||||
wxMessageDialog msgDialog(NULL, "Error! Cannot get favorite folder value from table.",
|
wxMessageDialog msgDialog(NULL, "Error! Cannot get hive value from table.",
|
||||||
"Error", wxOK | wxICON_ERROR);
|
"Error", wxOK | wxICON_ERROR);
|
||||||
msgDialog.ShowModal();
|
msgDialog.ShowModal();
|
||||||
sqlite3_free(m_ErrMsg);
|
sqlite3_free(m_ErrMsg);
|
||||||
|
|
@ -660,7 +661,7 @@ std::string Database::GetHiveByFilename(const std::string& filename)
|
||||||
wxLogDebug(exception.what());
|
wxLogDebug(exception.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
return folder;
|
return hive;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::RemoveSampleFromDatabase(const std::string& filename)
|
void Database::RemoveSampleFromDatabase(const std::string& filename)
|
||||||
|
|
@ -702,17 +703,17 @@ void Database::RemoveSampleFromDatabase(const std::string& filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::RemoveHiveFromDatabase(const std::string& folderName)
|
void Database::RemoveHiveFromDatabase(const std::string& hiveName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rc = sqlite3_open("sample.hive", &m_Database);
|
rc = sqlite3_open("sample.hive", &m_Database);
|
||||||
|
|
||||||
std::string remove = "DELETE FROM COLLECTIONS WHERE FOLDERNAME = ?;";
|
std::string remove = "DELETE FROM HIVES WHERE HIVE = ?;";
|
||||||
|
|
||||||
rc = sqlite3_prepare_v2(m_Database, remove.c_str(), remove.size(), &m_Stmt, NULL);
|
rc = sqlite3_prepare_v2(m_Database, remove.c_str(), remove.size(), &m_Stmt, NULL);
|
||||||
|
|
||||||
rc = sqlite3_bind_text(m_Stmt, 1, folderName.c_str(), folderName.size(), SQLITE_STATIC);
|
rc = sqlite3_bind_text(m_Stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC);
|
||||||
|
|
||||||
if (sqlite3_step(m_Stmt) == SQLITE_DONE)
|
if (sqlite3_step(m_Stmt) == SQLITE_DONE)
|
||||||
{
|
{
|
||||||
|
|
@ -846,7 +847,7 @@ Database::LoadSamplesDatabase(wxVector<wxVector<wxVariant>>& vecSet,
|
||||||
|
|
||||||
std::string load = "SELECT FAVORITE, FILENAME, EXTENSION, SAMPLEPACK, \
|
std::string load = "SELECT FAVORITE, FILENAME, EXTENSION, SAMPLEPACK, \
|
||||||
TYPE, CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH, \
|
TYPE, CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH, \
|
||||||
TRASHED, FOLDER FROM SAMPLES;";
|
TRASHED, HIVE FROM SAMPLES;";
|
||||||
|
|
||||||
rc = sqlite3_prepare_v2(m_Database, load.c_str(), load.size(), &m_Stmt, NULL);
|
rc = sqlite3_prepare_v2(m_Database, load.c_str(), load.size(), &m_Stmt, NULL);
|
||||||
|
|
||||||
|
|
@ -867,7 +868,7 @@ Database::LoadSamplesDatabase(wxVector<wxVector<wxVariant>>& vecSet,
|
||||||
int bitrate = sqlite3_column_int(m_Stmt, 8);
|
int bitrate = sqlite3_column_int(m_Stmt, 8);
|
||||||
wxString path = std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 9)));
|
wxString path = std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 9)));
|
||||||
int trashed = sqlite3_column_int(m_Stmt, 10);
|
int trashed = sqlite3_column_int(m_Stmt, 10);
|
||||||
wxString folder_name = std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 11)));
|
wxString hive_name = std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 11)));
|
||||||
|
|
||||||
wxVector<wxVariant> vec;
|
wxVector<wxVariant> vec;
|
||||||
|
|
||||||
|
|
@ -881,15 +882,15 @@ Database::LoadSamplesDatabase(wxVector<wxVector<wxVariant>>& vecSet,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxVariant icon_c, icon_gs;
|
wxVariant icon_c, icon_gs;
|
||||||
icon_c << wxDataViewIconText(wxEmptyString, wxIcon("../assets/icons/icon-hive_16x16.png"));
|
icon_c = wxVariant(wxBitmap("../assets/icons/icon-hive_16x16.png"));
|
||||||
icon_gs << wxDataViewIconText(wxEmptyString, wxIcon("../assets/icons/icon-hive_16x16-gs.png"));
|
icon_gs = wxVariant(wxBitmap("../assets/icons/icon-hive_16x16-gs.png"));
|
||||||
|
|
||||||
if (favorite == 1)
|
if (favorite == 1)
|
||||||
{
|
{
|
||||||
// vec.push_back(true);
|
// vec.push_back(true);
|
||||||
vec.push_back(icon_c);
|
vec.push_back(icon_c);
|
||||||
|
|
||||||
wxLogDebug("Loading collection items..");
|
wxLogDebug("Loading hives..");
|
||||||
|
|
||||||
std::deque<wxDataViewItem> nodes;
|
std::deque<wxDataViewItem> nodes;
|
||||||
nodes.push_back(favorite_tree.GetNthChild(wxDataViewItem(wxNullPtr), 0));
|
nodes.push_back(favorite_tree.GetNthChild(wxDataViewItem(wxNullPtr), 0));
|
||||||
|
|
@ -897,23 +898,23 @@ Database::LoadSamplesDatabase(wxVector<wxVector<wxVariant>>& vecSet,
|
||||||
wxDataViewItem current_item, found_item;
|
wxDataViewItem current_item, found_item;
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
int folder_count = favorite_tree.GetChildCount(wxDataViewItem(wxNullPtr));
|
int hive_count = favorite_tree.GetChildCount(wxDataViewItem(wxNullPtr));
|
||||||
|
|
||||||
while(!nodes.empty())
|
while(!nodes.empty())
|
||||||
{
|
{
|
||||||
current_item = nodes.front();
|
current_item = nodes.front();
|
||||||
nodes.pop_front();
|
nodes.pop_front();
|
||||||
|
|
||||||
if (favorite_tree.GetItemText(current_item) == folder_name)
|
if (favorite_tree.GetItemText(current_item) == hive_name)
|
||||||
{
|
{
|
||||||
found_item = current_item;
|
found_item = current_item;
|
||||||
wxLogDebug("Loading, folder name: %s", folder_name);
|
wxLogDebug("Loading, hive name: %s", hive_name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewItem child = favorite_tree.GetNthChild(wxDataViewItem(wxNullPtr), 0);
|
wxDataViewItem child = favorite_tree.GetNthChild(wxDataViewItem(wxNullPtr), 0);
|
||||||
|
|
||||||
while (row < (folder_count - 1))
|
while (row < (hive_count - 1))
|
||||||
{
|
{
|
||||||
row ++;
|
row ++;
|
||||||
|
|
||||||
|
|
@ -926,8 +927,8 @@ Database::LoadSamplesDatabase(wxVector<wxVector<wxVariant>>& vecSet,
|
||||||
|
|
||||||
if (found_item.IsOk())
|
if (found_item.IsOk())
|
||||||
{
|
{
|
||||||
// wxLogDebug("Another folder by the name %s already exist. Please try with a different name.",
|
// wxLogDebug("Another hive by the name %s already exist. Please try with a different name.",
|
||||||
// folder_name);
|
// hive_name);
|
||||||
if (show_extension)
|
if (show_extension)
|
||||||
favorite_tree.AppendItem(found_item,
|
favorite_tree.AppendItem(found_item,
|
||||||
wxString::Format("%s.%s", filename, file_extension));
|
wxString::Format("%s.%s", filename, file_extension));
|
||||||
|
|
@ -936,7 +937,7 @@ Database::LoadSamplesDatabase(wxVector<wxVector<wxVariant>>& vecSet,
|
||||||
}
|
}
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// favorite_tree.AppendItem(wxDataViewItem(wxNullPtr), folder_name);
|
// favorite_tree.AppendItem(wxDataViewItem(wxNullPtr), hive_name);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1026,8 +1027,8 @@ Database::FilterDatabaseBySampleName(wxVector<wxVector<wxVariant>>& sampleVec,
|
||||||
wxVector<wxVariant> vec;
|
wxVector<wxVariant> vec;
|
||||||
|
|
||||||
wxVariant icon_c, icon_gs;
|
wxVariant icon_c, icon_gs;
|
||||||
icon_c << wxDataViewIconText(wxEmptyString, wxIcon("../assets/icons/icon-hive_16x16.png"));
|
icon_c = wxVariant(wxBitmap("../assets/icons/icon-hive_16x16.png"));
|
||||||
icon_gs << wxDataViewIconText(wxEmptyString, wxIcon("../assets/icons/icon-hive_16x16-gs.png"));
|
icon_gs = wxVariant(wxBitmap("../assets/icons/icon-hive_16x16-gs.png"));
|
||||||
|
|
||||||
if (favorite == 1)
|
if (favorite == 1)
|
||||||
vec.push_back(icon_c);
|
vec.push_back(icon_c);
|
||||||
|
|
@ -1084,7 +1085,7 @@ Database::FilterDatabaseBySampleName(wxVector<wxVector<wxVariant>>& sampleVec,
|
||||||
|
|
||||||
wxVector<wxVector<wxVariant>>
|
wxVector<wxVector<wxVariant>>
|
||||||
Database::FilterDatabaseByHiveName(wxVector<wxVector<wxVariant>>& sampleVec,
|
Database::FilterDatabaseByHiveName(wxVector<wxVector<wxVariant>>& sampleVec,
|
||||||
const std::string& folderName, bool show_extension)
|
const std::string& hiveName, bool show_extension)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -1096,11 +1097,11 @@ Database::FilterDatabaseByHiveName(wxVector<wxVector<wxVariant>>& sampleVec,
|
||||||
|
|
||||||
std::string filter = "SELECT FAVORITE, FILENAME, SAMPLEPACK, TYPE, \
|
std::string filter = "SELECT FAVORITE, FILENAME, SAMPLEPACK, TYPE, \
|
||||||
CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \
|
CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \
|
||||||
FROM SAMPLES WHERE FOLDER = ? AND FAVORITE = 1;";
|
FROM SAMPLES WHERE HIVE = ? AND FAVORITE = 1;";
|
||||||
|
|
||||||
rc = sqlite3_prepare_v2(m_Database, filter.c_str(), filter.size(), &m_Stmt, NULL);
|
rc = sqlite3_prepare_v2(m_Database, filter.c_str(), filter.size(), &m_Stmt, NULL);
|
||||||
|
|
||||||
rc = sqlite3_bind_text(m_Stmt, 1, folderName.c_str(), folderName.size(), SQLITE_STATIC);
|
rc = sqlite3_bind_text(m_Stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC);
|
||||||
|
|
||||||
if (rc == SQLITE_OK)
|
if (rc == SQLITE_OK)
|
||||||
{
|
{
|
||||||
|
|
@ -1122,8 +1123,8 @@ Database::FilterDatabaseByHiveName(wxVector<wxVector<wxVariant>>& sampleVec,
|
||||||
wxVector<wxVariant> vec;
|
wxVector<wxVariant> vec;
|
||||||
|
|
||||||
wxVariant icon_c, icon_gs;
|
wxVariant icon_c, icon_gs;
|
||||||
icon_c << wxDataViewIconText(wxEmptyString, wxIcon("../assets/icons/icon-hive_16x16.png"));
|
icon_c = wxVariant(wxBitmap("../assets/icons/icon-hive_16x16.png"));
|
||||||
icon_gs << wxDataViewIconText(wxEmptyString, wxIcon("../assets/icons/icon-hive_16x16-gs.png"));
|
icon_gs = wxVariant(wxBitmap("../assets/icons/icon-hive_16x16-gs.png"));
|
||||||
|
|
||||||
if (favorite == 1)
|
if (favorite == 1)
|
||||||
vec.push_back(icon_c);
|
vec.push_back(icon_c);
|
||||||
|
|
@ -1188,7 +1189,7 @@ void Database::LoadHivesDatabase(wxDataViewTreeCtrl& treeCtrl)
|
||||||
throw sqlite3_errmsg(m_Database);
|
throw sqlite3_errmsg(m_Database);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string select = "SELECT FOLDERNAME FROM COLLECTIONS;";
|
std::string select = "SELECT HIVE FROM HIVES;";
|
||||||
|
|
||||||
rc = sqlite3_prepare_v2(m_Database, select.c_str(), select.size(), &m_Stmt, NULL);
|
rc = sqlite3_prepare_v2(m_Database, select.c_str(), select.size(), &m_Stmt, NULL);
|
||||||
|
|
||||||
|
|
@ -1197,14 +1198,14 @@ void Database::LoadHivesDatabase(wxDataViewTreeCtrl& treeCtrl)
|
||||||
while (SQLITE_ROW == sqlite3_step(m_Stmt))
|
while (SQLITE_ROW == sqlite3_step(m_Stmt))
|
||||||
{
|
{
|
||||||
wxLogInfo("Record found, fetching..");
|
wxLogInfo("Record found, fetching..");
|
||||||
wxString folder = wxString(std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 0))));
|
wxString hive = wxString(std::string(reinterpret_cast<const char*>(sqlite3_column_text(m_Stmt, 0))));
|
||||||
|
|
||||||
treeCtrl.AppendContainer(wxDataViewItem(wxNullPtr), folder);
|
treeCtrl.AppendContainer(wxDataViewItem(wxNullPtr), hive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxMessageDialog msgDialog(NULL, "Error! Cannot load foldername from collection table.",
|
wxMessageDialog msgDialog(NULL, "Error! Cannot load hive from hives table.",
|
||||||
"Error", wxOK | wxICON_ERROR);
|
"Error", wxOK | wxICON_ERROR);
|
||||||
msgDialog.ShowModal();
|
msgDialog.ShowModal();
|
||||||
sqlite3_free(m_ErrMsg);
|
sqlite3_free(m_ErrMsg);
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,13 @@ class Database
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Insert into database
|
// Insert into database
|
||||||
void InsertIntoSamples(std::vector<Sample>);
|
void InsertIntoSamples(std::vector<Sample>);
|
||||||
void InsertIntoHives(const std::string& folderName);
|
void InsertIntoHives(const std::string& hiveName);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Update database
|
// Update database
|
||||||
void UpdateFavoriteColumn(const std::string& filename, int value);
|
void UpdateFavoriteColumn(const std::string& filename, int value);
|
||||||
void UpdateFolder(const std::string& folderName);
|
void UpdateHive(const std::string& hiveOldName, const std::string& hiveNewName);
|
||||||
void UpdateHiveName(const std::string& filename,
|
void UpdateHiveName(const std::string& filename, const std::string& hiveName);
|
||||||
const std::string& folderName);
|
|
||||||
void UpdateTrashColumn(const std::string& filename, int value);
|
void UpdateTrashColumn(const std::string& filename, int value);
|
||||||
void UpdateSamplePack(const std::string& filename, const std::string& samplePack);
|
void UpdateSamplePack(const std::string& filename, const std::string& samplePack);
|
||||||
void UpdateSampleType(const std::string& filename, const std::string& type);
|
void UpdateSampleType(const std::string& filename, const std::string& type);
|
||||||
|
|
@ -66,7 +65,7 @@ class Database
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Remove from database
|
// Remove from database
|
||||||
void RemoveSampleFromDatabase(const std::string& filename);
|
void RemoveSampleFromDatabase(const std::string& filename);
|
||||||
void RemoveHiveFromDatabase(const std::string& folderName);
|
void RemoveHiveFromDatabase(const std::string& hiveName);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
wxVector<wxVector<wxVariant>>
|
wxVector<wxVector<wxVariant>>
|
||||||
|
|
@ -82,5 +81,5 @@ class Database
|
||||||
const std::string& sampleName, bool show_extension);
|
const std::string& sampleName, bool show_extension);
|
||||||
wxVector<wxVector<wxVariant>>
|
wxVector<wxVector<wxVariant>>
|
||||||
FilterDatabaseByHiveName(wxVector<wxVector<wxVariant>>& sampleVec,
|
FilterDatabaseByHiveName(wxVector<wxVector<wxVariant>>& sampleVec,
|
||||||
const std::string& folderName, bool show_extension);
|
const std::string& hiveName, bool show_extension);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ MainFrame::MainFrame()
|
||||||
|
|
||||||
// Initializing wxTreeCtrl as another page of wxNotebook
|
// Initializing wxTreeCtrl as another page of wxNotebook
|
||||||
m_Hives = new wxDataViewTreeCtrl(m_HivesPanel, BC_Hives, wxDefaultPosition, wxDefaultSize,
|
m_Hives = new wxDataViewTreeCtrl(m_HivesPanel, BC_Hives, wxDefaultPosition, wxDefaultSize,
|
||||||
wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT);
|
wxDV_NO_HEADER | wxDV_SINGLE);
|
||||||
|
|
||||||
m_Hives->DragAcceptFiles(true);
|
m_Hives->DragAcceptFiles(true);
|
||||||
|
|
||||||
|
|
@ -129,7 +129,7 @@ MainFrame::MainFrame()
|
||||||
m_RestoreTrashedItemButton = new wxButton(m_TrashPaneWindow, BC_RestoreTrashedItemButton, "Restore item");
|
m_RestoreTrashedItemButton = new wxButton(m_TrashPaneWindow, BC_RestoreTrashedItemButton, "Restore item");
|
||||||
|
|
||||||
// Adding default hive
|
// Adding default hive
|
||||||
favorites_hive = m_Hives->AppendContainer(wxDataViewItem(wxNullPtr), "Favourites");
|
favorites_hive = m_Hives->AppendContainer(wxDataViewItem(wxNullPtr), "Favorites");
|
||||||
|
|
||||||
// Addubg root to TrashedItems
|
// Addubg root to TrashedItems
|
||||||
trash_root_node = m_TrashedItems->AddRoot("ROOT");
|
trash_root_node = m_TrashedItems->AddRoot("ROOT");
|
||||||
|
|
@ -179,7 +179,7 @@ MainFrame::MainFrame()
|
||||||
wxDV_MULTIPLE | wxDV_HORIZ_RULES | wxDV_VERT_RULES);
|
wxDV_MULTIPLE | wxDV_HORIZ_RULES | wxDV_VERT_RULES);
|
||||||
|
|
||||||
// Adding columns to wxDataViewListCtrl.
|
// Adding columns to wxDataViewListCtrl.
|
||||||
m_SampleListView->AppendIconTextColumn("Favorite", wxDATAVIEW_CELL_ACTIVATABLE, 30, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE);
|
m_SampleListView->AppendBitmapColumn(wxBitmap(ICON_COLOURED), 0, wxDATAVIEW_CELL_ACTIVATABLE, 30, wxALIGN_CENTER, !wxDATAVIEW_COL_RESIZABLE);
|
||||||
m_SampleListView->AppendTextColumn("Filename", wxDATAVIEW_CELL_INERT, 320, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
|
m_SampleListView->AppendTextColumn("Filename", wxDATAVIEW_CELL_INERT, 320, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
|
||||||
m_SampleListView->AppendTextColumn("Sample Pack", wxDATAVIEW_CELL_INERT, 200, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
|
m_SampleListView->AppendTextColumn("Sample Pack", wxDATAVIEW_CELL_INERT, 200, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
|
||||||
m_SampleListView->AppendTextColumn("Type", wxDATAVIEW_CELL_INERT, 120, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
|
m_SampleListView->AppendTextColumn("Type", wxDATAVIEW_CELL_INERT, 120, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
|
||||||
|
|
@ -232,6 +232,7 @@ MainFrame::MainFrame()
|
||||||
|
|
||||||
m_Hives->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(MainFrame::OnDragAndDropToHives), NULL, this);
|
m_Hives->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(MainFrame::OnDragAndDropToHives), NULL, this);
|
||||||
Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &MainFrame::OnShowHivesContextMenu, this, BC_Hives);
|
Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &MainFrame::OnShowHivesContextMenu, this, BC_Hives);
|
||||||
|
Bind(wxEVT_DATAVIEW_ITEM_START_EDITING, &MainFrame::OnHiveStartEditing, this, BC_Hives);
|
||||||
Bind(wxEVT_BUTTON, &MainFrame::OnClickAddHive, this, BC_HiveAdd);
|
Bind(wxEVT_BUTTON, &MainFrame::OnClickAddHive, this, BC_HiveAdd);
|
||||||
Bind(wxEVT_BUTTON, &MainFrame::OnClickRemoveHive, this, BC_HiveRemove);
|
Bind(wxEVT_BUTTON, &MainFrame::OnClickRemoveHive, this, BC_HiveRemove);
|
||||||
|
|
||||||
|
|
@ -442,8 +443,7 @@ void MainFrame::AddSamples(wxArrayString& files)
|
||||||
|
|
||||||
wxVector<wxVariant> data;
|
wxVector<wxVariant> data;
|
||||||
|
|
||||||
wxVariant icon;
|
wxVariant icon = wxVariant(wxBitmap(ICON_GREYSCALE));
|
||||||
icon << wxDataViewIconText(wxEmptyString, wxIcon(ICON_GREYSCALE));
|
|
||||||
|
|
||||||
if (tags.IsFileValid())
|
if (tags.IsFileValid())
|
||||||
{
|
{
|
||||||
|
|
@ -578,8 +578,7 @@ void MainFrame::OnDragAndDropToHives(wxDropFilesEvent& event)
|
||||||
{
|
{
|
||||||
m_Hives->AppendItem(drop_target, files[i]);
|
m_Hives->AppendItem(drop_target, files[i]);
|
||||||
|
|
||||||
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_COLOURED))),
|
m_SampleListView->SetValue(wxVariant(wxBitmap(ICON_COLOURED)), row, 0);
|
||||||
row, 0);
|
|
||||||
|
|
||||||
db.UpdateFavoriteColumn(file_name.ToStdString(), 1);
|
db.UpdateFavoriteColumn(file_name.ToStdString(), 1);
|
||||||
db.UpdateHiveName(file_name.ToStdString(), hive_name.ToStdString());
|
db.UpdateHiveName(file_name.ToStdString(), hive_name.ToStdString());
|
||||||
|
|
@ -864,9 +863,12 @@ void MainFrame::OnClickSampleView(wxDataViewEvent& event)
|
||||||
wxString selection = m_SampleListView->GetTextValue(selected_row, 1);
|
wxString selection = m_SampleListView->GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
//Get Column
|
//Get Column
|
||||||
wxDataViewColumn* column = m_SampleListView->GetCurrentColumn();
|
wxDataViewColumn* CurrentColumn = m_SampleListView->GetCurrentColumn();
|
||||||
|
|
||||||
if (!column)
|
//Get Favorite column
|
||||||
|
wxDataViewColumn* FavoriteColumn = m_SampleListView->GetColumn(0);
|
||||||
|
|
||||||
|
if (!CurrentColumn)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Get Filename
|
//Get Filename
|
||||||
|
|
@ -893,7 +895,7 @@ void MainFrame::OnClickSampleView(wxDataViewEvent& event)
|
||||||
std::string filename = GetFilenamePathAndExtension(selection).Filename;
|
std::string filename = GetFilenamePathAndExtension(selection).Filename;
|
||||||
std::string extension = GetFilenamePathAndExtension(selection).Extension;
|
std::string extension = GetFilenamePathAndExtension(selection).Extension;
|
||||||
|
|
||||||
if (column->GetTitle() != m_Hives->GetItemText(favorites_hive))
|
if (CurrentColumn != FavoriteColumn)
|
||||||
{
|
{
|
||||||
m_MediaCtrl->Load(sample_path);
|
m_MediaCtrl->Load(sample_path);
|
||||||
|
|
||||||
|
|
@ -927,8 +929,7 @@ void MainFrame::OnClickSampleView(wxDataViewEvent& event)
|
||||||
|
|
||||||
if (db.GetFavoriteColumnValueByFilename(filename) == 0)
|
if (db.GetFavoriteColumnValueByFilename(filename) == 0)
|
||||||
{
|
{
|
||||||
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_COLOURED))),
|
m_SampleListView->SetValue(wxVariant(wxBitmap(ICON_COLOURED)), selected_row, 0);
|
||||||
selected_row, 0);
|
|
||||||
|
|
||||||
db.UpdateFavoriteColumn(filename, 1);
|
db.UpdateFavoriteColumn(filename, 1);
|
||||||
db.UpdateHiveName(filename, hive_name);
|
db.UpdateHiveName(filename, hive_name);
|
||||||
|
|
@ -948,8 +949,7 @@ void MainFrame::OnClickSampleView(wxDataViewEvent& event)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_GREYSCALE))),
|
m_SampleListView->SetValue(wxVariant(wxBitmap(ICON_GREYSCALE)), selected_row, 0);
|
||||||
selected_row, 0);
|
|
||||||
|
|
||||||
db.UpdateFavoriteColumn(filename, 0);
|
db.UpdateFavoriteColumn(filename, 0);
|
||||||
db.UpdateHiveName(filename, m_Hives->GetItemText(favorites_hive).ToStdString());
|
db.UpdateHiveName(filename, m_Hives->GetItemText(favorites_hive).ToStdString());
|
||||||
|
|
@ -983,16 +983,16 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath);
|
Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath);
|
||||||
Database db(*m_InfoBar);
|
Database db(*m_InfoBar);
|
||||||
|
|
||||||
wxDataViewItem selected_item = event.GetItem();
|
wxDataViewItem selected_hive = event.GetItem();
|
||||||
|
|
||||||
wxString hive_name = m_Hives->GetItemText(selected_item);
|
wxString hive_name = m_Hives->GetItemText(selected_hive);
|
||||||
|
|
||||||
wxMenu menu;
|
wxMenu menu;
|
||||||
|
|
||||||
if (m_Hives->IsContainer(selected_item))
|
if (m_Hives->IsContainer(selected_hive))
|
||||||
{
|
{
|
||||||
// Container menu items
|
// Container menu items
|
||||||
// container_menu.Append(MN_CreateHive, "Create new hive");
|
menu.Append(MN_RenameHive, "Rename hive");
|
||||||
menu.Append(MN_DeleteHive, "Delete hive");
|
menu.Append(MN_DeleteHive, "Delete hive");
|
||||||
|
|
||||||
if (!bFiltered)
|
if (!bFiltered)
|
||||||
|
|
@ -1007,14 +1007,117 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
menu.Append(MN_ShowInLibrary, "Show sample in library");
|
menu.Append(MN_ShowInLibrary, "Show sample in library");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected_item.IsOk() && m_Hives->IsContainer(selected_item))
|
if (selected_hive.IsOk() && m_Hives->IsContainer(selected_hive))
|
||||||
{
|
{
|
||||||
wxLogDebug("Container menu");
|
wxLogDebug("Container menu");
|
||||||
|
|
||||||
switch (m_Hives->GetPopupMenuSelectionFromUser(menu, event.GetPosition()))
|
switch (m_Hives->GetPopupMenuSelectionFromUser(menu, event.GetPosition()))
|
||||||
{
|
{
|
||||||
// case MN_CreateHive:
|
case MN_RenameHive:
|
||||||
// break;
|
{
|
||||||
|
std::deque<wxDataViewItem> nodes;
|
||||||
|
nodes.push_back(m_Hives->GetNthChild(wxDataViewItem(wxNullPtr), 0));
|
||||||
|
|
||||||
|
wxDataViewItem current_item, found_item;
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
int hive_count = m_Hives->GetChildCount(wxDataViewItem(wxNullPtr));
|
||||||
|
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
wxTextEntryDialog* renameEntry;
|
||||||
|
renameEntry = new wxTextEntryDialog(this, "Enter new name", wxGetTextFromUserPromptStr,
|
||||||
|
wxEmptyString, wxTextEntryDialogStyle, wxDefaultPosition);
|
||||||
|
|
||||||
|
renameEntry->SetTextValidator(wxFILTER_EMPTY);
|
||||||
|
|
||||||
|
switch (renameEntry->ShowModal())
|
||||||
|
{
|
||||||
|
case wxID_OK:
|
||||||
|
{
|
||||||
|
wxString hive_name = renameEntry->GetValue();
|
||||||
|
|
||||||
|
while(!nodes.empty())
|
||||||
|
{
|
||||||
|
current_item = nodes.front();
|
||||||
|
nodes.pop_front();
|
||||||
|
|
||||||
|
if (m_Hives->GetItemText(current_item) == hive_name)
|
||||||
|
{
|
||||||
|
found_item = current_item;
|
||||||
|
wxLogDebug("Found item: %s", m_Hives->GetItemText(current_item));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDataViewItem child = m_Hives->GetNthChild(wxDataViewItem(wxNullPtr), 0);
|
||||||
|
|
||||||
|
wxLogDebug("Row: %d :: Hive count: %d :: Child: %s",
|
||||||
|
row, hive_count, m_Hives->GetItemText(child));
|
||||||
|
|
||||||
|
while (row < (hive_count - 1))
|
||||||
|
{
|
||||||
|
row ++;
|
||||||
|
|
||||||
|
child = m_Hives->GetNthChild(wxDataViewItem(wxNullPtr), row);
|
||||||
|
nodes.push_back(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nodes.clear();
|
||||||
|
|
||||||
|
if (found_item.IsOk())
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(
|
||||||
|
"Another hive by the name %s already exist. Please try with a different name.",
|
||||||
|
hive_name),
|
||||||
|
"Error!", wxOK | wxCENTRE, this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString selected_hive_name = m_Hives->GetItemText(selected_hive);
|
||||||
|
|
||||||
|
int sample_count = m_Hives->GetChildCount(selected_hive);
|
||||||
|
|
||||||
|
if (sample_count <= 0)
|
||||||
|
{
|
||||||
|
wxLogDebug("Sample count: %d", sample_count);
|
||||||
|
|
||||||
|
m_Hives->SetItemText(selected_hive, hive_name);
|
||||||
|
db.UpdateHive(selected_hive_name.ToStdString(), hive_name.ToStdString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < sample_count; i++)
|
||||||
|
{
|
||||||
|
wxDataViewItem sample_item = m_Hives->GetNthChild(selected_hive, i);
|
||||||
|
|
||||||
|
wxString sample_name = settings.IsShowFileExtension() ?
|
||||||
|
m_Hives->GetItemText(sample_item).BeforeLast('.') :
|
||||||
|
m_Hives->GetItemText(sample_item);
|
||||||
|
|
||||||
|
wxLogDebug("Sample count: %d :: Sample name: %s", sample_count, sample_name);
|
||||||
|
|
||||||
|
db.UpdateHiveName(sample_name.ToStdString(), hive_name.ToStdString());
|
||||||
|
db.UpdateHive(selected_hive_name.ToStdString(), hive_name.ToStdString());
|
||||||
|
|
||||||
|
m_Hives->SetItemText(selected_hive, hive_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = wxString::Format("Successfully changed hive name to %s.", hive_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case wxID_CANCEL:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
m_InfoBar->ShowMessage(msg, wxICON_INFORMATION);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case MN_DeleteHive:
|
case MN_DeleteHive:
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
@ -1041,12 +1144,12 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
"Error!", wxOK | wxCENTRE, this);
|
"Error!", wxOK | wxCENTRE, this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!selected_item.IsOk())
|
else if (!selected_hive.IsOk())
|
||||||
{
|
{
|
||||||
wxMessageBox("No hive selected, try selecting a hive first", "Error!", wxOK | wxCENTRE, this);
|
wxMessageBox("No hive selected, try selecting a hive first", "Error!", wxOK | wxCENTRE, this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (selected_item.IsOk() && !m_Hives->IsContainer(selected_item))
|
else if (selected_hive.IsOk() && !m_Hives->IsContainer(selected_hive))
|
||||||
{
|
{
|
||||||
wxMessageBox(wxString::Format("Error! %s is not a hive, cannot delete from hives.",
|
wxMessageBox(wxString::Format("Error! %s is not a hive, cannot delete from hives.",
|
||||||
hive_name),
|
hive_name),
|
||||||
|
|
@ -1054,15 +1157,15 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_Hives->GetChildCount(selected_item) <= 0)
|
if(m_Hives->GetChildCount(selected_hive) <= 0)
|
||||||
{
|
{
|
||||||
switch (deleteEmptyHiveDialog.ShowModal())
|
switch (deleteEmptyHiveDialog.ShowModal())
|
||||||
{
|
{
|
||||||
case wxID_YES:
|
case wxID_YES:
|
||||||
if (selected_item.IsOk() && m_Hives->IsContainer(selected_item) &&
|
if (selected_hive.IsOk() && m_Hives->IsContainer(selected_hive) &&
|
||||||
hive_name != m_Hives->GetItemText(favorites_hive))
|
hive_name != m_Hives->GetItemText(favorites_hive))
|
||||||
{
|
{
|
||||||
m_Hives->DeleteItem(selected_item);
|
m_Hives->DeleteItem(selected_hive);
|
||||||
|
|
||||||
db.RemoveHiveFromDatabase(hive_name.ToStdString());
|
db.RemoveHiveFromDatabase(hive_name.ToStdString());
|
||||||
|
|
||||||
|
|
@ -1080,7 +1183,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
switch (deleteFilledHiveDialog.ShowModal())
|
switch (deleteFilledHiveDialog.ShowModal())
|
||||||
{
|
{
|
||||||
case wxID_YES:
|
case wxID_YES:
|
||||||
if (selected_item.IsOk() && m_Hives->IsContainer(selected_item) &&
|
if (selected_hive.IsOk() && m_Hives->IsContainer(selected_hive) &&
|
||||||
hive_name != m_Hives->GetItemText(favorites_hive))
|
hive_name != m_Hives->GetItemText(favorites_hive))
|
||||||
{
|
{
|
||||||
wxDataViewItem child_item;
|
wxDataViewItem child_item;
|
||||||
|
|
@ -1091,9 +1194,9 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
m_SampleListView->GetTextValue(i, 1).BeforeLast('.') :
|
m_SampleListView->GetTextValue(i, 1).BeforeLast('.') :
|
||||||
m_SampleListView->GetTextValue(i, 1);
|
m_SampleListView->GetTextValue(i, 1);
|
||||||
|
|
||||||
for (int j = 0; j < m_Hives->GetChildCount(selected_item); j++)
|
for (int j = 0; j < m_Hives->GetChildCount(selected_hive); j++)
|
||||||
{
|
{
|
||||||
child_item = m_Hives->GetNthChild(selected_item, j);
|
child_item = m_Hives->GetNthChild(selected_hive, j);
|
||||||
|
|
||||||
wxString child_name = settings.IsShowFileExtension() ?
|
wxString child_name = settings.IsShowFileExtension() ?
|
||||||
m_Hives->GetItemText(child_item).BeforeLast('.') :
|
m_Hives->GetItemText(child_item).BeforeLast('.') :
|
||||||
|
|
@ -1103,7 +1206,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
wxLogDebug("Found match");
|
wxLogDebug("Found match");
|
||||||
|
|
||||||
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_GREYSCALE))), i, 0);
|
m_SampleListView->SetValue(wxVariant(wxBitmap(ICON_GREYSCALE)), i, 0);
|
||||||
|
|
||||||
db.UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
db.UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
||||||
db.UpdateHiveName(matched_sample.ToStdString(),
|
db.UpdateHiveName(matched_sample.ToStdString(),
|
||||||
|
|
@ -1116,8 +1219,8 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Hives->DeleteChildren(selected_item);
|
m_Hives->DeleteChildren(selected_hive);
|
||||||
m_Hives->DeleteItem(selected_item);
|
m_Hives->DeleteItem(selected_hive);
|
||||||
|
|
||||||
db.RemoveHiveFromDatabase(hive_name.ToStdString());
|
db.RemoveHiveFromDatabase(hive_name.ToStdString());
|
||||||
|
|
||||||
|
|
@ -1207,7 +1310,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (selected_item.IsOk() && !m_Hives->IsContainer(selected_item))
|
else if (selected_hive.IsOk() && !m_Hives->IsContainer(selected_hive))
|
||||||
{
|
{
|
||||||
wxLogDebug("Child menu");
|
wxLogDebug("Child menu");
|
||||||
|
|
||||||
|
|
@ -1228,13 +1331,13 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
wxLogDebug("Found match");
|
wxLogDebug("Found match");
|
||||||
|
|
||||||
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_GREYSCALE))), i, 0);
|
m_SampleListView->SetValue(wxVariant(wxBitmap(ICON_GREYSCALE)), i, 0);
|
||||||
|
|
||||||
db.UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
db.UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
||||||
db.UpdateHiveName(matched_sample.ToStdString(),
|
db.UpdateHiveName(matched_sample.ToStdString(),
|
||||||
m_Hives->GetItemText(favorites_hive).ToStdString());
|
m_Hives->GetItemText(favorites_hive).ToStdString());
|
||||||
|
|
||||||
m_Hives->DeleteItem(selected_item);
|
m_Hives->DeleteItem(selected_hive);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1375,8 +1478,7 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
|
||||||
//Add To Favorites
|
//Add To Favorites
|
||||||
if (favorite_add && db_status == 0)
|
if (favorite_add && db_status == 0)
|
||||||
{
|
{
|
||||||
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_COLOURED))),
|
m_SampleListView->SetValue(wxVariant(wxBitmap(ICON_COLOURED)), selected_row, 0);
|
||||||
selected_row, 0);
|
|
||||||
|
|
||||||
db.UpdateFavoriteColumn(filename, 1);
|
db.UpdateFavoriteColumn(filename, 1);
|
||||||
db.UpdateHiveName(filename, hive_name);
|
db.UpdateHiveName(filename, hive_name);
|
||||||
|
|
@ -1397,8 +1499,7 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Remove From Favorites
|
//Remove From Favorites
|
||||||
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_GREYSCALE))),
|
m_SampleListView->SetValue(wxVariant(wxBitmap(ICON_GREYSCALE)), selected_row, 0);
|
||||||
selected_row, 0);
|
|
||||||
|
|
||||||
db.UpdateFavoriteColumn(filename, 0);
|
db.UpdateFavoriteColumn(filename, 0);
|
||||||
db.UpdateHiveName(filename, m_Hives->GetItemText(favorites_hive).ToStdString());
|
db.UpdateHiveName(filename, m_Hives->GetItemText(favorites_hive).ToStdString());
|
||||||
|
|
@ -1571,8 +1672,7 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
|
||||||
|
|
||||||
if (db.GetFavoriteColumnValueByFilename(filename))
|
if (db.GetFavoriteColumnValueByFilename(filename))
|
||||||
{
|
{
|
||||||
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_GREYSCALE))),
|
m_SampleListView->SetValue(wxVariant(wxBitmap(ICON_GREYSCALE)), selected_row, 0);
|
||||||
selected_row, 0);
|
|
||||||
|
|
||||||
db.UpdateFavoriteColumn(filename, 0);
|
db.UpdateFavoriteColumn(filename, 0);
|
||||||
|
|
||||||
|
|
@ -1628,8 +1728,7 @@ void MainFrame::OnShowSampleListViewContextMenu(wxDataViewEvent& event)
|
||||||
|
|
||||||
if (db.GetFavoriteColumnValueByFilename(files[i].ToStdString()))
|
if (db.GetFavoriteColumnValueByFilename(files[i].ToStdString()))
|
||||||
{
|
{
|
||||||
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_GREYSCALE))),
|
m_SampleListView->SetValue(wxVariant(wxBitmap(ICON_GREYSCALE)), item_row, 0);
|
||||||
item_row, 0);
|
|
||||||
|
|
||||||
db.UpdateFavoriteColumn(files[i].ToStdString(), 0);
|
db.UpdateFavoriteColumn(files[i].ToStdString(), 0);
|
||||||
|
|
||||||
|
|
@ -1914,7 +2013,7 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxLogDebug("Found match");
|
wxLogDebug("Found match");
|
||||||
|
|
||||||
m_SampleListView->SetValue(wxVariant(wxDataViewIconText(wxEmptyString, wxIcon(ICON_GREYSCALE))), i, 0);
|
m_SampleListView->SetValue(wxVariant(wxBitmap(ICON_GREYSCALE)), i, 0);
|
||||||
|
|
||||||
db.UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
db.UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
||||||
db.UpdateHiveName(matched_sample.ToStdString(),
|
db.UpdateHiveName(matched_sample.ToStdString(),
|
||||||
|
|
@ -2095,4 +2194,10 @@ MainFrame::GetFilenamePathAndExtension(const wxString& selected, bool checkExten
|
||||||
return { path, extension, filename };
|
return { path, extension, filename };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainFrame::OnHiveStartEditing(wxDataViewEvent &event)
|
||||||
|
{
|
||||||
|
wxLogDebug("Right click on a hive and select rename to rename it..");
|
||||||
|
event.Veto();
|
||||||
|
}
|
||||||
|
|
||||||
MainFrame::~MainFrame(){}
|
MainFrame::~MainFrame(){}
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,7 @@ class MainFrame : public wxFrame
|
||||||
void OnClickAddHive(wxCommandEvent& event);
|
void OnClickAddHive(wxCommandEvent& event);
|
||||||
void OnClickRemoveHive(wxCommandEvent& event);
|
void OnClickRemoveHive(wxCommandEvent& event);
|
||||||
void OnShowHivesContextMenu(wxDataViewEvent& event);
|
void OnShowHivesContextMenu(wxDataViewEvent& event);
|
||||||
|
void OnHiveStartEditing(wxDataViewEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// SearchCtrl event handlers
|
// SearchCtrl event handlers
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue