mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-18 20:40:43 +01:00
Add album effective_artist filter that falls back to artist when unavailable (Issue 509)
This commit is contained in:
parent
92d2d644d0
commit
edb9b0b4fe
@ -335,5 +335,6 @@
|
||||
<file>icons/22x22/user-away.png</file>
|
||||
<file>icons/32x32/search.png</file>
|
||||
<file>schema/schema-35.sql</file>
|
||||
<file>schema/schema-36.sql</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
7
data/schema/schema-36.sql
Normal file
7
data/schema/schema-36.sql
Normal file
@ -0,0 +1,7 @@
|
||||
ALTER TABLE %allsongstables ADD COLUMN effective_albumartist TEXT;
|
||||
|
||||
UPDATE %allsongstables SET effective_albumartist = albumartist;
|
||||
|
||||
UPDATE %allsongstables SET effective_albumartist = artist WHERE effective_albumartist = "";
|
||||
|
||||
UPDATE schema_version SET version=36;
|
@ -33,7 +33,7 @@
|
||||
#include <QVariant>
|
||||
|
||||
const char* Database::kDatabaseFilename = "clementine.db";
|
||||
const int Database::kSchemaVersion = 35;
|
||||
const int Database::kSchemaVersion = 36;
|
||||
const char* Database::kMagicAllSongsTables = "%allsongstables";
|
||||
|
||||
int Database::sNextConnectionId = 1;
|
||||
|
@ -140,13 +140,11 @@ QString OrganiseFormat::TagValue(const QString &tag, const Song &song) const {
|
||||
else if (tag == "samplerate") value = QString::number(song.samplerate());
|
||||
else if (tag == "extension") value = song.url().toLocalFile().section('.', -1, -1);
|
||||
else if (tag == "artistinitial") {
|
||||
value = song.albumartist().trimmed();
|
||||
if (value.isEmpty()) value = song.artist().trimmed();
|
||||
value = song.effective_albumartist().trimmed();
|
||||
if (!value.isEmpty()) value = value[0].toUpper();
|
||||
}
|
||||
else if (tag == "albumartist") {
|
||||
value = song.albumartist();
|
||||
if (value.isEmpty()) value = song.artist();
|
||||
value = song.is_compilation() ? "Various Artists" : song.effective_albumartist();
|
||||
}
|
||||
|
||||
if (replace_the_ && (tag == "artist" || tag == "albumartist"))
|
||||
|
@ -105,7 +105,7 @@ const QStringList Song::kColumns = QStringList()
|
||||
<< "art_manual" << "filetype" << "playcount" << "lastplayed" << "rating"
|
||||
<< "forced_compilation_on" << "forced_compilation_off"
|
||||
<< "effective_compilation" << "skipcount" << "score" << "beginning" << "length"
|
||||
<< "cue_path" << "unavailable";
|
||||
<< "cue_path" << "unavailable" << "effective_albumartist";
|
||||
|
||||
const QString Song::kColumnSpec = Song::kColumns.join(", ");
|
||||
const QString Song::kBindSpec = Prepend(":", Song::kColumns).join(", ");
|
||||
@ -588,6 +588,8 @@ void Song::InitFromQuery(const SqlRow& q, bool reliable_metadata, int col) {
|
||||
d->cue_path_ = tostr(col + 34);
|
||||
d->unavailable_ = q.value(col + 35).toBool();
|
||||
|
||||
// effective_albumartist = 36
|
||||
|
||||
#undef tostr
|
||||
#undef toint
|
||||
#undef tolonglong
|
||||
@ -1069,6 +1071,7 @@ void Song::BindToQuery(QSqlQuery *query) const {
|
||||
|
||||
query->bindValue(":cue_path", d->cue_path_);
|
||||
query->bindValue(":unavailable", d->unavailable_ ? 1 : 0);
|
||||
query->bindValue(":effective_albumartist", this->effective_albumartist());
|
||||
|
||||
#undef intval
|
||||
#undef notnullintval
|
||||
|
@ -187,6 +187,7 @@ class Song {
|
||||
const QString& album() const { return d->album_; }
|
||||
const QString& artist() const { return d->artist_; }
|
||||
const QString& albumartist() const { return d->albumartist_; }
|
||||
const QString& effective_albumartist() const { return d->albumartist_.isEmpty() ? d->artist_ : d->albumartist_; }
|
||||
const QString& composer() const { return d->composer_; }
|
||||
int track() const { return d->track_; }
|
||||
int disc() const { return d->disc_; }
|
||||
|
@ -174,7 +174,7 @@ void LibraryModel::SongsDiscovered(const SongList& songs) {
|
||||
case GroupBy_Artist: key = song.artist(); break;
|
||||
case GroupBy_Composer: key = song.composer(); break;
|
||||
case GroupBy_Genre: key = song.genre(); break;
|
||||
case GroupBy_AlbumArtist: key = song.albumartist(); break;
|
||||
case GroupBy_AlbumArtist: key = song.effective_albumartist(); break;
|
||||
case GroupBy_Year:
|
||||
key = QString::number(qMax(0, song.year())); break;
|
||||
case GroupBy_YearAlbum:
|
||||
@ -700,7 +700,7 @@ void LibraryModel::InitQuery(GroupBy type, LibraryQuery* q) {
|
||||
q->SetColumnSpec("DISTINCT genre");
|
||||
break;
|
||||
case GroupBy_AlbumArtist:
|
||||
q->SetColumnSpec("DISTINCT albumartist");
|
||||
q->SetColumnSpec("DISTINCT effective_albumartist");
|
||||
break;
|
||||
case GroupBy_None:
|
||||
q->SetColumnSpec("%songs_table.ROWID, " + Song::kColumnSpec);
|
||||
@ -742,7 +742,7 @@ void LibraryModel::FilterQuery(GroupBy type, LibraryItem* item, LibraryQuery* q)
|
||||
q->AddWhere("genre", item->key);
|
||||
break;
|
||||
case GroupBy_AlbumArtist:
|
||||
q->AddWhere("albumartist", item->key);
|
||||
q->AddWhere("effective_albumartist", item->key);
|
||||
break;
|
||||
case GroupBy_FileType:
|
||||
q->AddWhere("filetype", item->metadata.filetype());
|
||||
@ -854,7 +854,7 @@ LibraryItem* LibraryModel::ItemFromSong(GroupBy type,
|
||||
case GroupBy_Composer: item->key = s.composer();
|
||||
case GroupBy_Genre: if (item->key.isNull()) item->key = s.genre();
|
||||
case GroupBy_Album: if (item->key.isNull()) item->key = s.album();
|
||||
case GroupBy_AlbumArtist: if (item->key.isNull()) item->key = s.albumartist();
|
||||
case GroupBy_AlbumArtist: if (item->key.isNull()) item->key = s.effective_albumartist();
|
||||
item->display_text = TextOrUnknown(item->key);
|
||||
item->sort_text = SortTextForArtist(item->key);
|
||||
break;
|
||||
|
@ -322,7 +322,7 @@ QString OSD::ReplaceVariable(const QString& variable, const Song& song) {
|
||||
} else if (variable == "%title%") {
|
||||
return song.PrettyTitle();
|
||||
} else if (variable == "%albumartist%") {
|
||||
return song.albumartist();
|
||||
return song.effective_albumartist();
|
||||
} else if (variable == "%year%") {
|
||||
return song.PrettyYear();
|
||||
} else if (variable == "%composer%") {
|
||||
|
Loading…
Reference in New Issue
Block a user