feat(purchases): readable dates, a release-date column and sort, column labels

The list printed the purchase date as "9/1/26" and nothing else, so a
row said neither when the record came out nor, at a glance, what the
number meant. Rows now carry the catalog's original release date next to
the purchase date, both as "Sep 1, 2026", under a column-label strip
like the album list's, and the toolbar sorts by release date (`released`)
beside the four existing keys.

cc
This commit is contained in:
vicrodh committed 2026-09-01 23:59:36 -06:00
1 parent 0756e96940
commit e41235f791
13 files changed
+209 -11

No files matched your search

@@ -6346,3 +6346,12 @@ msgstr "Bei Wiedergabekonflikten"
msgid "Ask each time or automatically choose which queue and device should continue."
msgstr "Jedes Mal nachfragen oder automatisch auswählen, welche Warteschlange und welches Gerät fortfahren sollen."
msgid "Purchased"
msgstr "Gekauft"
msgid "Sort: Release date"
msgstr "Sortierung: Veröffentlichungsdatum"
msgid "Until the purchased file is downloaded, Play streams the best quality Qobuz offers for this album. Once it is on disk, Play uses your copy."
msgstr "Solange die gekaufte Datei nicht heruntergeladen ist, streamt Wiedergabe die beste Qualität, die Qobuz für dieses Album anbietet. Sobald sie auf der Festplatte liegt, verwendet Wiedergabe deine Kopie."
@@ -6352,3 +6352,12 @@ msgstr "Cuando la reproducción entre en conflicto"
msgid "Ask each time or automatically choose which queue and device should continue."
msgstr "Preguntar cada vez o elegir automáticamente qué cola y dispositivo deben continuar."
msgid "Purchased"
msgstr "Comprado"
msgid "Sort: Release date"
msgstr "Orden: Fecha de lanzamiento"
msgid "Until the purchased file is downloaded, Play streams the best quality Qobuz offers for this album. Once it is on disk, Play uses your copy."
msgstr "Mientras no descargues el archivo comprado, Reproducir usa la mejor calidad que Qobuz ofrece para este álbum. Cuando ya esté en disco, Reproducir usa tu copia."
@@ -6344,3 +6344,12 @@ msgstr "En cas de conflit de lecture"
msgid "Ask each time or automatically choose which queue and device should continue."
msgstr "Demander à chaque fois ou choisir automatiquement la file d’attente et l’appareil qui doivent continuer."
msgid "Purchased"
msgstr "Acheté"
msgid "Sort: Release date"
msgstr "Tri : Date de sortie"
msgid "Until the purchased file is downloaded, Play streams the best quality Qobuz offers for this album. Once it is on disk, Play uses your copy."
msgstr "Tant que le fichier acheté n’est pas téléchargé, Lecture diffuse la meilleure qualité que Qobuz propose pour cet album. Une fois sur le disque, Lecture utilise votre copie."
@@ -6327,3 +6327,12 @@ msgstr "再生が競合した場合"
msgid "Ask each time or automatically choose which queue and device should continue."
msgstr "毎回確認するか、続行するキューとデバイスを自動的に選択します。"
msgid "Purchased"
msgstr "購入日"
msgid "Sort: Release date"
msgstr "並び替え: 発売日"
msgid "Until the purchased file is downloaded, Play streams the best quality Qobuz offers for this album. Once it is on disk, Play uses your copy."
msgstr "購入したファイルをダウンロードするまでは、このアルバムに Qobuz が提供する最高品質でストリーミング再生します。ディスクに保存されると、再生はあなたのコピーを使います。"
@@ -6334,3 +6334,12 @@ msgstr "Bij een afspeelconflict"
msgid "Ask each time or automatically choose which queue and device should continue."
msgstr "Vraag het elke keer of kies automatisch welke wachtrij en welk apparaat doorgaan."
msgid "Purchased"
msgstr "Gekocht"
msgid "Sort: Release date"
msgstr "Sorteren: Releasedatum"
msgid "Until the purchased file is downloaded, Play streams the best quality Qobuz offers for this album. Once it is on disk, Play uses your copy."
msgstr "Zolang het gekochte bestand niet is gedownload, streamt Afspelen de beste kwaliteit die Qobuz voor dit album biedt. Zodra het op schijf staat, gebruikt Afspelen jouw kopie."
@@ -6344,3 +6344,12 @@ msgstr "Quando houver conflito de reprodução"
msgid "Ask each time or automatically choose which queue and device should continue."
msgstr "Perguntar sempre ou escolher automaticamente qual fila e dispositivo devem continuar."
msgid "Purchased"
msgstr "Comprado"
msgid "Sort: Release date"
msgstr "Ordenar: Data de lançamento"
msgid "Until the purchased file is downloaded, Play streams the best quality Qobuz offers for this album. Once it is on disk, Play uses your copy."
msgstr "Enquanto o ficheiro comprado não for descarregado, Reproduzir transmite a melhor qualidade que a Qobuz oferece para este álbum. Assim que estiver no disco, Reproduzir usa a sua cópia."
@@ -6365,3 +6365,12 @@ msgstr "При конфликте воспроизведения"
msgid "Ask each time or automatically choose which queue and device should continue."
msgstr "Спрашивать каждый раз или автоматически выбирать, какая очередь и устройство продолжат воспроизведение."
msgid "Purchased"
msgstr "Куплено"
msgid "Sort: Release date"
msgstr "Сортировка: Дата выхода"
msgid "Until the purchased file is downloaded, Play streams the best quality Qobuz offers for this album. Once it is on disk, Play uses your copy."
msgstr "Пока купленный файл не скачан, воспроизведение идёт в лучшем качестве, которое Qobuz предлагает для этого альбома. Как только он окажется на диске, воспроизводится ваша копия."
+1
View File
@@ -890,6 +890,7 @@ fn main() {
"qml/views/purchases/PurchaseAlbumsCollection.qml",
"qml/views/purchases/PurchaseGridCard.qml",
"qml/views/purchases/PurchaseListRow.qml",
"qml/views/purchases/PurchaseListHeader.qml",
"qml/views/purchases/PurchaseTrackRow.qml",
"qml/views/purchases/PurchasesToolbar.qml",
// Playlist Manager (route "playlistmanager"): the router target
@@ -39,6 +39,8 @@ Item {
readonly property int cardGap: 16
readonly property int listRowHeight: 60
readonly property int listGap: 4
/// The column-label strip above the rows (PurchaseListHeader), list arm only.
readonly property int listHeaderHeight: 28
readonly property int columns: Math.max(
1, Math.floor((width + root.cardGap) / (root.cardWidth + root.cardGap)))
@@ -49,7 +51,8 @@ Item {
// Content-sized: the page Flickable reads this through its Column.
height: root.viewMode === "list"
? (root.albums.length > 0
? root.albums.length * root.listRowHeight
? root.listHeaderHeight + root.listGap
+ root.albums.length * root.listRowHeight
+ (root.albums.length - 1) * root.listGap
: 0)
: (root.gridRows > 0
@@ -83,6 +86,11 @@ Item {
visible: root.viewMode === "list"
anchors.fill: parent
spacing: root.listGap
PurchaseListHeader {
visible: root.viewMode === "list" && root.albums.length > 0
width: parent.width
height: root.listHeaderHeight
}
Repeater {
model: root.viewMode === "list" ? root.albums : []
delegate: PurchaseListRow {
@@ -0,0 +1,49 @@
// PurchaseListHeader — the column labels above the purchases list rows.
// Widths mirror PurchaseListRow (art 48 · stretch · quality · released ·
// purchased, 12px gaps, 8/12 margins) so each label sits on its column, the
// way views/AlbumListHeader.qml does for the album list.
import QtQuick
import com.blitzfc.qbz
import "../../theme"
Item {
id: root
QbzTheme { id: theme }
function t(s) { return QbzSession.tr(s, QbzSession.trRev) }
readonly property int colQuality: 110
readonly property int colReleased: 120
readonly property int colPurchased: 130
width: parent ? parent.width : 0
height: 28
component ColLabel: Text {
color: theme.textMuted
font.pixelSize: 11
font.weight: theme.weightSemibold
font.letterSpacing: 0.5
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
height: parent.height
}
Row {
anchors.fill: parent
anchors.leftMargin: 8
anchors.rightMargin: 12
spacing: 12
Item { width: 48; height: 1 }
ColLabel {
width: Math.max(0, parent.width - 48
- root.colQuality - root.colReleased - root.colPurchased - 4 * 12)
text: root.t("Title").toUpperCase()
}
ColLabel { width: root.colQuality; text: root.t("Quality").toUpperCase() }
ColLabel { width: root.colReleased; text: root.t("Release date").toUpperCase() }
ColLabel { width: root.colPurchased; text: root.t("Purchased").toUpperCase() }
}
}
@@ -33,8 +33,21 @@ Rectangle {
function t(s) { return QbzSession.tr(s, QbzSession.trRev) }
/// Epoch -> the viewer's short date. "" for a row that carries no stamp,
/// so the column collapses to blank rather than to 1970.
/// Column widths, shared with PurchaseListHeader so the labels sit on
/// their columns.
readonly property int colQuality: 110
readonly property int colReleased: 120
readonly property int colPurchased: 130
/// A date the way a person reads one ("Sep 1, 2026"), never the numeric
/// short form ("9/1/26") that the first port used: the two date columns
/// sit side by side and a reader has to tell them apart at a glance.
function readableDate(d) {
return Qt.formatDate(d, "MMM d, yyyy")
}
/// Epoch -> readable date. "" for a row that carries no stamp, so the
/// column collapses to blank rather than to 1970.
function purchaseDate() {
var ts = root.album.purchasedAt || 0
if (ts <= 0)
@@ -42,7 +55,20 @@ Rectangle {
// Defensive: the seam says seconds, but a producer that ever hands
// milliseconds through would otherwise print a date in the year 55000.
var ms = ts > 100000000000 ? ts : ts * 1000
return new Date(ms).toLocaleDateString(Qt.locale(), Locale.ShortFormat)
return root.readableDate(new Date(ms))
}
/// ISO `YYYY-MM-DD` -> readable date; a bare year stays a year; "" stays "".
function releaseDate() {
var iso = root.album.releaseDate || ""
if (iso === "")
return root.album.year || ""
var parts = iso.split("-")
if (parts.length < 3)
return parts[0]
// Local-time construction: `new Date("YYYY-MM-DD")` parses as UTC and
// prints the previous day west of Greenwich.
return root.readableDate(new Date(parseInt(parts[0]), parseInt(parts[1]) - 1, parseInt(parts[2])))
}
width: parent ? parent.width : 0
@@ -95,9 +121,10 @@ Rectangle {
// Title over artist — the stretch column.
Column {
width: Math.max(0, parent.width - 48 - 110 - 110
width: Math.max(0, parent.width - 48
- root.colQuality - root.colReleased - root.colPurchased
- (unavailLabel.visible ? unavailLabel.width + 12 : 0)
- 3 * 12)
- 4 * 12)
anchors.verticalCenter: parent.verticalCenter
spacing: 2
Text {
@@ -120,24 +147,34 @@ Rectangle {
// Quality column — the SAME badge the album list rows show
// (views/AlbumListRow.qml): tier label over the exact quality line.
Item {
width: 110
width: root.colQuality
height: parent.height
QualityBadgeFull {
anchors.right: parent.right
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
tier: root.album.qualityTier || ""
detail: root.album.qualityDetail || ""
}
}
// Release-date column (the catalog's original release).
Text {
width: root.colReleased
height: parent.height
text: root.releaseDate()
color: theme.textSecondary
font.pixelSize: theme.fontLegal
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
// Purchase-date column.
Text {
width: 110
width: root.colPurchased
height: parent.height
text: root.purchaseDate()
color: theme.textMuted
font.pixelSize: theme.fontLegal
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
@@ -324,6 +324,7 @@ Item {
label: root.sortKey === "artist" ? root.t("Sort: Artist")
: root.sortKey === "album" ? root.t("Sort: Album")
: root.sortKey === "quality" ? root.t("Sort: Quality")
: root.sortKey === "released" ? root.t("Sort: Release date")
: root.t("Sort: Date")
onClicked: sortMenu.openBelowLeft(sortBtn)
@@ -352,6 +353,12 @@ Item {
arrow: sortBtn.arrowFor("purchased")
onPicked: sortBtn.pick("purchased")
}
MenuRow {
label: root.t("Release date")
selected: root.sortKey === "released"
arrow: sortBtn.arrowFor("released")
onPicked: sortBtn.pick("released")
}
MenuRow {
label: root.t("Artist")
selected: root.sortKey === "artist"
+34 -1
View File
@@ -132,6 +132,11 @@ struct AlbumRow {
#[serde(rename = "artPath")]
art_path: String,
year: String,
/// ADDITIVE: the full `release_date_original` (ISO `YYYY-MM-DD`, `""` when
/// the listing has none), so the list can show a readable release date
/// next to the purchase date and sort by it.
#[serde(rename = "releaseDate")]
release_date: String,
genre: String,
#[serde(rename = "qualityTier")]
quality_tier: String,
@@ -962,7 +967,8 @@ fn build_list_doc(s: &ListState) -> ListDoc {
}
}
/// `sortAlbums` (`:211-…`): `dir = asc ? 1 : -1`, applied to one of four keys.
/// `sortAlbums` (`:211-…`): `dir = asc ? 1 : -1`, applied to one of five keys
/// (`released` is ours — the reference had no release-date sort).
/// `"purchased"` is §G.2's spelling of the reference's `"date"`; both are
/// accepted so a QML lane written against either name works.
fn sort_albums(list: &mut [&PurchaseAlbum], key: &str, ascending: bool) {
@@ -970,6 +976,16 @@ fn sort_albums(list: &mut [&PurchaseAlbum], key: &str, ascending: bool) {
match key {
"artist" => list.sort_by(|a, b| flip(a.artist.name.cmp(&b.artist.name))),
"album" | "title" => list.sort_by(|a, b| flip(a.title.cmp(&b.title))),
// ISO dates compare as strings; an album without one sorts first
// ascending / last descending, never among the dated ones.
"released" => list.sort_by(|a, b| {
flip(
a.release_date_original
.as_deref()
.unwrap_or("")
.cmp(b.release_date_original.as_deref().unwrap_or("")),
)
}),
// `(a.sr||0)-(b.sr||0) || (a.bd||0)-(b.bd||0)`
"quality" => list.sort_by(|a, b| {
let asr = a.maximum_sampling_rate.unwrap_or(0.0);
@@ -1017,6 +1033,7 @@ fn album_row(a: &PurchaseAlbum) -> AlbumRow {
year: svc::parse_release_year(a.release_date_original.as_deref())
.map(|y| y.to_string())
.unwrap_or_default(),
release_date: a.release_date_original.clone().unwrap_or_default(),
genre: a.genre.as_ref().map(|g| g.name.clone()).unwrap_or_default(),
quality_tier: quality.0,
quality_detail: quality.1,
@@ -2861,6 +2878,22 @@ mod tests {
assert_eq!(by_date[0].id, "2");
}
#[test]
fn sorting_by_release_date_orders_iso_strings_and_parks_the_undated() {
let mut a = album("a", "A", "X");
a.release_date_original = Some("2024-03-01".to_string());
let mut b = album("b", "B", "X");
b.release_date_original = Some("1990-09-24".to_string());
let c = album("c", "C", "X");
let mut list: Vec<&PurchaseAlbum> = vec![&a, &b, &c];
sort_albums(&mut list, "released", false);
let ids: Vec<&str> = list.iter().map(|x| x.id.as_str()).collect();
assert_eq!(ids, vec!["a", "b", "c"], "newest first, undated last");
sort_albums(&mut list, "released", true);
let ids: Vec<&str> = list.iter().map(|x| x.id.as_str()).collect();
assert_eq!(ids, vec!["c", "b", "a"]);
}
#[test]
fn sorting_by_quality_compares_rate_then_depth() {
let mut low = album("1", "Low", "X");