ToobPlayer UI. .mdata file handling.

This commit is contained in:
Robin E. R. Davies
2025-06-19 16:04:32 -04:00
parent bf9846e37f
commit f35ee9330d
29 changed files with 671 additions and 425 deletions
-49
View File
@@ -192,13 +192,6 @@ void AudioFilesDb::CreateDb(const std::filesystem::path &dbPathName)
"width INTEGER, "
"height INTEGER)");
db->exec("CREATE TABLE IF NOT EXISTS extraMetadata ("
"idExtra INTEGER PRIMARY KEY AUTOINCREMENT, "
"idFile INT64 NOT NULL, "
"key TEXT NOT NULL, "
"value TEXT NOT NULL, "
"FOREIGN KEY (idFile) REFERENCES files(idFile) ON DELETE CASCADE, "
"UNIQUE(idFile, key))");
}
catch (const SQLite::Exception &e)
{
@@ -510,45 +503,3 @@ void AudioFilesDb::UpdateFilePosition(
updateFileQuery->exec();
}
void AudioFilesDb::DeleteFileExtraMetadata(
const std::string &fileNameOnly,
const std::string &key)
{
auto deleteExtraMetadataQuery = std::make_unique<SQLite::Statement>(
*db,
"DELETE FROM extraMetadata WHERE idFile = (SELECT idFile FROM files WHERE fileName = ?) AND key = ?");
deleteExtraMetadataQuery->bind(1, fileNameOnly);
deleteExtraMetadataQuery->bind(2, key);
deleteExtraMetadataQuery->exec();
}
void AudioFilesDb::SetFileExtraMetadata(
const std::string &fileNameOnly,
const std::string &key,
const std::string &value)
{
auto setExtraMetadataQuery = std::make_unique<SQLite::Statement>(
*db,
"INSERT OR REPLACE INTO extraMetadata (idFile, key, value) "
"VALUES ((SELECT idFile FROM files WHERE fileName = ?), ?, ?)");
setExtraMetadataQuery->bind(1, fileNameOnly);
setExtraMetadataQuery->bind(2, key);
setExtraMetadataQuery->bind(3, value);
setExtraMetadataQuery->exec();
}
std::string AudioFilesDb::GetFileExtraMetadata(
const std::string &fileNameOnly,
const std::string &key)
{
auto getExtraMetadataQuery = std::make_unique<SQLite::Statement>(
*db,
"SELECT value FROM extraMetadata WHERE idFile = (SELECT idFile FROM files WHERE fileName = ?) AND key = ?");
getExtraMetadataQuery->bind(1, fileNameOnly);
getExtraMetadataQuery->bind(2, key);
if (getExtraMetadataQuery->executeStep())
{
return getExtraMetadataQuery->getColumn(0).getText();
}
return "";
}