Remove InfoBar from Database.
This commit is contained in:
parent
4630695589
commit
0ecf694997
|
|
@ -52,35 +52,38 @@ void show_modal_dialog_and_log(const std::string &message, const std::string &ti
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << message << error_msg;
|
ss << message << error_msg;
|
||||||
|
|
||||||
const auto msg = ss.str();
|
const auto msg = ss.str();
|
||||||
|
|
||||||
wxLogDebug(msg.c_str());
|
wxLogDebug(msg.c_str());
|
||||||
wxMessageDialog msgDialog(NULL, msg, title, wxOK | wxICON_ERROR);
|
|
||||||
|
wxMessageDialog msgDialog(NULL, _(msg), _(title), wxOK | wxICON_ERROR);
|
||||||
msgDialog.ShowModal();
|
msgDialog.ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
class Sqlite3Statement
|
class Sqlite3Statement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Sqlite3Statement(sqlite3 *database, const std::string &query)
|
Sqlite3Statement(sqlite3 *database, const std::string &query)
|
||||||
{
|
{
|
||||||
throw_on_sqlite3_error(sqlite3_prepare_v2(database, query.c_str(), query.size(), &stmt, NULL));
|
throw_on_sqlite3_error(sqlite3_prepare_v2(database, query.c_str(), query.size(), &stmt, NULL));
|
||||||
}
|
}
|
||||||
~Sqlite3Statement()
|
~Sqlite3Statement()
|
||||||
{
|
{
|
||||||
throw_on_sqlite3_error(sqlite3_finalize(stmt));
|
throw_on_sqlite3_error(sqlite3_finalize(stmt));
|
||||||
}
|
}
|
||||||
sqlite3_stmt *stmt = nullptr;
|
|
||||||
|
sqlite3_stmt *stmt = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
Database::Database(wxInfoBar &infoBar, const std::string &dbPath)
|
Database::Database(const std::string &dbPath)
|
||||||
: m_InfoBar(infoBar)
|
|
||||||
{
|
{
|
||||||
open(dbPath);
|
OpenDatabase(dbPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Database::~Database()
|
Database::~Database()
|
||||||
{
|
{
|
||||||
close();
|
CloseDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::CreateTableSamples()
|
void Database::CreateTableSamples()
|
||||||
|
|
@ -103,7 +106,7 @@ void Database::CreateTableSamples()
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
throw_on_sqlite3_error(sqlite3_exec(m_Database, samples, NULL, 0, &m_ErrMsg));
|
throw_on_sqlite3_error(sqlite3_exec(m_Database, samples, NULL, 0, &m_ErrMsg));
|
||||||
wxLogDebug("Samples table created successfully.");
|
wxLogDebug(_("Samples table created successfully."));
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
|
|
@ -194,6 +197,7 @@ void Database::InsertIntoHives(const std::string &hiveName)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "INSERT INTO HIVES(HIVE) VALUES(?);";
|
const auto sql = "INSERT INTO HIVES(HIVE) VALUES(?);";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
// rc = sqlite3_exec(m_Database, "BEGIN TRANSACTION", NULL, NULL, &m_ErrMsg);
|
// rc = sqlite3_exec(m_Database, "BEGIN TRANSACTION", NULL, NULL, &m_ErrMsg);
|
||||||
|
|
@ -241,6 +245,7 @@ void Database::UpdateHive(const std::string &hiveOldName, const std::string &hiv
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "UPDATE HIVES SET HIVE = ? WHERE HIVE = ?;";
|
const auto sql = "UPDATE HIVES SET HIVE = ? WHERE HIVE = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveNewName.c_str(), hiveNewName.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveNewName.c_str(), hiveNewName.size(), SQLITE_STATIC));
|
||||||
|
|
@ -266,6 +271,7 @@ void Database::UpdateHiveName(const std::string &filename, const std::string &hi
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "UPDATE SAMPLES SET HIVE = ? WHERE FILENAME = ?;";
|
const auto sql = "UPDATE SAMPLES SET HIVE = ? WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC));
|
||||||
|
|
@ -289,6 +295,7 @@ void Database::UpdateFavoriteColumn(const std::string &filename, int value)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "UPDATE SAMPLES SET FAVORITE = ? WHERE FILENAME = ?;";
|
const auto sql = "UPDATE SAMPLES SET FAVORITE = ? WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, value));
|
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, value));
|
||||||
|
|
@ -312,6 +319,7 @@ void Database::UpdateSamplePack(const std::string &filename, const std::string &
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "UPDATE SAMPLES SET SAMPLEPACK = ? WHERE FILENAME = ?;";
|
const auto sql = "UPDATE SAMPLES SET SAMPLEPACK = ? WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, samplePack.c_str(), samplePack.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, samplePack.c_str(), samplePack.size(), SQLITE_STATIC));
|
||||||
|
|
@ -335,6 +343,7 @@ void Database::UpdateSampleType(const std::string &filename, const std::string &
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "UPDATE SAMPLES SET TYPE = ? WHERE FILENAME = ?;";
|
const auto sql = "UPDATE SAMPLES SET TYPE = ? WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, type.c_str(), type.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, type.c_str(), type.size(), SQLITE_STATIC));
|
||||||
|
|
@ -359,6 +368,7 @@ std::string Database::GetSampleType(const std::string &filename)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT TYPE FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT TYPE FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
|
|
@ -369,6 +379,7 @@ std::string Database::GetSampleType(const std::string &filename)
|
||||||
|
|
||||||
type = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0)));
|
type = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogDebug("Selected data from table successfully.");
|
wxLogDebug("Selected data from table successfully.");
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
|
|
@ -386,6 +397,7 @@ int Database::GetFavoriteColumnValueByFilename(const std::string &filename)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT FAVORITE FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT FAVORITE FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
|
|
@ -413,6 +425,7 @@ std::string Database::GetHiveByFilename(const std::string &filename)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT HIVE FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT HIVE FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
|
|
@ -438,6 +451,7 @@ void Database::RemoveSampleFromDatabase(const std::string &filename)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "DELETE FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "DELETE FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
|
|
@ -460,6 +474,7 @@ void Database::RemoveHiveFromDatabase(const std::string &hiveName)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "DELETE FROM HIVES WHERE HIVE = ?;";
|
const auto sql = "DELETE FROM HIVES WHERE HIVE = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC));
|
||||||
|
|
@ -484,6 +499,7 @@ std::string Database::GetSamplePathByFilename(const std::string &filename)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT PATH FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT PATH FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
|
|
@ -511,6 +527,7 @@ std::string Database::GetSampleFileExtension(const std::string &filename)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT EXTENSION FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT EXTENSION FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
|
|
@ -531,31 +548,34 @@ std::string Database::GetSampleFileExtension(const std::string &filename)
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(
|
wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &favorite_tree, wxDataViewItem &favorite_item,
|
||||||
// wxTreeCtrl& favorite_tree, wxTreeItemId& favorite_item,
|
wxTreeCtrl &trash_tree, wxTreeItemId &trash_item, bool show_extension,
|
||||||
wxDataViewTreeCtrl &favorite_tree, wxDataViewItem &favorite_item,
|
const std::string &icon_star_filled, const std::string &icon_star_empty)
|
||||||
wxTreeCtrl &trash_tree, wxTreeItemId &trash_item, bool show_extension,
|
|
||||||
const std::string &icon_star_filled, const std::string &icon_star_empty)
|
|
||||||
{
|
{
|
||||||
wxVector<wxVector<wxVariant>> vecSet;
|
wxVector<wxVector<wxVariant>> vecSet;
|
||||||
|
|
||||||
wxVariant icon_filled, icon_empty;
|
wxVariant icon_filled, icon_empty;
|
||||||
icon_filled = wxVariant(wxBitmap(icon_star_filled));
|
icon_filled = wxVariant(wxBitmap(icon_star_filled));
|
||||||
icon_empty = wxVariant(wxBitmap(icon_star_empty));
|
icon_empty = wxVariant(wxBitmap(icon_star_empty));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
int numRows = 0;
|
int numRows = 0;
|
||||||
|
|
||||||
Sqlite3Statement statement1(m_Database, "SELECT Count(*) FROM SAMPLES;");
|
Sqlite3Statement statement1(m_Database, "SELECT Count(*) FROM SAMPLES;");
|
||||||
|
|
||||||
if (SQLITE_ROW == sqlite3_step(statement1.stmt))
|
if (SQLITE_ROW == sqlite3_step(statement1.stmt))
|
||||||
{
|
{
|
||||||
numRows = sqlite3_column_int(statement1.stmt, 0);
|
numRows = sqlite3_column_int(statement1.stmt, 0);
|
||||||
|
|
||||||
wxLogDebug("rows %d", numRows);
|
wxLogDebug("rows %d", numRows);
|
||||||
|
|
||||||
vecSet.reserve(numRows);
|
vecSet.reserve(numRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, "SELECT FAVORITE, FILENAME, EXTENSION, SAMPLEPACK, \
|
Sqlite3Statement statement(m_Database, "SELECT FAVORITE, FILENAME, EXTENSION, SAMPLEPACK, \
|
||||||
TYPE, CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH, \
|
TYPE, CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH, \
|
||||||
TRASHED, HIVE FROM SAMPLES;");
|
TRASHED, HIVE FROM SAMPLES;");
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
|
|
@ -580,6 +600,7 @@ wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(
|
||||||
|
|
||||||
wxVector<wxVariant> vec;
|
wxVector<wxVariant> vec;
|
||||||
vec.reserve(12);
|
vec.reserve(12);
|
||||||
|
|
||||||
if (trashed == 1)
|
if (trashed == 1)
|
||||||
{
|
{
|
||||||
if (show_extension)
|
if (show_extension)
|
||||||
|
|
@ -656,6 +677,7 @@ wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(
|
||||||
{
|
{
|
||||||
vec.push_back(path.AfterLast('/').BeforeLast('.'));
|
vec.push_back(path.AfterLast('/').BeforeLast('.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec.push_back(sample_pack);
|
vec.push_back(sample_pack);
|
||||||
vec.push_back(sample_type);
|
vec.push_back(sample_type);
|
||||||
vec.push_back(wxString::Format("%d", channels));
|
vec.push_back(wxString::Format("%d", channels));
|
||||||
|
|
@ -683,14 +705,17 @@ Database::FilterDatabaseBySampleName(const std::string &sampleName, bool show_ex
|
||||||
const std::string &icon_star_filled, const std::string &icon_star_empty)
|
const std::string &icon_star_filled, const std::string &icon_star_empty)
|
||||||
{
|
{
|
||||||
wxVector<wxVector<wxVariant>> sampleVec;
|
wxVector<wxVector<wxVariant>> sampleVec;
|
||||||
|
|
||||||
wxVariant icon_filled, icon_empty;
|
wxVariant icon_filled, icon_empty;
|
||||||
icon_filled = wxVariant(wxBitmap(icon_star_filled));
|
icon_filled = wxVariant(wxBitmap(icon_star_filled));
|
||||||
icon_empty = wxVariant(wxBitmap(icon_star_empty));
|
icon_empty = wxVariant(wxBitmap(icon_star_empty));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Sqlite3Statement statement(m_Database, "SELECT FAVORITE, FILENAME, SAMPLEPACK, TYPE, \
|
Sqlite3Statement statement(m_Database, "SELECT FAVORITE, FILENAME, SAMPLEPACK, TYPE, \
|
||||||
CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \
|
CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \
|
||||||
FROM SAMPLES WHERE FILENAME LIKE '%' || ? || '%' ;");
|
FROM SAMPLES WHERE FILENAME LIKE '%' || ? || '%' ;");
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, sampleName.c_str(), sampleName.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, sampleName.c_str(), sampleName.size(), SQLITE_STATIC));
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
@ -761,14 +786,16 @@ Database::FilterDatabaseByHiveName(const std::string &hiveName, bool show_extens
|
||||||
const std::string &icon_star_filled, const std::string &icon_star_empty)
|
const std::string &icon_star_filled, const std::string &icon_star_empty)
|
||||||
{
|
{
|
||||||
wxVector<wxVector<wxVariant>> sampleVec;
|
wxVector<wxVector<wxVariant>> sampleVec;
|
||||||
|
|
||||||
wxVariant icon_filled, icon_empty;
|
wxVariant icon_filled, icon_empty;
|
||||||
icon_filled = wxVariant(wxBitmap(icon_star_filled));
|
icon_filled = wxVariant(wxBitmap(icon_star_filled));
|
||||||
icon_empty = wxVariant(wxBitmap(icon_star_empty));
|
icon_empty = wxVariant(wxBitmap(icon_star_empty));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Sqlite3Statement statement(m_Database, "SELECT FAVORITE, FILENAME, SAMPLEPACK, TYPE, \
|
Sqlite3Statement statement(m_Database, "SELECT FAVORITE, FILENAME, SAMPLEPACK, TYPE, \
|
||||||
CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \
|
CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \
|
||||||
FROM SAMPLES WHERE HIVE = ? AND FAVORITE = 1;");
|
FROM SAMPLES WHERE HIVE = ? AND FAVORITE = 1;");
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC));
|
||||||
|
|
||||||
|
|
@ -840,6 +867,7 @@ void Database::LoadHivesDatabase(wxDataViewTreeCtrl &treeCtrl)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT HIVE FROM HIVES;";
|
const auto sql = "SELECT HIVE FROM HIVES;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
while (SQLITE_ROW == sqlite3_step(statement.stmt))
|
while (SQLITE_ROW == sqlite3_step(statement.stmt))
|
||||||
|
|
@ -867,6 +895,7 @@ wxArrayString Database::CheckDuplicates(const wxArrayString &files)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT * FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT * FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < files.size(); i++)
|
for (unsigned int i = 0; i < files.size(); i++)
|
||||||
|
|
@ -897,6 +926,7 @@ bool Database::IsTrashed(const std::string &filename)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT TRASHED FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT TRASHED FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
|
|
@ -924,6 +954,7 @@ void Database::UpdateTrashColumn(const std::string &filename, int value)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "UPDATE SAMPLES SET TRASHED = ? WHERE FILENAME = ?;";
|
const auto sql = "UPDATE SAMPLES SET TRASHED = ? WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, value));
|
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, value));
|
||||||
|
|
@ -950,11 +981,13 @@ Database::RestoreFromTrashByFilename(const std::string &filename,
|
||||||
wxVariant icon_filled, icon_empty;
|
wxVariant icon_filled, icon_empty;
|
||||||
icon_filled = wxVariant(wxBitmap(icon_star_filled));
|
icon_filled = wxVariant(wxBitmap(icon_star_filled));
|
||||||
icon_empty = wxVariant(wxBitmap(icon_star_empty));
|
icon_empty = wxVariant(wxBitmap(icon_star_empty));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT FAVORITE, FILENAME, EXTENSION, SAMPLEPACK, \
|
const auto sql = "SELECT FAVORITE, FILENAME, EXTENSION, SAMPLEPACK, \
|
||||||
TYPE, CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH, \
|
TYPE, CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH, \
|
||||||
TRASHED, HIVE FROM SAMPLES WHERE FILENAME = ?;";
|
TRASHED, HIVE FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_Database, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
|
|
@ -1012,12 +1045,12 @@ Database::RestoreFromTrashByFilename(const std::string &filename,
|
||||||
return vecSet;
|
return vecSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::open(const std::string &dbPath)
|
void Database::OpenDatabase(const std::string &dbPath)
|
||||||
{
|
{
|
||||||
throw_on_sqlite3_error(sqlite3_open(dbPath.c_str(), &m_Database));
|
throw_on_sqlite3_error(sqlite3_open(dbPath.c_str(), &m_Database));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::close()
|
void Database::CloseDatabase()
|
||||||
{
|
{
|
||||||
throw_on_sqlite3_error(sqlite3_close(m_Database));
|
throw_on_sqlite3_error(sqlite3_close(m_Database));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
class Database
|
class Database
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Database(wxInfoBar& infoBar, const std::string& dbPath);
|
Database(const std::string& dbPath);
|
||||||
~Database();
|
~Database();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -45,12 +45,11 @@ class Database
|
||||||
sqlite3* m_Database;
|
sqlite3* m_Database;
|
||||||
int rc;
|
int rc;
|
||||||
char* m_ErrMsg;
|
char* m_ErrMsg;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
wxInfoBar& m_InfoBar;
|
void OpenDatabase(const std::string& dbPath);
|
||||||
|
void CloseDatabase();
|
||||||
void open(const std::string& dbPath);
|
|
||||||
void close();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
@ -91,9 +90,6 @@ class Database
|
||||||
void RemoveHiveFromDatabase(const std::string& hiveName);
|
void RemoveHiveFromDatabase(const std::string& hiveName);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// LoadDatabase(wxVector<wxVector<wxVariant>> &vecSet,
|
|
||||||
// wxTreeCtrl& favorite_tree, wxTreeItemId& favorite_item,
|
|
||||||
// wxTreeCtrl& trash_tree, wxTreeItemId& trash_item, bool show_extension);
|
|
||||||
wxVector<wxVector<wxVariant>>
|
wxVector<wxVector<wxVariant>>
|
||||||
LoadSamplesDatabase(wxDataViewTreeCtrl& favorite_tree, wxDataViewItem& favorite_item,
|
LoadSamplesDatabase(wxDataViewTreeCtrl& favorite_tree, wxDataViewItem& favorite_item,
|
||||||
wxTreeCtrl& trash_tree, wxTreeItemId& trash_item, bool show_extension,
|
wxTreeCtrl& trash_tree, wxTreeItemId& trash_item, bool show_extension,
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,16 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "MainFrame.hpp"
|
||||||
|
#include "ControlID_Enums.hpp"
|
||||||
|
#include "Database.hpp"
|
||||||
|
#include "SettingsDialog.hpp"
|
||||||
|
#include "TagEditorDialog.hpp"
|
||||||
|
#include "Tags.hpp"
|
||||||
|
#include "Sample.hpp"
|
||||||
|
#include "Serialize.hpp"
|
||||||
|
#include "SampleHiveConfig.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
@ -56,16 +66,6 @@
|
||||||
#include <wx/vector.h>
|
#include <wx/vector.h>
|
||||||
#include <wx/utils.h>
|
#include <wx/utils.h>
|
||||||
|
|
||||||
#include "MainFrame.hpp"
|
|
||||||
#include "ControlID_Enums.hpp"
|
|
||||||
#include "Database.hpp"
|
|
||||||
#include "SettingsDialog.hpp"
|
|
||||||
#include "TagEditorDialog.hpp"
|
|
||||||
#include "Tags.hpp"
|
|
||||||
#include "Sample.hpp"
|
|
||||||
#include "Serialize.hpp"
|
|
||||||
#include "SampleHiveConfig.hpp"
|
|
||||||
|
|
||||||
// Path to all the assets
|
// Path to all the assets
|
||||||
#define ICON_HIVE_16px SAMPLEHIVE_DATADIR "/icons/icon-hive_16x16.png"
|
#define ICON_HIVE_16px SAMPLEHIVE_DATADIR "/icons/icon-hive_16x16.png"
|
||||||
#define ICON_HIVE_24px SAMPLEHIVE_DATADIR "/icons/icon-hive_24x24.png"
|
#define ICON_HIVE_24px SAMPLEHIVE_DATADIR "/icons/icon-hive_24x24.png"
|
||||||
|
|
@ -399,11 +399,12 @@ MainFrame::MainFrame()
|
||||||
m_Timer = new wxTimer(this);
|
m_Timer = new wxTimer(this);
|
||||||
|
|
||||||
// Initialize the database
|
// Initialize the database
|
||||||
m_database = std::make_unique<Database>(*m_InfoBar, m_DatabaseFilepath);
|
// m_Database = std::make_unique<Database>(*m_InfoBar, m_DatabaseFilepath);
|
||||||
m_database->CreateTableSamples();
|
m_Database = std::make_unique<Database>(m_DatabaseFilepath);
|
||||||
m_database->CreateTableHives();
|
m_Database->CreateTableSamples();
|
||||||
|
m_Database->CreateTableHives();
|
||||||
|
|
||||||
m_TopWaveformPanel = new WaveformViewer(this, m_TopPanel, *m_Library, *m_MediaCtrl, *m_database,
|
m_TopWaveformPanel = new WaveformViewer(this, m_TopPanel, *m_Library, *m_MediaCtrl, *m_Database,
|
||||||
m_ConfigFilepath, m_DatabaseFilepath);
|
m_ConfigFilepath, m_DatabaseFilepath);
|
||||||
|
|
||||||
// Binding events.
|
// Binding events.
|
||||||
|
|
@ -604,7 +605,7 @@ void MainFrame::AddSamples(wxArrayString& files)
|
||||||
//Check All Files At Once
|
//Check All Files At Once
|
||||||
wxArrayString sorted_files;
|
wxArrayString sorted_files;
|
||||||
|
|
||||||
sorted_files = m_database->CheckDuplicates(files);
|
sorted_files = m_Database->CheckDuplicates(files);
|
||||||
files = sorted_files;
|
files = sorted_files;
|
||||||
|
|
||||||
if(files.size() < 1)
|
if(files.size() < 1)
|
||||||
|
|
@ -685,7 +686,7 @@ void MainFrame::AddSamples(wxArrayString& files)
|
||||||
|
|
||||||
progressDialog->Pulse(_("Updating Database.."), NULL);
|
progressDialog->Pulse(_("Updating Database.."), NULL);
|
||||||
|
|
||||||
m_database->InsertIntoSamples(sample_array);
|
m_Database->InsertIntoSamples(sample_array);
|
||||||
|
|
||||||
progressDialog->Destroy();
|
progressDialog->Destroy();
|
||||||
}
|
}
|
||||||
|
|
@ -785,23 +786,23 @@ void MainFrame::OnDragAndDropToHives(wxDropFilesEvent& event)
|
||||||
rows - i, files[i], m_Hives->GetItemText(drop_target));
|
rows - i, files[i], m_Hives->GetItemText(drop_target));
|
||||||
|
|
||||||
if (drop_target.IsOk() && m_Hives->IsContainer(drop_target) &&
|
if (drop_target.IsOk() && m_Hives->IsContainer(drop_target) &&
|
||||||
m_database->GetFavoriteColumnValueByFilename(file_name.ToStdString()) == 0)
|
m_Database->GetFavoriteColumnValueByFilename(file_name.ToStdString()) == 0)
|
||||||
{
|
{
|
||||||
m_Hives->AppendItem(drop_target, files[i]);
|
m_Hives->AppendItem(drop_target, files[i]);
|
||||||
|
|
||||||
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_FILLED_16px)), row, 0);
|
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_FILLED_16px)), row, 0);
|
||||||
|
|
||||||
m_database->UpdateFavoriteColumn(file_name.ToStdString(), 1);
|
m_Database->UpdateFavoriteColumn(file_name.ToStdString(), 1);
|
||||||
m_database->UpdateHiveName( file_name.ToStdString(), hive_name.ToStdString());
|
m_Database->UpdateHiveName(file_name.ToStdString(), hive_name.ToStdString());
|
||||||
|
|
||||||
msg = wxString::Format(_("%s added to %s."), files[i], hive_name);
|
msg = wxString::Format(_("%s added to %s."), files[i], hive_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_database->GetFavoriteColumnValueByFilename(file_name.ToStdString()) == 1)
|
if (m_Database->GetFavoriteColumnValueByFilename(file_name.ToStdString()) == 1)
|
||||||
{
|
{
|
||||||
wxMessageBox(wxString::Format(_("%s is already added to %s hive"), files[i],
|
wxMessageBox(wxString::Format(_("%s is already added to %s hive"), files[i],
|
||||||
m_database->GetHiveByFilename(file_name.ToStdString())),
|
m_Database->GetHiveByFilename(file_name.ToStdString())),
|
||||||
_("Error!"), wxOK | wxICON_ERROR | wxCENTRE, this);
|
_("Error!"), wxOK | wxICON_ERROR | wxCENTRE, this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -902,12 +903,12 @@ void MainFrame::OnDragFromLibrary(wxDataViewEvent& event)
|
||||||
|
|
||||||
wxString selection = m_Library->GetTextValue(selected_row, 1);
|
wxString selection = m_Library->GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
// wxString sample_with_extension = m_database->GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
// wxString sample_with_extension = m_Database->GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||||
// wxString sample_without_extension = m_database->GetSamplePathByFilename(selection.ToStdString());
|
// wxString sample_without_extension = m_Database->GetSamplePathByFilename(selection.ToStdString());
|
||||||
|
|
||||||
// std::string extension = settings.ShouldShowFileExtension() ?
|
// std::string extension = settings.ShouldShowFileExtension() ?
|
||||||
// m_database->GetSampleFileExtension(selection.ToStdString()) :
|
// m_Database->GetSampleFileExtension(selection.ToStdString()) :
|
||||||
// m_database->GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
// m_Database->GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
// wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
// wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
||||||
// sample_with_extension : sample_without_extension;
|
// sample_with_extension : sample_without_extension;
|
||||||
|
|
@ -935,12 +936,12 @@ void MainFrame::OnClickPlay(wxCommandEvent& event)
|
||||||
|
|
||||||
wxString selection = m_Library->GetTextValue(selected_row, 1);
|
wxString selection = m_Library->GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
// wxString sample_with_extension = m_database->GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
// wxString sample_with_extension = m_Database->GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||||
// wxString sample_without_extension = m_database->GetSamplePathByFilename(selection.ToStdString());
|
// wxString sample_without_extension = m_Database->GetSamplePathByFilename(selection.ToStdString());
|
||||||
|
|
||||||
// std::string extension = settings.ShouldShowFileExtension() ?
|
// std::string extension = settings.ShouldShowFileExtension() ?
|
||||||
// m_database->GetSampleFileExtension(selection.ToStdString()) :
|
// m_Database->GetSampleFileExtension(selection.ToStdString()) :
|
||||||
// m_database->GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
// m_Database->GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
// wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
// wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
||||||
// sample_with_extension : sample_without_extension;
|
// sample_with_extension : sample_without_extension;
|
||||||
|
|
@ -1129,12 +1130,12 @@ void MainFrame::OnClickLibrary(wxDataViewEvent& event)
|
||||||
// else
|
// else
|
||||||
// selection = m_Library->GetTextValue(selected_row, 1);
|
// selection = m_Library->GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
// wxString sample_with_extension = m_database->GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
// wxString sample_with_extension = m_Database->GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||||
// wxString sample_without_extension = m_database->GetSamplePathByFilename(selection.ToStdString());
|
// wxString sample_without_extension = m_Database->GetSamplePathByFilename(selection.ToStdString());
|
||||||
|
|
||||||
// std::string extension = settings.ShouldShowFileExtension() ?
|
// std::string extension = settings.ShouldShowFileExtension() ?
|
||||||
// m_database->GetSampleFileExtension(selection.ToStdString()) :
|
// m_Database->GetSampleFileExtension(selection.ToStdString()) :
|
||||||
// m_database->GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
// m_Database->GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
// wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
// wxString sample = selection.Contains(wxString::Format(".%s", extension)) ?
|
||||||
// sample_with_extension : sample_without_extension;
|
// sample_with_extension : sample_without_extension;
|
||||||
|
|
@ -1177,12 +1178,12 @@ void MainFrame::OnClickLibrary(wxDataViewEvent& event)
|
||||||
wxDataViewItem container;
|
wxDataViewItem container;
|
||||||
wxDataViewItem child;
|
wxDataViewItem child;
|
||||||
|
|
||||||
if (m_database->GetFavoriteColumnValueByFilename(filename) == 0)
|
if (m_Database->GetFavoriteColumnValueByFilename(filename) == 0)
|
||||||
{
|
{
|
||||||
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_FILLED_16px)), selected_row, 0);
|
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_FILLED_16px)), selected_row, 0);
|
||||||
|
|
||||||
m_database->UpdateFavoriteColumn(filename, 1);
|
m_Database->UpdateFavoriteColumn(filename, 1);
|
||||||
m_database->UpdateHiveName(filename, hive_name);
|
m_Database->UpdateHiveName(filename, hive_name);
|
||||||
|
|
||||||
for (int i = 0; i < m_Hives->GetChildCount(root); i++)
|
for (int i = 0; i < m_Hives->GetChildCount(root); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -1201,8 +1202,8 @@ void MainFrame::OnClickLibrary(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), selected_row, 0);
|
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), selected_row, 0);
|
||||||
|
|
||||||
m_database->UpdateFavoriteColumn(filename, 0);
|
m_Database->UpdateFavoriteColumn(filename, 0);
|
||||||
m_database->UpdateHiveName(filename, m_Hives->GetItemText(favorites_hive).ToStdString());
|
m_Database->UpdateHiveName(filename, m_Hives->GetItemText(favorites_hive).ToStdString());
|
||||||
|
|
||||||
for (int i = 0; i < m_Hives->GetChildCount(root); i++)
|
for (int i = 0; i < m_Hives->GetChildCount(root); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -1329,7 +1330,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
wxLogDebug("Sample count: %d", sample_count);
|
wxLogDebug("Sample count: %d", sample_count);
|
||||||
|
|
||||||
m_Hives->SetItemText(selected_hive, hive_name);
|
m_Hives->SetItemText(selected_hive, hive_name);
|
||||||
m_database->UpdateHive(selected_hive_name.ToStdString(), hive_name.ToStdString());
|
m_Database->UpdateHive(selected_hive_name.ToStdString(), hive_name.ToStdString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1343,8 +1344,8 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
|
|
||||||
wxLogDebug("Sample count: %d :: Sample name: %s", sample_count, sample_name);
|
wxLogDebug("Sample count: %d :: Sample name: %s", sample_count, sample_name);
|
||||||
|
|
||||||
m_database->UpdateHiveName(sample_name.ToStdString(), hive_name.ToStdString());
|
m_Database->UpdateHiveName(sample_name.ToStdString(), hive_name.ToStdString());
|
||||||
m_database->UpdateHive(selected_hive_name.ToStdString(), hive_name.ToStdString());
|
m_Database->UpdateHive(selected_hive_name.ToStdString(), hive_name.ToStdString());
|
||||||
|
|
||||||
m_Hives->SetItemText(selected_hive, hive_name);
|
m_Hives->SetItemText(selected_hive, hive_name);
|
||||||
}
|
}
|
||||||
|
|
@ -1413,7 +1414,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
m_Hives->DeleteItem(selected_hive);
|
m_Hives->DeleteItem(selected_hive);
|
||||||
|
|
||||||
m_database->RemoveHiveFromDatabase(hive_name.ToStdString());
|
m_Database->RemoveHiveFromDatabase(hive_name.ToStdString());
|
||||||
|
|
||||||
msg = wxString::Format(_("%s deleted from hives successfully."), hive_name);
|
msg = wxString::Format(_("%s deleted from hives successfully."), hive_name);
|
||||||
}
|
}
|
||||||
|
|
@ -1454,8 +1455,8 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
|
|
||||||
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0);
|
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0);
|
||||||
|
|
||||||
m_database->UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
m_Database->UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
||||||
m_database->UpdateHiveName(matched_sample.ToStdString(), m_Hives->GetItemText(favorites_hive).ToStdString());
|
m_Database->UpdateHiveName(matched_sample.ToStdString(), m_Hives->GetItemText(favorites_hive).ToStdString());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1467,7 +1468,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
m_Hives->DeleteChildren(selected_hive);
|
m_Hives->DeleteChildren(selected_hive);
|
||||||
m_Hives->DeleteItem(selected_hive);
|
m_Hives->DeleteItem(selected_hive);
|
||||||
|
|
||||||
m_database->RemoveHiveFromDatabase(hive_name.ToStdString());
|
m_Database->RemoveHiveFromDatabase(hive_name.ToStdString());
|
||||||
|
|
||||||
msg = wxString::Format(
|
msg = wxString::Format(
|
||||||
_("%s and all samples inside %s have been deleted from hives successfully."),
|
_("%s and all samples inside %s have been deleted from hives successfully."),
|
||||||
|
|
@ -1491,9 +1492,9 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto dataset = m_database->FilterDatabaseByHiveName(hive_name.ToStdString(),
|
const auto dataset = m_Database->FilterDatabaseByHiveName(hive_name.ToStdString(),
|
||||||
settings.ShouldShowFileExtension(),
|
settings.ShouldShowFileExtension(),
|
||||||
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
||||||
|
|
||||||
if (dataset.empty())
|
if (dataset.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -1525,8 +1526,8 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto dataset = m_database->FilterDatabaseBySampleName("", settings.ShouldShowFileExtension(),
|
const auto dataset = m_Database->FilterDatabaseBySampleName("", settings.ShouldShowFileExtension(),
|
||||||
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
||||||
|
|
||||||
if (dataset.empty())
|
if (dataset.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -1578,9 +1579,9 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
|
|
||||||
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0);
|
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0);
|
||||||
|
|
||||||
m_database->UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
m_Database->UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
||||||
m_database->UpdateHiveName(matched_sample.ToStdString(),
|
m_Database->UpdateHiveName(matched_sample.ToStdString(),
|
||||||
m_Hives->GetItemText(favorites_hive).ToStdString());
|
m_Hives->GetItemText(favorites_hive).ToStdString());
|
||||||
|
|
||||||
m_Hives->DeleteItem(selected_hive);
|
m_Hives->DeleteItem(selected_hive);
|
||||||
|
|
||||||
|
|
@ -1589,7 +1590,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
|
|
||||||
m_InfoBar->ShowMessage(wxString::Format(_("Removed %s from %s"),
|
m_InfoBar->ShowMessage(wxString::Format(_("Removed %s from %s"),
|
||||||
m_Hives->GetItemText(event.GetItem()),
|
m_Hives->GetItemText(event.GetItem()),
|
||||||
m_database->GetHiveByFilename(matched_sample.ToStdString())),
|
m_Database->GetHiveByFilename(matched_sample.ToStdString())),
|
||||||
wxICON_INFORMATION);
|
wxICON_INFORMATION);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -1649,7 +1650,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
//true = add false = remove
|
//true = add false = remove
|
||||||
bool favorite_add = false;
|
bool favorite_add = false;
|
||||||
|
|
||||||
if (m_database->GetFavoriteColumnValueByFilename(filename) == 1)
|
if (m_Database->GetFavoriteColumnValueByFilename(filename) == 1)
|
||||||
menu.Append(MN_FavoriteSample, _("Remove from hive"), _("Remove the selected sample(s) from hive"));
|
menu.Append(MN_FavoriteSample, _("Remove from hive"), _("Remove the selected sample(s) from hive"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1703,7 +1704,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
filename = settings.ShouldShowFileExtension() ?
|
filename = settings.ShouldShowFileExtension() ?
|
||||||
name.BeforeLast('.').ToStdString() : name.ToStdString();
|
name.BeforeLast('.').ToStdString() : name.ToStdString();
|
||||||
|
|
||||||
db_status = m_database->GetFavoriteColumnValueByFilename(filename);
|
db_status = m_Database->GetFavoriteColumnValueByFilename(filename);
|
||||||
|
|
||||||
// Aleady Added, Do Nothing
|
// Aleady Added, Do Nothing
|
||||||
if (favorite_add && db_status == 1)
|
if (favorite_add && db_status == 1)
|
||||||
|
|
@ -1718,8 +1719,8 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_FILLED_16px)), selected_row, 0);
|
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_FILLED_16px)), selected_row, 0);
|
||||||
|
|
||||||
m_database->UpdateFavoriteColumn(filename, 1);
|
m_Database->UpdateFavoriteColumn(filename, 1);
|
||||||
m_database->UpdateHiveName(filename, hive_name);
|
m_Database->UpdateHiveName(filename, hive_name);
|
||||||
|
|
||||||
for (int i = 0; i < m_Hives->GetChildCount(root); i++)
|
for (int i = 0; i < m_Hives->GetChildCount(root); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -1739,9 +1740,9 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
//Remove From Favorites
|
//Remove From Favorites
|
||||||
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), selected_row, 0);
|
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), selected_row, 0);
|
||||||
|
|
||||||
m_database->UpdateFavoriteColumn(filename, 0);
|
m_Database->UpdateFavoriteColumn(filename, 0);
|
||||||
m_database->UpdateHiveName(filename,
|
m_Database->UpdateHiveName(filename,
|
||||||
m_Hives->GetItemText(favorites_hive).ToStdString());
|
m_Hives->GetItemText(favorites_hive).ToStdString());
|
||||||
|
|
||||||
for (int i = 0; i < m_Hives->GetChildCount(root); i++)
|
for (int i = 0; i < m_Hives->GetChildCount(root); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -1803,7 +1804,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
wxLogDebug("Selected row: %d :: Sample: %s", selected_row, filename);
|
wxLogDebug("Selected row: %d :: Sample: %s", selected_row, filename);
|
||||||
|
|
||||||
m_database->RemoveSampleFromDatabase(filename);
|
m_Database->RemoveSampleFromDatabase(filename);
|
||||||
m_Library->DeleteItem(selected_row);
|
m_Library->DeleteItem(selected_row);
|
||||||
|
|
||||||
for (int j = 0; j < m_Hives->GetChildCount(root); j++)
|
for (int j = 0; j < m_Hives->GetChildCount(root); j++)
|
||||||
|
|
@ -1853,7 +1854,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
std::string multi_selection = settings.ShouldShowFileExtension() ?
|
std::string multi_selection = settings.ShouldShowFileExtension() ?
|
||||||
text_value.BeforeLast('.').ToStdString() : text_value.ToStdString() ;
|
text_value.BeforeLast('.').ToStdString() : text_value.ToStdString() ;
|
||||||
|
|
||||||
m_database->RemoveSampleFromDatabase(multi_selection);
|
m_Database->RemoveSampleFromDatabase(multi_selection);
|
||||||
m_Library->DeleteItem(row);
|
m_Library->DeleteItem(row);
|
||||||
|
|
||||||
for (int j = 0; j < m_Hives->GetChildCount(root); j++)
|
for (int j = 0; j < m_Hives->GetChildCount(root); j++)
|
||||||
|
|
@ -1895,7 +1896,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
wxDataViewItem root = wxDataViewItem(wxNullPtr);
|
wxDataViewItem root = wxDataViewItem(wxNullPtr);
|
||||||
wxDataViewItem container, child;
|
wxDataViewItem container, child;
|
||||||
|
|
||||||
if (m_database->IsTrashed(filename))
|
if (m_Database->IsTrashed(filename))
|
||||||
wxLogDebug(_("Already trashed.."));
|
wxLogDebug(_("Already trashed.."));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1920,11 +1921,11 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
|
|
||||||
files = file_data.GetFilenames();
|
files = file_data.GetFilenames();
|
||||||
|
|
||||||
if (m_database->GetFavoriteColumnValueByFilename(files[i].ToStdString()))
|
if (m_Database->GetFavoriteColumnValueByFilename(files[i].ToStdString()))
|
||||||
{
|
{
|
||||||
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), item_row, 0);
|
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), item_row, 0);
|
||||||
|
|
||||||
m_database->UpdateFavoriteColumn(files[i].ToStdString(), 0);
|
m_Database->UpdateFavoriteColumn(files[i].ToStdString(), 0);
|
||||||
|
|
||||||
for (int j = 0; j < m_Hives->GetChildCount(root); j++)
|
for (int j = 0; j < m_Hives->GetChildCount(root); j++)
|
||||||
{
|
{
|
||||||
|
|
@ -1947,9 +1948,9 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_database->UpdateTrashColumn(files[i].ToStdString(), 1);
|
m_Database->UpdateTrashColumn(files[i].ToStdString(), 1);
|
||||||
m_database->UpdateHiveName(files[i].ToStdString(),
|
m_Database->UpdateHiveName(files[i].ToStdString(),
|
||||||
m_Hives->GetItemText(favorites_hive).ToStdString());
|
m_Hives->GetItemText(favorites_hive).ToStdString());
|
||||||
|
|
||||||
m_Trash->AppendItem(trash_root, text_value);
|
m_Trash->AppendItem(trash_root, text_value);
|
||||||
|
|
||||||
|
|
@ -2057,11 +2058,11 @@ void MainFrame::LoadDatabase()
|
||||||
Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath);
|
Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_database->LoadHivesDatabase(*m_Hives);
|
m_Database->LoadHivesDatabase(*m_Hives);
|
||||||
|
|
||||||
const auto dataset = m_database->LoadSamplesDatabase(*m_Hives, favorites_hive,
|
const auto dataset = m_Database->LoadSamplesDatabase(*m_Hives, favorites_hive,
|
||||||
*m_Trash, trash_root, settings.ShouldShowFileExtension(),
|
*m_Trash, trash_root, settings.ShouldShowFileExtension(),
|
||||||
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
||||||
|
|
||||||
if (dataset.empty())
|
if (dataset.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -2103,7 +2104,7 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event)
|
||||||
m_Trash->GetItemText(selected_trashed_item).BeforeLast('.') :
|
m_Trash->GetItemText(selected_trashed_item).BeforeLast('.') :
|
||||||
m_Trash->GetItemText(selected_trashed_item);
|
m_Trash->GetItemText(selected_trashed_item);
|
||||||
|
|
||||||
m_database->RemoveSampleFromDatabase(trashed_item_name.ToStdString());
|
m_Database->RemoveSampleFromDatabase(trashed_item_name.ToStdString());
|
||||||
|
|
||||||
m_Trash->Delete(selected_trashed_item);
|
m_Trash->Delete(selected_trashed_item);
|
||||||
}
|
}
|
||||||
|
|
@ -2134,15 +2135,15 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event)
|
||||||
|
|
||||||
files = file_data.GetFilenames();
|
files = file_data.GetFilenames();
|
||||||
|
|
||||||
m_database->UpdateTrashColumn(files[i].ToStdString(), 0);
|
m_Database->UpdateTrashColumn(files[i].ToStdString(), 0);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
wxVector<wxVector<wxVariant>> dataset;
|
wxVector<wxVector<wxVariant>> dataset;
|
||||||
|
|
||||||
if (m_database->RestoreFromTrashByFilename(files[i].ToStdString(),
|
if (m_Database->RestoreFromTrashByFilename(files[i].ToStdString(),
|
||||||
dataset, settings.ShouldShowFileExtension(),
|
dataset, settings.ShouldShowFileExtension(),
|
||||||
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px).empty())
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px).empty())
|
||||||
{
|
{
|
||||||
wxLogDebug(_("Error! Database is empty."));
|
wxLogDebug(_("Error! Database is empty."));
|
||||||
}
|
}
|
||||||
|
|
@ -2200,11 +2201,11 @@ void MainFrame::OnDragAndDropToTrash(wxDropFilesEvent& event)
|
||||||
|
|
||||||
files = file_data.GetFilenames();
|
files = file_data.GetFilenames();
|
||||||
|
|
||||||
if (m_database->GetFavoriteColumnValueByFilename(files[i].ToStdString()))
|
if (m_Database->GetFavoriteColumnValueByFilename(files[i].ToStdString()))
|
||||||
{
|
{
|
||||||
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), item_row, 0);
|
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), item_row, 0);
|
||||||
|
|
||||||
m_database->UpdateFavoriteColumn(files[i].ToStdString(), 0);
|
m_Database->UpdateFavoriteColumn(files[i].ToStdString(), 0);
|
||||||
|
|
||||||
for (int j = 0; j < m_Hives->GetChildCount(root); j++)
|
for (int j = 0; j < m_Hives->GetChildCount(root); j++)
|
||||||
{
|
{
|
||||||
|
|
@ -2227,9 +2228,9 @@ void MainFrame::OnDragAndDropToTrash(wxDropFilesEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_database->UpdateTrashColumn(files[i].ToStdString(), 1);
|
m_Database->UpdateTrashColumn(files[i].ToStdString(), 1);
|
||||||
m_database->UpdateHiveName(files[i].ToStdString(),
|
m_Database->UpdateHiveName(files[i].ToStdString(),
|
||||||
m_Hives->GetItemText(favorites_hive).ToStdString());
|
m_Hives->GetItemText(favorites_hive).ToStdString());
|
||||||
|
|
||||||
m_Trash->AppendItem(trash_root, text_value);
|
m_Trash->AppendItem(trash_root, text_value);
|
||||||
|
|
||||||
|
|
@ -2306,7 +2307,7 @@ void MainFrame::OnClickAddHive(wxCommandEvent& event)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Hives->AppendContainer(wxDataViewItem(wxNullPtr), hive_name);
|
m_Hives->AppendContainer(wxDataViewItem(wxNullPtr), hive_name);
|
||||||
m_database->InsertIntoHives(hive_name.ToStdString());
|
m_Database->InsertIntoHives(hive_name.ToStdString());
|
||||||
|
|
||||||
msg = wxString::Format(_("%s added to Hives."), hive_name);
|
msg = wxString::Format(_("%s added to Hives."), hive_name);
|
||||||
}
|
}
|
||||||
|
|
@ -2374,7 +2375,7 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
m_Hives->DeleteItem(selected_item);
|
m_Hives->DeleteItem(selected_item);
|
||||||
|
|
||||||
m_database->RemoveHiveFromDatabase(hive_name.ToStdString());
|
m_Database->RemoveHiveFromDatabase(hive_name.ToStdString());
|
||||||
msg = wxString::Format(_("%s deleted from hives successfully."), hive_name);
|
msg = wxString::Format(_("%s deleted from hives successfully."), hive_name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -2414,9 +2415,9 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event)
|
||||||
|
|
||||||
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0);
|
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0);
|
||||||
|
|
||||||
m_database->UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
m_Database->UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
||||||
m_database->UpdateHiveName(matched_sample.ToStdString(),
|
m_Database->UpdateHiveName(matched_sample.ToStdString(),
|
||||||
m_Hives->GetItemText(favorites_hive).ToStdString());
|
m_Hives->GetItemText(favorites_hive).ToStdString());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -2428,7 +2429,7 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event)
|
||||||
m_Hives->DeleteChildren(selected_item);
|
m_Hives->DeleteChildren(selected_item);
|
||||||
m_Hives->DeleteItem(selected_item);
|
m_Hives->DeleteItem(selected_item);
|
||||||
|
|
||||||
m_database->RemoveHiveFromDatabase(hive_name.ToStdString());
|
m_Database->RemoveHiveFromDatabase(hive_name.ToStdString());
|
||||||
|
|
||||||
msg = wxString::Format(_("%s and all samples inside %s have been deleted from hives successfully."),
|
msg = wxString::Format(_("%s and all samples inside %s have been deleted from hives successfully."),
|
||||||
hive_name, hive_name);
|
hive_name, hive_name);
|
||||||
|
|
@ -2483,15 +2484,15 @@ void MainFrame::OnClickRestoreTrashItem(wxCommandEvent& event)
|
||||||
|
|
||||||
files = file_data.GetFilenames();
|
files = file_data.GetFilenames();
|
||||||
|
|
||||||
m_database->UpdateTrashColumn(files[i].ToStdString(), 0);
|
m_Database->UpdateTrashColumn(files[i].ToStdString(), 0);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
wxVector<wxVector<wxVariant>> dataset;
|
wxVector<wxVector<wxVariant>> dataset;
|
||||||
|
|
||||||
if (m_database->RestoreFromTrashByFilename(files[i].ToStdString(), dataset,
|
if (m_Database->RestoreFromTrashByFilename(files[i].ToStdString(), dataset,
|
||||||
settings.ShouldShowFileExtension(),
|
settings.ShouldShowFileExtension(),
|
||||||
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px).empty())
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px).empty())
|
||||||
{
|
{
|
||||||
wxLogDebug(_("Error! Database is empty."));
|
wxLogDebug(_("Error! Database is empty."));
|
||||||
}
|
}
|
||||||
|
|
@ -2520,8 +2521,8 @@ void MainFrame::OnDoSearch(wxCommandEvent& event)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto dataset = m_database->FilterDatabaseBySampleName(search, settings.ShouldShowFileExtension(),
|
const auto dataset = m_Database->FilterDatabaseBySampleName(search, settings.ShouldShowFileExtension(),
|
||||||
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
||||||
|
|
||||||
if (dataset.empty())
|
if (dataset.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -2651,14 +2652,14 @@ MainFrame::GetFilenamePathAndExtension(const wxString& selected, bool checkExten
|
||||||
wxString path;
|
wxString path;
|
||||||
std::string extension, filename;
|
std::string extension, filename;
|
||||||
|
|
||||||
wxString filename_with_extension = m_database->GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
wxString filename_with_extension = m_Database->GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
wxString filename_without_extension = m_database->GetSamplePathByFilename(selected.ToStdString());
|
wxString filename_without_extension = m_Database->GetSamplePathByFilename(selected.ToStdString());
|
||||||
|
|
||||||
if (checkExtension)
|
if (checkExtension)
|
||||||
{
|
{
|
||||||
extension = settings.ShouldShowFileExtension() ?
|
extension = settings.ShouldShowFileExtension() ?
|
||||||
m_database->GetSampleFileExtension(selected.ToStdString()) :
|
m_Database->GetSampleFileExtension(selected.ToStdString()) :
|
||||||
m_database->GetSampleFileExtension(selected.BeforeLast('.').ToStdString());
|
m_Database->GetSampleFileExtension(selected.BeforeLast('.').ToStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
path = selected.Contains(wxString::Format(".%s", extension)) ?
|
path = selected.Contains(wxString::Format(".%s", extension)) ?
|
||||||
|
|
@ -2914,7 +2915,7 @@ void MainFrame::OnRecieveLoopPoints(SampleHive::SH_LoopPointsEvent& event)
|
||||||
wxLogDebug("%s Event processed successfully..", __FUNCTION__);
|
wxLogDebug("%s Event processed successfully..", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnRecieveStatusBarStatus(SampleHive::SH_SetStatusBarMessageEvent& event)
|
void MainFrame::OnRecieveStatusBarStatus(SampleHive::SH_StatusBarMessageEvent& event)
|
||||||
{
|
{
|
||||||
std::pair<wxString, int> status = event.GetMessageAndSection();
|
std::pair<wxString, int> status = event.GetMessageAndSection();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Database.hpp"
|
||||||
#include "WaveformViewer.hpp"
|
#include "WaveformViewer.hpp"
|
||||||
#include "SampleHiveConfig.hpp"
|
#include "SampleHiveConfig.hpp"
|
||||||
#include "SH_Event.hpp"
|
#include "SH_Event.hpp"
|
||||||
|
|
@ -66,8 +67,6 @@
|
||||||
#include <taglib/tstring.h>
|
#include <taglib/tstring.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Database.hpp"
|
|
||||||
|
|
||||||
struct FileInfo
|
struct FileInfo
|
||||||
{
|
{
|
||||||
wxString Path;
|
wxString Path;
|
||||||
|
|
@ -173,6 +172,9 @@ class MainFrame : public wxFrame
|
||||||
// Timer
|
// Timer
|
||||||
wxTimer* m_Timer;
|
wxTimer* m_Timer;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
std::unique_ptr<Database> m_Database;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// FileSystemWatcher
|
// FileSystemWatcher
|
||||||
wxFileSystemWatcher* m_FsWatcher;
|
wxFileSystemWatcher* m_FsWatcher;
|
||||||
|
|
@ -183,7 +185,6 @@ class MainFrame : public wxFrame
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
wxSystemAppearance m_Theme = wxSystemSettings::GetAppearance();
|
wxSystemAppearance m_Theme = wxSystemSettings::GetAppearance();
|
||||||
|
|
||||||
std::unique_ptr<Database> m_database;
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
bool bAutoplay = false;
|
bool bAutoplay = false;
|
||||||
|
|
@ -273,7 +274,7 @@ class MainFrame : public wxFrame
|
||||||
// Recieve custom events
|
// Recieve custom events
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void OnRecieveLoopPoints(SampleHive::SH_LoopPointsEvent& event);
|
void OnRecieveLoopPoints(SampleHive::SH_LoopPointsEvent& event);
|
||||||
void OnRecieveStatusBarStatus(SampleHive::SH_SetStatusBarMessageEvent& event);
|
void OnRecieveStatusBarStatus(SampleHive::SH_StatusBarMessageEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void LoadDatabase();
|
void LoadDatabase();
|
||||||
|
|
|
||||||
|
|
@ -41,29 +41,42 @@ namespace SampleHive
|
||||||
|
|
||||||
// wxDEFINE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, SH_MediaEvent);
|
// wxDEFINE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, SH_MediaEvent);
|
||||||
|
|
||||||
SH_SetStatusBarMessageEvent::SH_SetStatusBarMessageEvent(wxEventType eventType, int winId)
|
SH_StatusBarMessageEvent::SH_StatusBarMessageEvent(wxEventType eventType, int winId)
|
||||||
: wxCommandEvent(eventType, winId)
|
: wxCommandEvent(eventType, winId)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SH_SetStatusBarMessageEvent::~SH_SetStatusBarMessageEvent()
|
SH_StatusBarMessageEvent::~SH_StatusBarMessageEvent()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_MESSAGE_UPDATED, SH_SetStatusBarMessageEvent);
|
wxDEFINE_EVENT(SH_EVT_STATUSBAR_MESSAGE_UPDATED, SH_StatusBarMessageEvent);
|
||||||
|
|
||||||
// SH_TimerEvent::SH_TimerEvent(wxEventType eventType, int winId)
|
// SH_InfoBarMessageEvent::SH_InfoBarMessageEvent(wxEventType eventType, int winId)
|
||||||
// : wxCommandEvent(eventType, winId)
|
// : wxCommandEvent(eventType, winId)
|
||||||
// {
|
// {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// SH_TimerEvent::~SH_TimerEvent()
|
// SH_InfoBarMessageEvent::~SH_InfoBarMessageEvent()
|
||||||
// {
|
// {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// wxDEFINE_EVENT(SH_EVT_TIMER_STATUS_UPDATED, SH_TimerEvent);
|
// wxDEFINE_EVENT(SH_EVT_INFOBAR_MESSAGE_UPDATED, SH_InfoBarMessageEvent);
|
||||||
|
|
||||||
|
// SH_TimerEvent::SH_TimerEvent(wxEventType eventType, int winId)
|
||||||
|
// : wxCommandEvent(eventType, winId)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// SH_TimerEvent::~SH_TimerEvent()
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// wxDEFINE_EVENT(SH_EVT_TIMER_STATUS_UPDATED, SH_TimerEvent);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,14 +64,14 @@ namespace SampleHive
|
||||||
|
|
||||||
// wxDECLARE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, SH_MediaEvent);
|
// wxDECLARE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, SH_MediaEvent);
|
||||||
|
|
||||||
class SH_SetStatusBarMessageEvent : public wxCommandEvent
|
class SH_StatusBarMessageEvent : public wxCommandEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SH_SetStatusBarMessageEvent(wxEventType eventType, int winId);
|
SH_StatusBarMessageEvent(wxEventType eventType, int winId);
|
||||||
~SH_SetStatusBarMessageEvent();
|
~SH_StatusBarMessageEvent();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual wxEvent* Clone() const { return new SH_SetStatusBarMessageEvent(*this); }
|
virtual wxEvent* Clone() const { return new SH_StatusBarMessageEvent(*this); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::pair<wxString, int> GetMessageAndSection() const { return { m_Msg, m_Section }; }
|
std::pair<wxString, int> GetMessageAndSection() const { return { m_Msg, m_Section }; }
|
||||||
|
|
@ -82,25 +82,45 @@ namespace SampleHive
|
||||||
int m_Section;
|
int m_Section;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_MESSAGE_UPDATED, SH_SetStatusBarMessageEvent);
|
wxDECLARE_EVENT(SH_EVT_STATUSBAR_MESSAGE_UPDATED, SH_StatusBarMessageEvent);
|
||||||
|
|
||||||
// class SH_TimerEvent : public wxCommandEvent
|
// class SH_InfoBarMessageEvent : public wxCommandEvent
|
||||||
// {
|
// {
|
||||||
// public:
|
// public:
|
||||||
// SH_TimerEvent(wxEventType eventType, int winId);
|
// SH_InfoBarMessageEvent(wxEventType eventType, int winId);
|
||||||
// ~SH_TimerEvent();
|
// ~SH_InfoBarMessageEvent();
|
||||||
|
|
||||||
// public:
|
// public:
|
||||||
// virtual wxEvent* Clone() const { return new SH_TimerEvent(*this); }
|
// virtual wxEvent* Clone() const { return new SH_InfoBarMessageEvent(*this); }
|
||||||
|
|
||||||
// public:
|
// public:
|
||||||
// std::pair<int, bool> GetSecondsAndMode() const { return { m_Seconds, m_Mode }; }
|
// std::pair<wxString, int> GetInfoBarMessage() const { return { m_Msg, m_Mode }; }
|
||||||
// void SetSecondsAndMode(std::pair<int, bool> timerStatus) { m_Seconds = timerStatus.first; m_Mode = timerStatus.second; }
|
// void SetInfoBarMessage(std::pair<wxString, int> infoBarMessageEvent) { m_Msg = infoBarMessageEvent.first; m_Mode = infoBarMessageEvent.second; }
|
||||||
|
|
||||||
// private:
|
// private:
|
||||||
// int m_Seconds;
|
// wxString m_Msg;
|
||||||
// bool m_Mode;
|
// int m_Mode;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// wxDECLARE_EVENT(SH_EVT_TIMER_STATUS_UPDATED, SH_TimerEvent);
|
// wxDECLARE_EVENT(SH_EVT_INFOBAR_MESSAGE_UPDATED, SH_InfoBarMessageEvent);
|
||||||
|
|
||||||
|
// class SH_TimerEvent : public wxCommandEvent
|
||||||
|
// {
|
||||||
|
// public:
|
||||||
|
// SH_TimerEvent(wxEventType eventType, int winId);
|
||||||
|
// ~SH_TimerEvent();
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// virtual wxEvent* Clone() const { return new SH_TimerEvent(*this); }
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// std::pair<int, bool> GetSecondsAndMode() const { return { m_Seconds, m_Mode }; }
|
||||||
|
// void SetSecondsAndMode(std::pair<int, bool> timerStatus) { m_Seconds = timerStatus.first; m_Mode = timerStatus.second; }
|
||||||
|
|
||||||
|
// private:
|
||||||
|
// int m_Seconds;
|
||||||
|
// bool m_Mode;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// wxDECLARE_EVENT(SH_EVT_TIMER_STATUS_UPDATED, SH_TimerEvent);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,8 @@ void TagEditor::OnClickCustomTagButton(wxCommandEvent& event)
|
||||||
|
|
||||||
void TagEditor::OnClickApply(wxCommandEvent& event)
|
void TagEditor::OnClickApply(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Database db(m_InfoBar, m_DatabaseFilepath);
|
// Database db(m_InfoBar, m_DatabaseFilepath);
|
||||||
|
Database db(m_DatabaseFilepath);
|
||||||
|
|
||||||
wxString title = m_TitleText->GetValue();
|
wxString title = m_TitleText->GetValue();
|
||||||
wxString artist = m_ArtistText->GetValue();
|
wxString artist = m_ArtistText->GetValue();
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ WaveformViewer::WaveformViewer(wxWindow* parentFrame, wxWindow* window, wxDataVi
|
||||||
wxMediaCtrl& mediaCtrl, Database& database,
|
wxMediaCtrl& mediaCtrl, Database& database,
|
||||||
const std::string& configFilepath, const std::string& databaseFilepath)
|
const std::string& configFilepath, const std::string& databaseFilepath)
|
||||||
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE),
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE),
|
||||||
m_ParentFrame(parentFrame), m_Window(window), m_Library(library), m_database(database), m_MediaCtrl(mediaCtrl),
|
m_ParentFrame(parentFrame), m_Window(window), m_Database(database), m_Library(library), m_MediaCtrl(mediaCtrl),
|
||||||
m_ConfigFilepath(configFilepath), m_DatabaseFilepath(databaseFilepath)
|
m_ConfigFilepath(configFilepath), m_DatabaseFilepath(databaseFilepath)
|
||||||
{
|
{
|
||||||
this->SetDoubleBuffered(true);
|
this->SetDoubleBuffered(true);
|
||||||
|
|
@ -116,7 +116,7 @@ void WaveformViewer::RenderPlayhead(wxDC& dc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
||||||
std::string path = m_database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
Tags tags(path);
|
Tags tags(path);
|
||||||
|
|
||||||
|
|
@ -158,12 +158,12 @@ void WaveformViewer::UpdateWaveformBitmap()
|
||||||
|
|
||||||
wxString selection = m_Library.GetTextValue(selected_row, 1);
|
wxString selection = m_Library.GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
wxString filepath_with_extension = m_database.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
wxString filepath_with_extension = m_Database.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||||
wxString filepath_without_extension = m_database.GetSamplePathByFilename(selection.ToStdString());
|
wxString filepath_without_extension = m_Database.GetSamplePathByFilename(selection.ToStdString());
|
||||||
|
|
||||||
std::string extension = settings.ShouldShowFileExtension() ?
|
std::string extension = settings.ShouldShowFileExtension() ?
|
||||||
m_database.GetSampleFileExtension(selection.ToStdString()) :
|
m_Database.GetSampleFileExtension(selection.ToStdString()) :
|
||||||
m_database.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
m_Database.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
wxString path = selection.Contains(wxString::Format(".%s", extension)) ?
|
wxString path = selection.Contains(wxString::Format(".%s", extension)) ?
|
||||||
filepath_with_extension : filepath_without_extension;
|
filepath_with_extension : filepath_without_extension;
|
||||||
|
|
@ -296,7 +296,7 @@ void WaveformViewer::OnMouseMotion(wxMouseEvent& event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
||||||
std::string path = m_database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
Tags tags(path);
|
Tags tags(path);
|
||||||
|
|
||||||
|
|
@ -336,7 +336,7 @@ void WaveformViewer::OnMouseLeftButtonDown(wxMouseEvent& event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
||||||
std::string path = m_database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
Tags tags(path);
|
Tags tags(path);
|
||||||
|
|
||||||
|
|
@ -385,7 +385,7 @@ void WaveformViewer::OnMouseLeftButtonUp(wxMouseEvent& event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
||||||
std::string path = m_database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
Tags tags(path);
|
Tags tags(path);
|
||||||
|
|
||||||
|
|
@ -455,7 +455,7 @@ void WaveformViewer::SendLoopPoints()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
||||||
std::string path = m_database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
Tags tags(path);
|
Tags tags(path);
|
||||||
|
|
||||||
|
|
@ -477,7 +477,7 @@ void WaveformViewer::SendLoopPoints()
|
||||||
|
|
||||||
void WaveformViewer::SendStatusBarStatus(const wxString& msg, int section)
|
void WaveformViewer::SendStatusBarStatus(const wxString& msg, int section)
|
||||||
{
|
{
|
||||||
SampleHive::SH_SetStatusBarMessageEvent event(SampleHive::SH_EVT_STATUSBAR_MESSAGE_UPDATED, this->GetId());
|
SampleHive::SH_StatusBarMessageEvent event(SampleHive::SH_EVT_STATUSBAR_MESSAGE_UPDATED, this->GetId());
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
|
|
||||||
event.SetMessageAndSection({ msg, section });
|
event.SetMessageAndSection({ msg, section });
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,8 @@ class WaveformViewer : public wxPanel
|
||||||
wxWindow* m_ParentFrame;
|
wxWindow* m_ParentFrame;
|
||||||
wxWindow* m_Window;
|
wxWindow* m_Window;
|
||||||
|
|
||||||
|
Database& m_Database;
|
||||||
wxDataViewListCtrl& m_Library;
|
wxDataViewListCtrl& m_Library;
|
||||||
Database& m_database;
|
|
||||||
wxMediaCtrl& m_MediaCtrl;
|
wxMediaCtrl& m_MediaCtrl;
|
||||||
|
|
||||||
const std::string& m_ConfigFilepath;
|
const std::string& m_ConfigFilepath;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue