Added ability to install SampleHive, added `_()` macro for translation support, much more clearer log messages and general clean up.
This commit is contained in:
parent
293821be99
commit
953b81d753
28
README.md
28
README.md
|
|
@ -21,38 +21,50 @@ On Arch based distributions,
|
|||
sudo pacman -S wxgtk3 wxsvg sqlite taglib yaml-cpp
|
||||
```
|
||||
|
||||
On Ubuntu and Ubuntu based distributions,
|
||||
On Debian, Ubuntu and distributions based the on two,
|
||||
|
||||
```
|
||||
sudo apt install libwxbase3.0-dev libwxgtk-media3.0-gtk3-dev libwxgtk3.0-gtk3-dev wx3.0-headers libwxsvg-dev libwxsvg3 libsqlite3-dev libyaml-cpp-dev libtagc0-dev libtag1-dev libtagc0 libexif-dev
|
||||
sudo apt install libwxbase3.0-dev libwxgtk-media3.0-gtk3-dev libwxgtk3.0-gtk3-dev wx3.0-headers libwxsvg-dev libwxsvg3 libsqlite3-dev libyaml-cpp-dev libtagc0-dev libtag1-dev libtagc0 libexif-dev libpango1.0-dev
|
||||
```
|
||||
|
||||
You might also need to install `git`, `meson` and `g++` as well, if you don't already have them installed in order to compile SampleHive.
|
||||
You might also need to install `git`, `meson` and `g++` as well, if you don't already have them installed in order to build SampleHive.
|
||||
|
||||
*NOTE:* On Debian and Debian based distributions you also have to install `libwxgtk-media3.0-dev`
|
||||
|
||||
## How to build SampleHive?
|
||||
|
||||
Download the source code from this repository or use a git clone:
|
||||
|
||||
```
|
||||
git clone https://gitlab.com/apoorv569/sample-hive
|
||||
git clone https://gitlab.com/samplehive/sample-hive
|
||||
cd sample-hive
|
||||
meson build
|
||||
ninja -C build
|
||||
meson build -Dprefix=/tmp/SampleHive
|
||||
ninja -C build install
|
||||
```
|
||||
|
||||
This will install SampleHive under `/tmp/SampleHive`.
|
||||
|
||||
The configuration file will be placed under `~/.config/SampleHive/config.yaml` and the database file will be placed under `~/.local/share/SampleHive/sample.hive`
|
||||
|
||||
*NOTE:* If you don't provide the `-Dprefix=/tmp/SampleHive` by default it will be installed under `/usr/local`. You can set the prefix to anything you want.
|
||||
|
||||
## How to run SampleHive?
|
||||
|
||||
To run SampleHive:
|
||||
|
||||
If you provided a prefix, you can go the prefix directory then go to the `bin` directory and run the SampleHive binary, for example, assuming the prefix was set to `/tmp/SampleHive`
|
||||
|
||||
```
|
||||
cd build
|
||||
cd /tmp/SampleHive/bin
|
||||
./SampleHive
|
||||
```
|
||||
|
||||
If you didn't provide a prefix, you can find SampleHive in your menu system or run launcher and run SampleHive as you would run any other program on you system.
|
||||
|
||||
## Are there any keybindings for SampleHive?
|
||||
|
||||
// TODO
|
||||
|
||||
## Can I configure SampleHive?
|
||||
|
||||
SampleHive comes with a `config.yaml` file, that you can edit to change some settings for it.
|
||||
SampleHive comes with a `config.yaml` file, that is placed under `~/.config/SampleHive/config.yaml`, that you can edit to change some settings for it.
|
||||
|
|
|
|||
40
meson.build
40
meson.build
|
|
@ -4,6 +4,30 @@ project('SampleHive', 'cpp',
|
|||
default_options : ['warning_level=1',
|
||||
'cpp_std=c++11'])
|
||||
|
||||
meson_src_root = meson.current_source_dir()
|
||||
|
||||
# Save important directories
|
||||
prefix = get_option('prefix')
|
||||
bindir = prefix / get_option('bindir')
|
||||
libdir = prefix / get_option('libdir')
|
||||
datadir = prefix / get_option('datadir')
|
||||
samplehive_datadir = datadir / 'SampleHive'
|
||||
|
||||
# Create configuration data
|
||||
config_data = configuration_data()
|
||||
config_data.set_quoted('PREFIX', prefix)
|
||||
config_data.set_quoted('BINDIR', bindir)
|
||||
config_data.set_quoted('LIBDIR', libdir)
|
||||
config_data.set_quoted('DATADIR', datadir)
|
||||
config_data.set_quoted('SAMPLEHIVE_DATADIR', samplehive_datadir)
|
||||
|
||||
# Create samplehive-config.h based on configuration
|
||||
config_h = configure_file(
|
||||
output: 'SampleHiveConfig.hpp',
|
||||
configuration: config_data,
|
||||
)
|
||||
|
||||
# Source files to be compiled
|
||||
src = [
|
||||
|
||||
'src/App.cpp',
|
||||
|
|
@ -11,10 +35,10 @@ src = [
|
|||
'src/SettingsDialog.cpp',
|
||||
'src/TagEditorDialog.cpp',
|
||||
'src/Database.cpp',
|
||||
'src/Serialize.cpp',
|
||||
'src/TreeItemDialog.cpp',
|
||||
'src/Tags.cpp',
|
||||
'src/Sample.cpp',
|
||||
'src/Serialize.cpp',
|
||||
'src/Tags.cpp',
|
||||
|
||||
]
|
||||
|
||||
wxconfig = find_program(['wx-config-gtk3', 'wx-config'])
|
||||
|
|
@ -27,14 +51,22 @@ foreach module : wx_modules
|
|||
wx_libs += run_command(wxconfig, '--libs', module).stdout().strip().split()
|
||||
endforeach
|
||||
|
||||
# Dependencies
|
||||
wx = dependency('wxwidgets', version: '>=3.0.4')
|
||||
wxsvg = dependency('libwxsvg')
|
||||
taglib = dependency('taglib', version: '>=1.11')
|
||||
sqlite3 = dependency('sqlite3')
|
||||
yaml = dependency('yaml-cpp')
|
||||
|
||||
install_subdir(
|
||||
'assets',
|
||||
install_dir: samplehive_datadir,
|
||||
exclude_directories: 'screenshots'
|
||||
)
|
||||
|
||||
executable('SampleHive',
|
||||
sources: src,
|
||||
cpp_args: [wx_cxx_flags],
|
||||
link_args: [wx_libs],
|
||||
dependencies : [wx, wxsvg, taglib, sqlite3, yaml])
|
||||
dependencies: [wx, wxsvg, taglib, sqlite3, yaml],
|
||||
install: true)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
#include "App.hpp"
|
||||
#include "SampleHiveConfig.hpp"
|
||||
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/defs.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/splash.h>
|
||||
|
||||
#define SPLASH_LOGO SAMPLEHIVE_DATADIR "/assets/logo/logo-hive_768x432.png"
|
||||
|
||||
wxIMPLEMENT_APP(App);
|
||||
|
||||
App::App()
|
||||
|
|
@ -27,7 +30,7 @@ bool App::OnInit()
|
|||
wxBitmap bitmap;
|
||||
wxSplashScreen* splash;
|
||||
|
||||
if (bitmap.LoadFile("../assets/logo/logo-hive_768x432.png", wxBITMAP_TYPE_PNG))
|
||||
if (bitmap.LoadFile(SPLASH_LOGO, wxBITMAP_TYPE_PNG))
|
||||
{
|
||||
splash = new wxSplashScreen(bitmap,
|
||||
wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT,
|
||||
|
|
|
|||
104
src/Database.cpp
104
src/Database.cpp
|
|
@ -23,7 +23,7 @@ Database::~Database()
|
|||
|
||||
}
|
||||
|
||||
void Database::CreateTableSamples()
|
||||
void Database::CreateTableSamples(const std::string& dbPath)
|
||||
{
|
||||
/* Create SQL statement */
|
||||
std::string samples = "CREATE TABLE IF NOT EXISTS SAMPLES("
|
||||
|
|
@ -42,7 +42,7 @@ void Database::CreateTableSamples()
|
|||
|
||||
try
|
||||
{
|
||||
if (sqlite3_open("sample.hive", &m_Database) != SQLITE_OK)
|
||||
if (sqlite3_open(dbPath.c_str(), &m_Database) != SQLITE_OK)
|
||||
{
|
||||
wxLogDebug("Error opening DB");
|
||||
throw sqlite3_errmsg(m_Database);
|
||||
|
|
@ -63,7 +63,7 @@ void Database::CreateTableSamples()
|
|||
}
|
||||
else
|
||||
{
|
||||
wxLogDebug("Table created successfully.");
|
||||
wxLogDebug("Samples table created successfully.");
|
||||
}
|
||||
|
||||
rc = sqlite3_close(m_Database);
|
||||
|
|
@ -79,14 +79,14 @@ void Database::CreateTableSamples()
|
|||
}
|
||||
}
|
||||
|
||||
void Database::CreateTableHives()
|
||||
void Database::CreateTableHives(const std::string& dbPath)
|
||||
{
|
||||
/* Create SQL statement */
|
||||
std::string hives = "CREATE TABLE IF NOT EXISTS HIVES(HIVE TEXT NOT NULL);";
|
||||
|
||||
try
|
||||
{
|
||||
if (sqlite3_open("sample.hive", &m_Database) != SQLITE_OK)
|
||||
if (sqlite3_open(dbPath.c_str(), &m_Database) != SQLITE_OK)
|
||||
{
|
||||
wxLogDebug("Error opening DB");
|
||||
throw sqlite3_errmsg(m_Database);
|
||||
|
|
@ -107,7 +107,7 @@ void Database::CreateTableHives()
|
|||
}
|
||||
else
|
||||
{
|
||||
wxLogDebug("Table created successfully.");
|
||||
wxLogDebug("Hives table created successfully.");
|
||||
}
|
||||
|
||||
rc = sqlite3_close(m_Database);
|
||||
|
|
@ -124,11 +124,11 @@ void Database::CreateTableHives()
|
|||
}
|
||||
|
||||
//Loops through a Sample array and adds them to the database
|
||||
void Database::InsertIntoSamples(std::vector<Sample> samples)
|
||||
void Database::InsertIntoSamples(const std::string& dbPath, std::vector<Sample> samples)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sqlite3_open("sample.hive", &m_Database) != SQLITE_OK)
|
||||
if (sqlite3_open(dbPath.c_str(), &m_Database) != SQLITE_OK)
|
||||
{
|
||||
wxLogDebug("Error opening DB");
|
||||
throw sqlite3_errmsg(m_Database);
|
||||
|
|
@ -235,11 +235,11 @@ void Database::InsertIntoSamples(std::vector<Sample> samples)
|
|||
}
|
||||
}
|
||||
|
||||
void Database::InsertIntoHives(const std::string& hiveName)
|
||||
void Database::InsertIntoHives(const std::string& dbPath, const std::string& hiveName)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sqlite3_open("sample.hive", &m_Database) != SQLITE_OK)
|
||||
if (sqlite3_open(dbPath.c_str(), &m_Database) != SQLITE_OK)
|
||||
{
|
||||
wxLogDebug("Error opening DB");
|
||||
throw sqlite3_errmsg(m_Database);
|
||||
|
|
@ -333,11 +333,11 @@ void Database::InsertIntoHives(const std::string& hiveName)
|
|||
}
|
||||
}
|
||||
|
||||
void Database::UpdateHive(const std::string& hiveOldName, const std::string& hiveNewName)
|
||||
void Database::UpdateHive(const std::string& dbPath, const std::string& hiveOldName, const std::string& hiveNewName)
|
||||
{
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string update = "UPDATE HIVES SET HIVE = ? WHERE HIVE = ?;";
|
||||
|
||||
|
|
@ -374,11 +374,11 @@ void Database::UpdateHive(const std::string& hiveOldName, const std::string& hiv
|
|||
}
|
||||
}
|
||||
|
||||
void Database::UpdateHiveName(const std::string& filename, const std::string& hiveName)
|
||||
void Database::UpdateHiveName(const std::string& dbPath, const std::string& filename, const std::string& hiveName)
|
||||
{
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string update = "UPDATE SAMPLES SET HIVE = ? WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -413,11 +413,11 @@ void Database::UpdateHiveName(const std::string& filename, const std::string& hi
|
|||
}
|
||||
}
|
||||
|
||||
void Database::UpdateFavoriteColumn(const std::string& filename, int value)
|
||||
void Database::UpdateFavoriteColumn(const std::string& dbPath, const std::string& filename, int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string update = "UPDATE SAMPLES SET FAVORITE = ? WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -452,11 +452,11 @@ void Database::UpdateFavoriteColumn(const std::string& filename, int value)
|
|||
}
|
||||
}
|
||||
|
||||
void Database::UpdateSamplePack(const std::string& filename, const std::string& samplePack)
|
||||
void Database::UpdateSamplePack(const std::string& dbPath, const std::string& filename, const std::string& samplePack)
|
||||
{
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string update = "UPDATE SAMPLES SET SAMPLEPACK = ? WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -491,11 +491,11 @@ void Database::UpdateSamplePack(const std::string& filename, const std::string&
|
|||
}
|
||||
}
|
||||
|
||||
void Database::UpdateSampleType(const std::string& filename, const std::string& type)
|
||||
void Database::UpdateSampleType(const std::string& dbPath, const std::string& filename, const std::string& type)
|
||||
{
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string update = "UPDATE SAMPLES SET TYPE = ? WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -530,13 +530,13 @@ void Database::UpdateSampleType(const std::string& filename, const std::string&
|
|||
}
|
||||
}
|
||||
|
||||
std::string Database::GetSampleType(const std::string& filename)
|
||||
std::string Database::GetSampleType(const std::string& dbPath, const std::string& filename)
|
||||
{
|
||||
std::string type;
|
||||
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string select = "SELECT TYPE FROM SAMPLES WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -575,13 +575,13 @@ std::string Database::GetSampleType(const std::string& filename)
|
|||
return type;
|
||||
}
|
||||
|
||||
int Database::GetFavoriteColumnValueByFilename(const std::string& filename)
|
||||
int Database::GetFavoriteColumnValueByFilename(const std::string& dbPath, const std::string& filename)
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string select = "SELECT FAVORITE FROM SAMPLES WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -619,13 +619,13 @@ int Database::GetFavoriteColumnValueByFilename(const std::string& filename)
|
|||
return value;
|
||||
}
|
||||
|
||||
std::string Database::GetHiveByFilename(const std::string& filename)
|
||||
std::string Database::GetHiveByFilename(const std::string& dbPath, const std::string& filename)
|
||||
{
|
||||
std::string hive;
|
||||
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string select = "SELECT HIVE FROM SAMPLES WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -664,11 +664,11 @@ std::string Database::GetHiveByFilename(const std::string& filename)
|
|||
return hive;
|
||||
}
|
||||
|
||||
void Database::RemoveSampleFromDatabase(const std::string& filename)
|
||||
void Database::RemoveSampleFromDatabase(const std::string& dbPath, const std::string& filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string remove = "DELETE FROM SAMPLES WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -703,11 +703,11 @@ void Database::RemoveSampleFromDatabase(const std::string& filename)
|
|||
}
|
||||
}
|
||||
|
||||
void Database::RemoveHiveFromDatabase(const std::string& hiveName)
|
||||
void Database::RemoveHiveFromDatabase(const std::string& dbPath, const std::string& hiveName)
|
||||
{
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string remove = "DELETE FROM HIVES WHERE HIVE = ?;";
|
||||
|
||||
|
|
@ -742,13 +742,13 @@ void Database::RemoveHiveFromDatabase(const std::string& hiveName)
|
|||
}
|
||||
}
|
||||
|
||||
std::string Database::GetSamplePathByFilename(const std::string& filename)
|
||||
std::string Database::GetSamplePathByFilename(const std::string& dbPath, const std::string& filename)
|
||||
{
|
||||
std::string path;
|
||||
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string select = "SELECT PATH FROM SAMPLES WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -786,13 +786,13 @@ std::string Database::GetSamplePathByFilename(const std::string& filename)
|
|||
return path;
|
||||
}
|
||||
|
||||
std::string Database::GetSampleFileExtension(const std::string& filename)
|
||||
std::string Database::GetSampleFileExtension(const std::string& dbPath, const std::string& filename)
|
||||
{
|
||||
std::string extension;
|
||||
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string select = "SELECT EXTENSION FROM SAMPLES WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -831,7 +831,7 @@ std::string Database::GetSampleFileExtension(const std::string& filename)
|
|||
}
|
||||
|
||||
wxVector<wxVector<wxVariant>>
|
||||
Database::LoadSamplesDatabase(wxVector<wxVector<wxVariant>>& vecSet,
|
||||
Database::LoadSamplesDatabase(const std::string& dbPath, wxVector<wxVector<wxVariant>>& vecSet,
|
||||
// wxTreeCtrl& favorite_tree, wxTreeItemId& favorite_item,
|
||||
wxDataViewTreeCtrl& favorite_tree, wxDataViewItem& favorite_item,
|
||||
wxTreeCtrl& trash_tree, wxTreeItemId& trash_item, bool show_extension,
|
||||
|
|
@ -839,7 +839,7 @@ Database::LoadSamplesDatabase(wxVector<wxVector<wxVariant>>& vecSet,
|
|||
{
|
||||
try
|
||||
{
|
||||
if (sqlite3_open("sample.hive", &m_Database) != SQLITE_OK)
|
||||
if (sqlite3_open(dbPath.c_str(), &m_Database) != SQLITE_OK)
|
||||
{
|
||||
wxLogDebug("Error opening DB");
|
||||
throw sqlite3_errmsg(m_Database);
|
||||
|
|
@ -989,13 +989,13 @@ Database::LoadSamplesDatabase(wxVector<wxVector<wxVariant>>& vecSet,
|
|||
}
|
||||
|
||||
wxVector<wxVector<wxVariant>>
|
||||
Database::FilterDatabaseBySampleName(wxVector<wxVector<wxVariant>>& sampleVec,
|
||||
Database::FilterDatabaseBySampleName(const std::string& dbPath, wxVector<wxVector<wxVariant>>& sampleVec,
|
||||
const std::string& sampleName, bool show_extension,
|
||||
const std::string& icon_star_filled, const std::string& icon_star_empty)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sqlite3_open("sample.hive", &m_Database) != SQLITE_OK)
|
||||
if (sqlite3_open(dbPath.c_str(), &m_Database) != SQLITE_OK)
|
||||
{
|
||||
wxLogDebug("Error opening DB");
|
||||
throw sqlite3_errmsg(m_Database);
|
||||
|
|
@ -1087,13 +1087,13 @@ Database::FilterDatabaseBySampleName(wxVector<wxVector<wxVariant>>& sampleVec,
|
|||
}
|
||||
|
||||
wxVector<wxVector<wxVariant>>
|
||||
Database::FilterDatabaseByHiveName(wxVector<wxVector<wxVariant>>& sampleVec,
|
||||
Database::FilterDatabaseByHiveName(const std::string& dbPath, wxVector<wxVector<wxVariant>>& sampleVec,
|
||||
const std::string& hiveName, bool show_extension,
|
||||
const std::string& icon_star_filled, const std::string& icon_star_empty)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sqlite3_open("sample.hive", &m_Database) != SQLITE_OK)
|
||||
if (sqlite3_open(dbPath.c_str(), &m_Database) != SQLITE_OK)
|
||||
{
|
||||
wxLogDebug("Error opening DB");
|
||||
throw sqlite3_errmsg(m_Database);
|
||||
|
|
@ -1184,11 +1184,11 @@ Database::FilterDatabaseByHiveName(wxVector<wxVector<wxVariant>>& sampleVec,
|
|||
return sampleVec;
|
||||
}
|
||||
|
||||
void Database::LoadHivesDatabase(wxDataViewTreeCtrl& treeCtrl)
|
||||
void Database::LoadHivesDatabase(const std::string& dbPath, wxDataViewTreeCtrl& treeCtrl)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sqlite3_open("sample.hive", &m_Database) != SQLITE_OK)
|
||||
if (sqlite3_open(dbPath.c_str(), &m_Database) != SQLITE_OK)
|
||||
{
|
||||
wxLogDebug("Error opening DB");
|
||||
throw sqlite3_errmsg(m_Database);
|
||||
|
|
@ -1227,7 +1227,7 @@ void Database::LoadHivesDatabase(wxDataViewTreeCtrl& treeCtrl)
|
|||
}
|
||||
|
||||
//Compares the input array with the database and removes duplicates.
|
||||
wxArrayString Database::CheckDuplicates(const wxArrayString& files)
|
||||
wxArrayString Database::CheckDuplicates(const std::string& dbPath, const wxArrayString& files)
|
||||
{
|
||||
wxArrayString sorted_files;
|
||||
|
||||
|
|
@ -1236,7 +1236,7 @@ wxArrayString Database::CheckDuplicates(const wxArrayString& files)
|
|||
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string select = "SELECT * FROM SAMPLES WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -1268,11 +1268,11 @@ wxArrayString Database::CheckDuplicates(const wxArrayString& files)
|
|||
return sorted_files;
|
||||
}
|
||||
|
||||
bool Database::IsTrashed(const std::string& filename)
|
||||
bool Database::IsTrashed(const std::string& dbPath, const std::string& filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string select = "SELECT TRASHED FROM SAMPLES WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -1312,11 +1312,11 @@ bool Database::IsTrashed(const std::string& filename)
|
|||
return false;
|
||||
}
|
||||
|
||||
void Database::UpdateTrashColumn(const std::string& filename, int value)
|
||||
void Database::UpdateTrashColumn(const std::string& dbPath, const std::string& filename, int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
rc = sqlite3_open(dbPath.c_str(), &m_Database);
|
||||
|
||||
std::string update = "UPDATE SAMPLES SET TRASHED = ? WHERE FILENAME = ?;";
|
||||
|
||||
|
|
@ -1353,13 +1353,13 @@ void Database::UpdateTrashColumn(const std::string& filename, int value)
|
|||
}
|
||||
|
||||
wxVector<wxVector<wxVariant>>
|
||||
Database::RestoreFromTrashByFilename(const std::string& filename, wxVector<wxVector<wxVariant>>& vecSet,
|
||||
bool show_extension, const std::string& icon_star_filled,
|
||||
const std::string& icon_star_empty)
|
||||
Database::RestoreFromTrashByFilename(const std::string& dbPath, const std::string& filename,
|
||||
wxVector<wxVector<wxVariant>>& vecSet, bool show_extension,
|
||||
const std::string& icon_star_filled, const std::string& icon_star_empty)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sqlite3_open("sample.hive", &m_Database) != SQLITE_OK)
|
||||
if (sqlite3_open(dbPath.c_str(), &m_Database) != SQLITE_OK)
|
||||
{
|
||||
wxLogDebug("Error opening DB");
|
||||
throw sqlite3_errmsg(m_Database);
|
||||
|
|
|
|||
|
|
@ -32,61 +32,61 @@ class Database
|
|||
public:
|
||||
// -------------------------------------------------------------------
|
||||
// Create the table
|
||||
void CreateTableSamples();
|
||||
void CreateTableHives();
|
||||
void CreateTableSamples(const std::string& dbPath);
|
||||
void CreateTableHives(const std::string& dbPath);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Insert into database
|
||||
void InsertIntoSamples(std::vector<Sample>);
|
||||
void InsertIntoHives(const std::string& hiveName);
|
||||
void InsertIntoSamples(const std::string& dbPath, std::vector<Sample>);
|
||||
void InsertIntoHives(const std::string& dbPath, const std::string& hiveName);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Update database
|
||||
void UpdateFavoriteColumn(const std::string& filename, int value);
|
||||
void UpdateHive(const std::string& hiveOldName, const std::string& hiveNewName);
|
||||
void UpdateHiveName(const std::string& filename, const std::string& hiveName);
|
||||
void UpdateTrashColumn(const std::string& filename, int value);
|
||||
void UpdateSamplePack(const std::string& filename, const std::string& samplePack);
|
||||
void UpdateSampleType(const std::string& filename, const std::string& type);
|
||||
void UpdateFavoriteColumn(const std::string& dbPath, const std::string& filename, int value);
|
||||
void UpdateHive(const std::string& dbPath, const std::string& hiveOldName, const std::string& hiveNewName);
|
||||
void UpdateHiveName(const std::string& dbPath, const std::string& filename, const std::string& hiveName);
|
||||
void UpdateTrashColumn(const std::string& dbPath, const std::string& filename, int value);
|
||||
void UpdateSamplePack(const std::string& dbPath, const std::string& filename, const std::string& samplePack);
|
||||
void UpdateSampleType(const std::string& dbPath, const std::string& filename, const std::string& type);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Get from database
|
||||
int GetFavoriteColumnValueByFilename(const std::string& filename);
|
||||
std::string GetHiveByFilename(const std::string& filename);
|
||||
std::string GetSamplePathByFilename(const std::string& filename);
|
||||
std::string GetSampleFileExtension(const std::string& filename);
|
||||
std::string GetSampleType(const std::string& filename);
|
||||
int GetFavoriteColumnValueByFilename(const std::string& dbPath, const std::string& filename);
|
||||
std::string GetHiveByFilename(const std::string& dbPath, const std::string& filename);
|
||||
std::string GetSamplePathByFilename(const std::string& dbPath, const std::string& filename);
|
||||
std::string GetSampleFileExtension(const std::string& dbPath, const std::string& filename);
|
||||
std::string GetSampleType(const std::string& dbPath, const std::string& filename);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Check database
|
||||
bool IsTrashed(const std::string& filename);
|
||||
wxArrayString CheckDuplicates(const wxArrayString& files);
|
||||
bool IsTrashed(const std::string& dbPath, const std::string& filename);
|
||||
wxArrayString CheckDuplicates(const std::string& dbPath, const wxArrayString& files);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Remove from database
|
||||
void RemoveSampleFromDatabase(const std::string& filename);
|
||||
void RemoveHiveFromDatabase(const std::string& hiveName);
|
||||
void RemoveSampleFromDatabase(const std::string& dbPath, const std::string& filename);
|
||||
void RemoveHiveFromDatabase(const std::string& dbPath, const std::string& hiveName);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
wxVector<wxVector<wxVariant>>
|
||||
// LoadDatabase(wxVector<wxVector<wxVariant>> &vecSet,
|
||||
// wxTreeCtrl& favorite_tree, wxTreeItemId& favorite_item,
|
||||
// wxTreeCtrl& trash_tree, wxTreeItemId& trash_item, bool show_extension);
|
||||
LoadSamplesDatabase(wxVector<wxVector<wxVariant>>& vecSet,
|
||||
LoadSamplesDatabase(const std::string& dbPath, wxVector<wxVector<wxVariant>>& vecSet,
|
||||
wxDataViewTreeCtrl& favorite_tree, wxDataViewItem& favorite_item,
|
||||
wxTreeCtrl& trash_tree, wxTreeItemId& trash_item, bool show_extension,
|
||||
const std::string& icon_star_filled, const std::string& icon_star_emtpy);
|
||||
void LoadHivesDatabase(wxDataViewTreeCtrl& favorite_tree);
|
||||
void LoadHivesDatabase(const std::string& dbPath, wxDataViewTreeCtrl& favorite_tree);
|
||||
wxVector<wxVector<wxVariant>>
|
||||
RestoreFromTrashByFilename(const std::string& filename, wxVector<wxVector<wxVariant>>& vecSet,
|
||||
bool show_extension, const std::string& icon_star_filled,
|
||||
const std::string& icon_star_empty);
|
||||
RestoreFromTrashByFilename(const std::string& dbPath, const std::string& filename,
|
||||
wxVector<wxVector<wxVariant>>& vecSet, bool show_extension,
|
||||
const std::string& icon_star_filled, const std::string& icon_star_empty);
|
||||
wxVector<wxVector<wxVariant>>
|
||||
FilterDatabaseBySampleName(wxVector<wxVector<wxVariant>>& sampleVec,
|
||||
FilterDatabaseBySampleName(const std::string& dbPath, wxVector<wxVector<wxVariant>>& sampleVec,
|
||||
const std::string& sampleName, bool show_extension,
|
||||
const std::string& icon_star_filled, const std::string& icon_star_empty);
|
||||
wxVector<wxVector<wxVariant>>
|
||||
FilterDatabaseByHiveName(wxVector<wxVector<wxVariant>>& sampleVec,
|
||||
FilterDatabaseByHiveName(const std::string& dbPath, wxVector<wxVector<wxVariant>>& sampleVec,
|
||||
const std::string& hiveName, bool show_extension,
|
||||
const std::string& icon_star_filled, const std::string& icon_star_empty);
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -7,7 +7,6 @@
|
|||
#include <wx/collpane.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/dirctrl.h>
|
||||
// #include <wx/dirdlg.h>
|
||||
#include <wx/event.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/fswatcher.h>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <wx/log.h>
|
||||
#include <wx/stdpaths.h>
|
||||
#include <wx/filename.h>
|
||||
|
||||
#include <yaml-cpp/emittermanip.h>
|
||||
#include <yaml-cpp/node/parse.h>
|
||||
|
|
@ -22,8 +23,10 @@ Serializer::Serializer(const std::string& filepath)
|
|||
|
||||
if (!ifstrm)
|
||||
{
|
||||
m_Emitter << YAML::Comment("This is the configuration file for the Sample Browser,"
|
||||
"feel free to edit this file as needed");
|
||||
wxLogDebug("Genrating configuration file..");
|
||||
|
||||
m_Emitter << YAML::Comment("This is the configuration file for SampleHive,"
|
||||
"feel free to edit the file as needed");
|
||||
m_Emitter << YAML::Newline;
|
||||
|
||||
m_Emitter << YAML::BeginMap;
|
||||
|
|
@ -61,6 +64,8 @@ Serializer::Serializer(const std::string& filepath)
|
|||
|
||||
std::ofstream ofstrm(m_Filepath);
|
||||
ofstrm << m_Emitter.c_str();
|
||||
|
||||
wxLogDebug("Generated %s successfully!", m_Filepath);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -106,7 +111,7 @@ int Serializer::DeserializeWinSize(std::string key, int size) const
|
|||
std::cout << ex.what() << std::endl;
|
||||
}
|
||||
|
||||
wxLogDebug("size: %d", size);
|
||||
wxLogDebug("Window size: %d", size);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
|
@ -149,7 +154,10 @@ bool Serializer::DeserializeBrowserControls(std::string key, bool control) const
|
|||
std::cout << ex.what() << std::endl;
|
||||
}
|
||||
|
||||
wxLogDebug("Control: %d", control);
|
||||
wxLogDebug("Autoplay: %s, Loop: %s, Muted: %s",
|
||||
autoplay ? "enabled" : "disabled",
|
||||
loop ? "enabled" : "disabled",
|
||||
muted ? "muted" : "unmuted");
|
||||
|
||||
return control;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,9 +107,9 @@ Settings::Settings(wxWindow* window, const std::string& configFilepath, const st
|
|||
|
||||
m_DisplayTopSizer->Add(m_DisplayFontSizer, 1, wxALL | wxEXPAND, 2);
|
||||
|
||||
m_CollectionImportDirSizer->Add(m_AutoImportCheck, 0, wxALL | wxALIGN_LEFT, 2);
|
||||
m_CollectionImportDirSizer->Add(m_ImportDirLocation, 1, wxALL, 2);
|
||||
m_CollectionImportDirSizer->Add(m_BrowseAutoImportDirButton, 0, wxALL | wxALIGN_RIGHT, 2);
|
||||
m_CollectionImportDirSizer->Add(m_AutoImportCheck, 0, wxALL | wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT, 2);
|
||||
m_CollectionImportDirSizer->Add(m_ImportDirLocation, 1, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||
m_CollectionImportDirSizer->Add(m_BrowseAutoImportDirButton, 0, wxALL | wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 2);
|
||||
|
||||
m_ShowFileExtensionSizer->Add(m_ShowFileExtensionCheck, 0, wxALL | wxALIGN_LEFT, 2);
|
||||
|
||||
|
|
|
|||
|
|
@ -125,6 +125,6 @@ class Settings : public wxDialog
|
|||
wxString GetImportDirPath();
|
||||
|
||||
inline wxFont GetFontType() { return m_Font; };
|
||||
inline bool IsAutoImport() { return bAutoImport; };
|
||||
inline bool IsShowFileExtension() { return bShowExtension; };
|
||||
inline bool CanAutoImport() { return bAutoImport; };
|
||||
inline bool ShouldShowFileExtension() { return bShowExtension; };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
#include "Database.hpp"
|
||||
#include "TagEditorDialog.hpp"
|
||||
|
||||
TagEditor::TagEditor(wxWindow* window, const std::string& filename, wxInfoBar& info_bar)
|
||||
TagEditor::TagEditor(wxWindow* window, const std::string& dbPath, const std::string& filename, wxInfoBar& info_bar)
|
||||
: wxDialog(window, wxID_ANY, "Edit tags", wxDefaultPosition,
|
||||
wxSize(640, 360), wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP),
|
||||
m_Window(window), m_Filename(filename), m_InfoBar(info_bar), tags(filename)
|
||||
m_Window(window), m_DatabaseFilepath(dbPath), m_Filename(filename), m_InfoBar(info_bar), tags(filename)
|
||||
{
|
||||
m_Panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
|||
wxString comment = m_CommentText->GetValue();
|
||||
wxString type = m_SampleTypeChoice->GetStringSelection();
|
||||
|
||||
std::string sampleType = db.GetSampleType(m_Filename);
|
||||
std::string sampleType = db.GetSampleType(m_DatabaseFilepath, m_Filename);
|
||||
|
||||
std::string filename = wxString(m_Filename).AfterLast('/').BeforeLast('.').ToStdString();
|
||||
|
||||
|
|
@ -245,7 +245,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
|||
wxLogDebug("Changing artist tag..");
|
||||
tags.SetArtist(artist.ToStdString());
|
||||
|
||||
db.UpdateSamplePack(m_Filename, artist.ToStdString());
|
||||
db.UpdateSamplePack(m_DatabaseFilepath, m_Filename, artist.ToStdString());
|
||||
|
||||
wxLogDebug("SAMPLE FILENAME HERE: %s", m_Filename);
|
||||
|
||||
|
|
@ -279,7 +279,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
|||
if (m_SampleTypeCheck->GetValue() && m_SampleTypeChoice->GetStringSelection() != sampleType)
|
||||
{
|
||||
wxLogDebug("Changing type tag..");
|
||||
db.UpdateSampleType(filename, type.ToStdString());
|
||||
db.UpdateSampleType(m_DatabaseFilepath, filename, type.ToStdString());
|
||||
|
||||
info_msg = wxString::Format("Successfully changed type tag to %s", type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,13 @@
|
|||
class TagEditor : public wxDialog
|
||||
{
|
||||
public:
|
||||
TagEditor(wxWindow* window, const std::string& filename, wxInfoBar& info_bar);
|
||||
TagEditor(wxWindow* window, const std::string& dbPath, const std::string& filename, wxInfoBar& info_bar);
|
||||
~TagEditor();
|
||||
|
||||
private:
|
||||
// -------------------------------------------------------------------
|
||||
wxWindow* m_Window;
|
||||
const std::string m_DatabaseFilepath;
|
||||
const std::string m_Filename;
|
||||
|
||||
wxInfoBar& m_InfoBar;
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
#include "TreeItemDialog.hpp"
|
||||
|
||||
TreeItemDialog::TreeItemDialog(wxWindow* window):
|
||||
wxDialog(window, wxID_ANY, "Add root", wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxSTAY_ON_TOP)
|
||||
{
|
||||
mainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
titleSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
buttonSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
mainPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
addRootLabel = new wxStaticText(mainPanel, wxID_ANY, "Title", wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
addRootText = new wxTextCtrl(mainPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
addRootButton = new wxButton(mainPanel, wxID_OK, "Ok", wxDefaultPosition, wxDefaultSize, 0);
|
||||
cancelButton = new wxButton(mainPanel, wxID_CANCEL, "Cancel", wxDefaultPosition, wxDefaultSize, 0);
|
||||
|
||||
titleSizer->Add(addRootLabel, 0, wxALL, 2);
|
||||
titleSizer->Add(addRootText, 1, wxALL, 2);
|
||||
|
||||
buttonSizer->Add(addRootButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
||||
buttonSizer->Add(cancelButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
||||
|
||||
mainSizer->Add(titleSizer, 0, wxALL | wxEXPAND, 2);
|
||||
mainSizer->Add(buttonSizer, 1, wxALL | wxALIGN_RIGHT, 2);
|
||||
|
||||
mainPanel->SetSizer(mainSizer);
|
||||
mainSizer->Fit(mainPanel);
|
||||
mainSizer->SetSizeHints(mainPanel);
|
||||
mainSizer->Layout();
|
||||
}
|
||||
|
||||
TreeItemDialog::~TreeItemDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <wx/button.h>
|
||||
#include <wx/defs.h>
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/stringimpl.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/window.h>
|
||||
|
||||
class TreeItemDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
TreeItemDialog(wxWindow* window);
|
||||
~TreeItemDialog();
|
||||
|
||||
public:
|
||||
wxPanel* mainPanel;
|
||||
|
||||
wxBoxSizer* mainSizer;
|
||||
wxBoxSizer* titleSizer;
|
||||
wxBoxSizer* buttonSizer;
|
||||
|
||||
wxStaticText* addRootLabel;
|
||||
|
||||
wxTextCtrl* addRootText;
|
||||
|
||||
wxButton* addRootButton;
|
||||
wxButton* cancelButton;
|
||||
};
|
||||
Loading…
Reference in New Issue