Use primary type in the album sort key
This commit is contained in:
parent
d8684f7ea0
commit
e0f3ae2fd3
@ -101,14 +101,14 @@ impl From<(u32, u8, u8)> for AlbumDate {
|
|||||||
pub struct AlbumSeq(pub u8);
|
pub struct AlbumSeq(pub u8);
|
||||||
|
|
||||||
/// Based on [MusicBrainz types](https://musicbrainz.org/doc/Release_Group/Type).
|
/// Based on [MusicBrainz types](https://musicbrainz.org/doc/Release_Group/Type).
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub enum AlbumPrimaryType {
|
pub enum AlbumPrimaryType {
|
||||||
/// Album
|
|
||||||
Album,
|
|
||||||
/// Single
|
/// Single
|
||||||
Single,
|
Single,
|
||||||
/// EP
|
/// EP
|
||||||
Ep,
|
Ep,
|
||||||
|
/// Album
|
||||||
|
Album,
|
||||||
/// Broadcast
|
/// Broadcast
|
||||||
Broadcast,
|
Broadcast,
|
||||||
/// Other
|
/// Other
|
||||||
@ -217,8 +217,13 @@ impl AlbumMeta {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_sort_key(&self) -> (&AlbumDate, &AlbumSeq, &AlbumId) {
|
pub fn get_sort_key(&self) -> (&AlbumDate, &AlbumSeq, &str, &Option<AlbumPrimaryType>) {
|
||||||
(&self.date, &self.seq, &self.id)
|
(
|
||||||
|
&self.date,
|
||||||
|
&self.seq,
|
||||||
|
&self.id.title,
|
||||||
|
&self.info.primary_type,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_mb_ref(&mut self, mb_ref: AlbumMbRef) {
|
pub fn set_mb_ref(&mut self, mb_ref: AlbumMbRef) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
|
||||||
use musichoard::collection::{
|
use musichoard::collection::{
|
||||||
album::{Album, AlbumDate, AlbumId, AlbumSeq},
|
album::{Album, AlbumDate, AlbumPrimaryType, AlbumSeq},
|
||||||
track::Track,
|
track::Track,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ impl AlbumSelection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct KeySelectAlbum {
|
pub struct KeySelectAlbum {
|
||||||
key: (AlbumDate, AlbumSeq, AlbumId),
|
key: (AlbumDate, AlbumSeq, String, Option<AlbumPrimaryType>),
|
||||||
track: Option<KeySelectTrack>,
|
track: Option<KeySelectTrack>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,14 +175,19 @@ impl KeySelectAlbum {
|
|||||||
let album = &albums[index];
|
let album = &albums[index];
|
||||||
let key = album.meta.get_sort_key();
|
let key = album.meta.get_sort_key();
|
||||||
KeySelectAlbum {
|
KeySelectAlbum {
|
||||||
key: (key.0.to_owned(), key.1.to_owned(), key.2.to_owned()),
|
key: (
|
||||||
|
key.0.to_owned(),
|
||||||
|
key.1.to_owned(),
|
||||||
|
key.2.to_owned(),
|
||||||
|
key.3.to_owned(),
|
||||||
|
),
|
||||||
track: KeySelectTrack::get(&album.tracks, &selection.track),
|
track: KeySelectTrack::get(&album.tracks, &selection.track),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_sort_key(&self) -> (&AlbumDate, &AlbumSeq, &AlbumId) {
|
pub fn get_sort_key(&self) -> (&AlbumDate, &AlbumSeq, &str, &Option<AlbumPrimaryType>) {
|
||||||
(&self.key.0, &self.key.1, &self.key.2)
|
(&self.key.0, &self.key.1, &self.key.2, &self.key.3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user