mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 19:45:31 +01:00
Show "Unknown" instead of "0" when sorting by year for albums that don't have a year set. Updates issue #188
This commit is contained in:
parent
539f0a517b
commit
55946ac2ba
@ -239,7 +239,7 @@ QString Library::DividerKey(GroupBy type, LibraryItem* item) const {
|
||||
return SortTextForYear(item->sort_text.toInt() / 10 * 10);
|
||||
|
||||
case GroupBy_YearAlbum:
|
||||
return QString::number(item->metadata.year());
|
||||
return SortTextForYear(item->metadata.year());
|
||||
|
||||
case GroupBy_None:
|
||||
default:
|
||||
@ -258,12 +258,16 @@ QString Library::DividerDisplayText(GroupBy type, const QString& key) const {
|
||||
case GroupBy_Genre:
|
||||
if (key == "0")
|
||||
return "0-9";
|
||||
// fallthrough
|
||||
return key.toUpper();
|
||||
|
||||
case GroupBy_YearAlbum:
|
||||
return key;
|
||||
if (key == "0000")
|
||||
return tr("Unknown");
|
||||
return key.toUpper();
|
||||
|
||||
case GroupBy_Year:
|
||||
if (key == "0000")
|
||||
return tr("Unknown");
|
||||
return QString::number(key.toInt()); // To remove leading 0s
|
||||
|
||||
case GroupBy_None:
|
||||
@ -683,6 +687,8 @@ QString Library::TextOrUnknown(const QString& text) const {
|
||||
}
|
||||
|
||||
QString Library::PrettyYearAlbum(int year, const QString& album) const {
|
||||
if (year <= 0)
|
||||
return TextOrUnknown(album);
|
||||
return QString::number(year) + " - " + TextOrUnknown(album);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ void LibraryItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
|
||||
|
||||
switch (type) {
|
||||
case LibraryItem::Type_Divider: {
|
||||
QString text(index.data().toString().toUpper());
|
||||
QString text(index.data().toString());
|
||||
|
||||
// Draw the background
|
||||
//QStyledItemDelegate::paint(painter, opt, QModelIndex());
|
||||
|
Loading…
x
Reference in New Issue
Block a user