Fix style, hide the new columns by default, and move the new columns to the end of the enum
This commit is contained in:
parent
a6d3b48231
commit
d89954ae31
@ -55,7 +55,10 @@ CREATE TABLE device_%deviceid_songs (
|
|||||||
unavailable INTEGER DEFAULT 0,
|
unavailable INTEGER DEFAULT 0,
|
||||||
|
|
||||||
effective_albumartist TEXT,
|
effective_albumartist TEXT,
|
||||||
etag TEXT
|
etag TEXT,
|
||||||
|
|
||||||
|
performer TEXT,
|
||||||
|
grouping TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX idx_device_%deviceid_songs_album ON device_%deviceid_songs (album);
|
CREATE INDEX idx_device_%deviceid_songs_album ON device_%deviceid_songs (album);
|
||||||
@ -63,7 +66,7 @@ CREATE INDEX idx_device_%deviceid_songs_album ON device_%deviceid_songs (album);
|
|||||||
CREATE INDEX idx_device_%deviceid_songs_comp_artist ON device_%deviceid_songs (effective_compilation, artist);
|
CREATE INDEX idx_device_%deviceid_songs_comp_artist ON device_%deviceid_songs (effective_compilation, artist);
|
||||||
|
|
||||||
CREATE VIRTUAL TABLE device_%deviceid_fts USING fts3(
|
CREATE VIRTUAL TABLE device_%deviceid_fts USING fts3(
|
||||||
ftstitle, ftsalbum, ftsartist, ftsalbumartist, ftscomposer, ftsgenre, ftscomment,
|
ftstitle, ftsalbum, ftsartist, ftsalbumartist, ftscomposer, ftsperformer, ftsgrouping, ftsgenre, ftscomment,
|
||||||
tokenize=unicode
|
tokenize=unicode
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -500,8 +500,8 @@ void Database::UpdateDatabaseSchema(int version, QSqlDatabase &db) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
qLog(Debug) << "Applying database schema update" << version
|
qLog(Debug) << "Applying database schema update" << version
|
||||||
<< "from" << filename;
|
<< "from" << filename;
|
||||||
ExecSchemaCommandsFromFile(db, filename, version - 1, &t);
|
ExecSchemaCommandsFromFile(db, filename, version - 1, true);
|
||||||
t.Commit();
|
t.Commit();
|
||||||
} else {
|
} else {
|
||||||
qLog(Debug) << "Applying database schema update" << version
|
qLog(Debug) << "Applying database schema update" << version
|
||||||
@ -533,22 +533,25 @@ void Database::UrlEncodeFilenameColumn(const QString& table, QSqlDatabase& db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::ExecSchemaCommandsFromFile(QSqlDatabase& db,
|
void Database::ExecSchemaCommandsFromFile(QSqlDatabase& db,
|
||||||
QString const& filename,
|
const QString& filename,
|
||||||
int schema_version,
|
int schema_version,
|
||||||
ScopedTransaction const* outerTransaction) {
|
bool in_transaction) {
|
||||||
// Open and read the database schema
|
// Open and read the database schema
|
||||||
QFile schema_file(filename);
|
QFile schema_file(filename);
|
||||||
if (!schema_file.open(QIODevice::ReadOnly))
|
if (!schema_file.open(QIODevice::ReadOnly))
|
||||||
qFatal("Couldn't open schema file %s", filename.toUtf8().constData());
|
qFatal("Couldn't open schema file %s", filename.toUtf8().constData());
|
||||||
ExecSchemaCommands(db, QString::fromUtf8(schema_file.readAll()), schema_version, outerTransaction);
|
ExecSchemaCommands(db,
|
||||||
|
QString::fromUtf8(schema_file.readAll()),
|
||||||
|
schema_version,
|
||||||
|
in_transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::ExecSchemaCommands(QSqlDatabase& db,
|
void Database::ExecSchemaCommands(QSqlDatabase& db,
|
||||||
QString const& schema,
|
const QString& schema,
|
||||||
int schema_version,
|
int schema_version,
|
||||||
ScopedTransaction const* outerTransaction) {
|
bool in_transaction) {
|
||||||
// Run each command
|
// Run each command
|
||||||
QStringList const schemaCommands(schema.split(";\n\n"));
|
const QStringList commands(schema.split(";\n\n"));
|
||||||
|
|
||||||
// We don't want this list to reflect possible DB schema changes
|
// We don't want this list to reflect possible DB schema changes
|
||||||
// so we initialize it before executing any statements.
|
// so we initialize it before executing any statements.
|
||||||
@ -556,26 +559,26 @@ void Database::ExecSchemaCommands(QSqlDatabase& db,
|
|||||||
// be queried before beginning an inner transaction! Otherwise
|
// be queried before beginning an inner transaction! Otherwise
|
||||||
// DROP TABLE commands on song tables may fail due to database
|
// DROP TABLE commands on song tables may fail due to database
|
||||||
// locks.
|
// locks.
|
||||||
QStringList const songTables(SongsTables(db, schema_version));
|
const QStringList song_tables(SongsTables(db, schema_version));
|
||||||
|
|
||||||
if (0 == outerTransaction) {
|
if (!in_transaction) {
|
||||||
ScopedTransaction innerTransaction(&db);
|
ScopedTransaction inner_transaction(&db);
|
||||||
ExecSongTablesCommands(db, songTables, schemaCommands);
|
ExecSongTablesCommands(db, song_tables, commands);
|
||||||
innerTransaction.Commit();
|
inner_transaction.Commit();
|
||||||
} else {
|
} else {
|
||||||
ExecSongTablesCommands(db, songTables, schemaCommands);
|
ExecSongTablesCommands(db, song_tables, commands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::ExecSongTablesCommands(QSqlDatabase& db,
|
void Database::ExecSongTablesCommands(QSqlDatabase& db,
|
||||||
QStringList const& songTables,
|
const QStringList& song_tables,
|
||||||
QStringList const& commands) {
|
const QStringList& commands) {
|
||||||
foreach (QString const& 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 (QString const& table, songTables) {
|
foreach (const QString& table, song_tables) {
|
||||||
qLog(Info) << "Updating" << table << "for" << kMagicAllSongsTables;
|
qLog(Info) << "Updating" << table << "for" << kMagicAllSongsTables;
|
||||||
QString new_command(command);
|
QString new_command(command);
|
||||||
new_command.replace(kMagicAllSongsTables, table);
|
new_command.replace(kMagicAllSongsTables, table);
|
||||||
|
@ -38,7 +38,6 @@ struct sqlite3_tokenizer_module;
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Application;
|
class Application;
|
||||||
class ScopedTransaction;
|
|
||||||
|
|
||||||
class Database : public QObject {
|
class Database : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -56,7 +55,10 @@ class Database : public QObject {
|
|||||||
QMutex* Mutex() { return &mutex_; }
|
QMutex* Mutex() { return &mutex_; }
|
||||||
|
|
||||||
void RecreateAttachedDb(const QString& database_name);
|
void RecreateAttachedDb(const QString& database_name);
|
||||||
void ExecSchemaCommands(QSqlDatabase &db, QString const& schema, int schema_version, ScopedTransaction const* outerTransaction = 0);
|
void ExecSchemaCommands(QSqlDatabase& db,
|
||||||
|
const QString& schema,
|
||||||
|
int schema_version,
|
||||||
|
bool in_transaction = false);
|
||||||
|
|
||||||
int startup_schema_version() const { return startup_schema_version_; }
|
int startup_schema_version() const { return startup_schema_version_; }
|
||||||
int current_schema_version() const { return kSchemaVersion; }
|
int current_schema_version() const { return kSchemaVersion; }
|
||||||
@ -70,8 +72,13 @@ class Database : public QObject {
|
|||||||
private:
|
private:
|
||||||
void UpdateMainSchema(QSqlDatabase* db);
|
void UpdateMainSchema(QSqlDatabase* db);
|
||||||
|
|
||||||
void ExecSchemaCommandsFromFile(QSqlDatabase &db, QString const& filename, int schema_version, ScopedTransaction const* outerTransaction = 0);
|
void ExecSchemaCommandsFromFile(QSqlDatabase& db,
|
||||||
void ExecSongTablesCommands(QSqlDatabase &db, QStringList const& songTables, QStringList const& commands);
|
const QString& filename,
|
||||||
|
int schema_version,
|
||||||
|
bool in_transaction = false);
|
||||||
|
void ExecSongTablesCommands(QSqlDatabase& db,
|
||||||
|
const QStringList& song_tables,
|
||||||
|
const QStringList& commands);
|
||||||
|
|
||||||
void UpdateDatabaseSchema(int version, QSqlDatabase& db);
|
void UpdateDatabaseSchema(int version, QSqlDatabase& db);
|
||||||
void UrlEncodeFilenameColumn(const QString& table, QSqlDatabase& db);
|
void UrlEncodeFilenameColumn(const QString& table, QSqlDatabase& db);
|
||||||
|
@ -90,7 +90,7 @@ int DeviceDatabaseBackend::AddDevice(const Device& device) {
|
|||||||
QString schema = QString::fromUtf8(schema_file.readAll());
|
QString schema = QString::fromUtf8(schema_file.readAll());
|
||||||
schema.replace("%deviceid", QString::number(id));
|
schema.replace("%deviceid", QString::number(id));
|
||||||
|
|
||||||
db_->ExecSchemaCommands(db, schema, 0, &t);
|
db_->ExecSchemaCommands(db, schema, 0, true);
|
||||||
|
|
||||||
t.Commit();
|
t.Commit();
|
||||||
return id;
|
return id;
|
||||||
|
@ -90,8 +90,6 @@ class Playlist : public QAbstractListModel {
|
|||||||
Column_Album,
|
Column_Album,
|
||||||
Column_AlbumArtist,
|
Column_AlbumArtist,
|
||||||
Column_Composer,
|
Column_Composer,
|
||||||
Column_Performer,
|
|
||||||
Column_Grouping,
|
|
||||||
Column_Length,
|
Column_Length,
|
||||||
Column_Track,
|
Column_Track,
|
||||||
Column_Disc,
|
Column_Disc,
|
||||||
@ -119,6 +117,9 @@ class Playlist : public QAbstractListModel {
|
|||||||
Column_Source,
|
Column_Source,
|
||||||
Column_Mood,
|
Column_Mood,
|
||||||
|
|
||||||
|
Column_Performer,
|
||||||
|
Column_Grouping,
|
||||||
|
|
||||||
ColumnCount
|
ColumnCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
# include "moodbar/moodbaritemdelegate.h"
|
# include "moodbar/moodbaritemdelegate.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const int PlaylistView::kStateVersion = 5;
|
const int PlaylistView::kStateVersion = 6;
|
||||||
const int PlaylistView::kGlowIntensitySteps = 24;
|
const int PlaylistView::kGlowIntensitySteps = 24;
|
||||||
const int PlaylistView::kAutoscrollGraceTimeout = 30; // seconds
|
const int PlaylistView::kAutoscrollGraceTimeout = 30; // seconds
|
||||||
const int PlaylistView::kDropIndicatorWidth = 2;
|
const int PlaylistView::kDropIndicatorWidth = 2;
|
||||||
@ -324,6 +324,10 @@ void PlaylistView::LoadGeometry() {
|
|||||||
if (state_version < 5) {
|
if (state_version < 5) {
|
||||||
header_->HideSection(Playlist::Column_Mood);
|
header_->HideSection(Playlist::Column_Mood);
|
||||||
}
|
}
|
||||||
|
if (state_version < 6) {
|
||||||
|
header_->HideSection(Playlist::Column_Performer);
|
||||||
|
header_->HideSection(Playlist::Column_Grouping);
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure at least one column is visible
|
// Make sure at least one column is visible
|
||||||
bool all_hidden = true;
|
bool all_hidden = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user