some minor .cue related changes
This commit is contained in:
parent
dfa5b9f8ea
commit
bb79a68be0
@ -513,12 +513,17 @@ void Database::ExecFromFile(const QString &filename, QSqlDatabase &db) {
|
|||||||
void Database::ExecCommands(const QString &schema, QSqlDatabase &db) {
|
void Database::ExecCommands(const QString &schema, QSqlDatabase &db) {
|
||||||
// Run each command
|
// Run each command
|
||||||
QStringList commands(schema.split(";\n\n"));
|
QStringList commands(schema.split(";\n\n"));
|
||||||
|
|
||||||
|
// We don't want this list to reflect possible DB schema changes
|
||||||
|
// so we initialize it before executing any statements.
|
||||||
|
QStringList tables = SongsTables(db);
|
||||||
|
|
||||||
foreach (const QString& command, commands) {
|
foreach (const QString& command, commands) {
|
||||||
// There are now lots of "songs" tables that need to have the same schema:
|
// There are now lots of "songs" tables that need to have the same schema:
|
||||||
// songs, magnatune_songs, and device_*_songs. We allow a magic value
|
// songs, magnatune_songs, and device_*_songs. We allow a magic value
|
||||||
// in the schema files to update all songs tables at once.
|
// in the schema files to update all songs tables at once.
|
||||||
if (command.contains(kMagicAllSongsTables)) {
|
if (command.contains(kMagicAllSongsTables)) {
|
||||||
foreach (const QString& table, SongsTables(db)) {
|
foreach (const QString& table, tables) {
|
||||||
qDebug() << "Updating" << table << "for" << kMagicAllSongsTables;
|
qDebug() << "Updating" << table << "for" << kMagicAllSongsTables;
|
||||||
QString new_command(command);
|
QString new_command(command);
|
||||||
new_command.replace(kMagicAllSongsTables, table);
|
new_command.replace(kMagicAllSongsTables, table);
|
||||||
|
@ -89,11 +89,11 @@ static QStringList Updateify(const QStringList& list) {
|
|||||||
const QStringList Song::kColumns = QStringList()
|
const QStringList Song::kColumns = QStringList()
|
||||||
<< "title" << "album" << "artist" << "albumartist" << "composer" << "track"
|
<< "title" << "album" << "artist" << "albumartist" << "composer" << "track"
|
||||||
<< "disc" << "bpm" << "year" << "genre" << "comment" << "compilation"
|
<< "disc" << "bpm" << "year" << "genre" << "comment" << "compilation"
|
||||||
<< "length" << "bitrate" << "samplerate" << "directory" << "filename"
|
<< "bitrate" << "samplerate" << "directory" << "filename"
|
||||||
<< "mtime" << "ctime" << "filesize" << "sampler" << "art_automatic"
|
<< "mtime" << "ctime" << "filesize" << "sampler" << "art_automatic"
|
||||||
<< "art_manual" << "filetype" << "playcount" << "lastplayed" << "rating"
|
<< "art_manual" << "filetype" << "playcount" << "lastplayed" << "rating"
|
||||||
<< "forced_compilation_on" << "forced_compilation_off"
|
<< "forced_compilation_on" << "forced_compilation_off"
|
||||||
<< "effective_compilation" << "skipcount" << "score" << "beginning";
|
<< "effective_compilation" << "skipcount" << "score" << "beginning" << "length";
|
||||||
|
|
||||||
const QString Song::kColumnSpec = Song::kColumns.join(", ");
|
const QString Song::kColumnSpec = Song::kColumns.join(", ");
|
||||||
const QString Song::kBindSpec = Prepend(":", Song::kColumns).join(", ");
|
const QString Song::kBindSpec = Prepend(":", Song::kColumns).join(", ");
|
||||||
@ -470,37 +470,38 @@ void Song::InitFromQuery(const SqlRow& q, int col) {
|
|||||||
d->comment_ = tostr(col + 11);
|
d->comment_ = tostr(col + 11);
|
||||||
d->compilation_ = q.value(col + 12).toBool();
|
d->compilation_ = q.value(col + 12).toBool();
|
||||||
|
|
||||||
d->bitrate_ = toint(col + 14);
|
d->bitrate_ = toint(col + 13);
|
||||||
d->samplerate_ = toint(col + 15);
|
d->samplerate_ = toint(col + 14);
|
||||||
|
|
||||||
d->directory_id_ = toint(col + 16);
|
d->directory_id_ = toint(col + 15);
|
||||||
d->filename_ = tostr(col + 17);
|
d->filename_ = tostr(col + 16);
|
||||||
d->basefilename_ = QFileInfo(d->filename_).fileName();
|
d->basefilename_ = QFileInfo(d->filename_).fileName();
|
||||||
d->mtime_ = toint(col + 18);
|
d->mtime_ = toint(col + 17);
|
||||||
d->ctime_ = toint(col + 19);
|
d->ctime_ = toint(col + 18);
|
||||||
d->filesize_ = toint(col + 20);
|
d->filesize_ = toint(col + 19);
|
||||||
|
|
||||||
d->sampler_ = q.value(col + 21).toBool();
|
d->sampler_ = q.value(col + 20).toBool();
|
||||||
|
|
||||||
d->art_automatic_ = q.value(col + 22).toString();
|
d->art_automatic_ = q.value(col + 21).toString();
|
||||||
d->art_manual_ = q.value(col + 23).toString();
|
d->art_manual_ = q.value(col + 22).toString();
|
||||||
|
|
||||||
d->filetype_ = FileType(q.value(col + 24).toInt());
|
d->filetype_ = FileType(q.value(col + 23).toInt());
|
||||||
d->playcount_ = q.value(col + 25).isNull() ? 0 : q.value(col + 25).toInt();
|
d->playcount_ = q.value(col + 24).isNull() ? 0 : q.value(col + 24).toInt();
|
||||||
d->lastplayed_ = toint(col + 26);
|
d->lastplayed_ = toint(col + 25);
|
||||||
d->rating_ = tofloat(col + 27);
|
d->rating_ = tofloat(col + 26);
|
||||||
|
|
||||||
d->forced_compilation_on_ = q.value(col + 28).toBool();
|
d->forced_compilation_on_ = q.value(col + 27).toBool();
|
||||||
d->forced_compilation_off_ = q.value(col + 29).toBool();
|
d->forced_compilation_off_ = q.value(col + 28).toBool();
|
||||||
|
|
||||||
// effective_compilation = 30
|
// effective_compilation = 29
|
||||||
|
|
||||||
d->skipcount_ = q.value(col + 31).isNull() ? 0 : q.value(col + 31).toInt();
|
d->skipcount_ = q.value(col + 30).isNull() ? 0 : q.value(col + 30).toInt();
|
||||||
d->score_ = q.value(col + 32).isNull() ? 0 : q.value(col + 32).toInt();
|
d->score_ = q.value(col + 31).isNull() ? 0 : q.value(col + 31).toInt();
|
||||||
|
|
||||||
// TODO: 'end' instead of 'length'
|
// do not move those statements - beginning must be initialized before
|
||||||
d->beginning_ = q.value(col + 33).isNull() ? 0 : q.value(col + 33).toInt();
|
// length is!
|
||||||
set_length(toint(col + 13));
|
d->beginning_ = q.value(col + 32).isNull() ? 0 : q.value(col + 32).toInt();
|
||||||
|
set_length(toint(col + 33));
|
||||||
|
|
||||||
#undef tostr
|
#undef tostr
|
||||||
#undef toint
|
#undef toint
|
||||||
@ -931,8 +932,6 @@ void Song::BindToQuery(QSqlQuery *query) const {
|
|||||||
query->bindValue(":comment", strval(d->comment_));
|
query->bindValue(":comment", strval(d->comment_));
|
||||||
query->bindValue(":compilation", d->compilation_ ? 1 : 0);
|
query->bindValue(":compilation", d->compilation_ ? 1 : 0);
|
||||||
|
|
||||||
// TODO: replace this with 'end'
|
|
||||||
query->bindValue(":length", intval(length()));
|
|
||||||
query->bindValue(":bitrate", intval(d->bitrate_));
|
query->bindValue(":bitrate", intval(d->bitrate_));
|
||||||
query->bindValue(":samplerate", intval(d->samplerate_));
|
query->bindValue(":samplerate", intval(d->samplerate_));
|
||||||
|
|
||||||
@ -960,6 +959,7 @@ void Song::BindToQuery(QSqlQuery *query) const {
|
|||||||
query->bindValue(":score", d->score_);
|
query->bindValue(":score", d->score_);
|
||||||
|
|
||||||
query->bindValue(":beginning", d->beginning_);
|
query->bindValue(":beginning", d->beginning_);
|
||||||
|
query->bindValue(":length", intval(length()));
|
||||||
|
|
||||||
#undef intval
|
#undef intval
|
||||||
#undef notnullintval
|
#undef notnullintval
|
||||||
@ -1049,7 +1049,6 @@ bool Song::IsMetadataEqual(const Song& other) const {
|
|||||||
d->comment_ == other.d->comment_ &&
|
d->comment_ == other.d->comment_ &&
|
||||||
d->compilation_ == other.d->compilation_ &&
|
d->compilation_ == other.d->compilation_ &&
|
||||||
d->beginning_ == other.d->beginning_ &&
|
d->beginning_ == other.d->beginning_ &&
|
||||||
// this should be replaced by 'end'
|
|
||||||
length() == other.length() &&
|
length() == other.length() &&
|
||||||
d->bitrate_ == other.d->bitrate_ &&
|
d->bitrate_ == other.d->bitrate_ &&
|
||||||
d->samplerate_ == other.d->samplerate_ &&
|
d->samplerate_ == other.d->samplerate_ &&
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
|
#include <QTextCodec>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
@ -33,8 +34,6 @@ const char* CueParser::kTrack = "track";
|
|||||||
const char* CueParser::kIndex = "index";
|
const char* CueParser::kIndex = "index";
|
||||||
const char* CueParser::kAudioTrackType = "audio";
|
const char* CueParser::kAudioTrackType = "audio";
|
||||||
|
|
||||||
// TODO: utf and regexps (check on Zucchero - there's something wrong)
|
|
||||||
|
|
||||||
CueParser::CueParser(LibraryBackendInterface* library, QObject* parent)
|
CueParser::CueParser(LibraryBackendInterface* library, QObject* parent)
|
||||||
: ParserBase(library, parent)
|
: ParserBase(library, parent)
|
||||||
{
|
{
|
||||||
@ -44,6 +43,8 @@ SongList CueParser::Load(QIODevice* device, const QDir& dir) const {
|
|||||||
SongList ret;
|
SongList ret;
|
||||||
|
|
||||||
QTextStream text_stream(device);
|
QTextStream text_stream(device);
|
||||||
|
text_stream.setCodec(QTextCodec::codecForUtfText(device->peek(1024), QTextCodec::codecForName("UTF-8")));
|
||||||
|
|
||||||
QString dir_path = dir.absolutePath();
|
QString dir_path = dir.absolutePath();
|
||||||
|
|
||||||
QString line;
|
QString line;
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
|
|
||||||
|
// This parser will try to detect the real encoding of a .cue file but there's
|
||||||
|
// a great chance it will fail so it's probably best to assume that the parser
|
||||||
|
// is UTF compatible only.
|
||||||
class CueParser : public ParserBase {
|
class CueParser : public ParserBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user