Add a filtering tool to only show only certain release group types #252
@ -138,6 +138,7 @@ pub enum AlbumSecondaryType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The album's ownership status.
|
/// The album's ownership status.
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum AlbumOwnership {
|
pub enum AlbumOwnership {
|
||||||
None,
|
None,
|
||||||
Owned(TrackFormat),
|
Owned(TrackFormat),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::core::{
|
use crate::core::{
|
||||||
interface::{database::IDatabase, library::ILibrary},
|
interface::{database::IDatabase, library::ILibrary},
|
||||||
musichoard::{database::IMusicHoardDatabase, Error, MusicHoard, NoDatabase, NoLibrary},
|
musichoard::{database::IMusicHoardDatabase, Error, MusicHoard, NoDatabase, NoLibrary, CollectionFilter},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Builder for [`MusicHoard`]. Its purpose is to make it easier to set various combinations of
|
/// Builder for [`MusicHoard`]. Its purpose is to make it easier to set various combinations of
|
||||||
@ -62,6 +62,8 @@ impl MusicHoard<NoDatabase, NoLibrary> {
|
|||||||
/// Create a new [`MusicHoard`] without any library or database.
|
/// Create a new [`MusicHoard`] without any library or database.
|
||||||
pub fn empty() -> Self {
|
pub fn empty() -> Self {
|
||||||
MusicHoard {
|
MusicHoard {
|
||||||
|
filter: CollectionFilter::default(),
|
||||||
|
filtered: vec![],
|
||||||
collection: vec![],
|
collection: vec![],
|
||||||
pre_commit: vec![],
|
pre_commit: vec![],
|
||||||
database: NoDatabase,
|
database: NoDatabase,
|
||||||
@ -83,6 +85,8 @@ impl<Library: ILibrary> MusicHoard<NoDatabase, Library> {
|
|||||||
/// Create a new [`MusicHoard`] with the provided [`ILibrary`] and no database.
|
/// Create a new [`MusicHoard`] with the provided [`ILibrary`] and no database.
|
||||||
pub fn library(library: Library) -> Self {
|
pub fn library(library: Library) -> Self {
|
||||||
MusicHoard {
|
MusicHoard {
|
||||||
|
filter: CollectionFilter::default(),
|
||||||
|
filtered: vec![],
|
||||||
collection: vec![],
|
collection: vec![],
|
||||||
pre_commit: vec![],
|
pre_commit: vec![],
|
||||||
database: NoDatabase,
|
database: NoDatabase,
|
||||||
@ -104,6 +108,8 @@ impl<Database: IDatabase> MusicHoard<Database, NoLibrary> {
|
|||||||
/// Create a new [`MusicHoard`] with the provided [`IDatabase`] and no library.
|
/// Create a new [`MusicHoard`] with the provided [`IDatabase`] and no library.
|
||||||
pub fn database(database: Database) -> Result<Self, Error> {
|
pub fn database(database: Database) -> Result<Self, Error> {
|
||||||
let mut mh = MusicHoard {
|
let mut mh = MusicHoard {
|
||||||
|
filter: CollectionFilter::default(),
|
||||||
|
filtered: vec![],
|
||||||
collection: vec![],
|
collection: vec![],
|
||||||
pre_commit: vec![],
|
pre_commit: vec![],
|
||||||
database,
|
database,
|
||||||
@ -127,6 +133,8 @@ impl<Database: IDatabase, Library: ILibrary> MusicHoard<Database, Library> {
|
|||||||
/// Create a new [`MusicHoard`] with the provided [`ILibrary`] and [`IDatabase`].
|
/// Create a new [`MusicHoard`] with the provided [`ILibrary`] and [`IDatabase`].
|
||||||
pub fn new(database: Database, library: Library) -> Result<Self, Error> {
|
pub fn new(database: Database, library: Library) -> Result<Self, Error> {
|
||||||
let mut mh = MusicHoard {
|
let mut mh = MusicHoard {
|
||||||
|
filter: CollectionFilter::default(),
|
||||||
|
filtered: vec![],
|
||||||
collection: vec![],
|
collection: vec![],
|
||||||
pre_commit: vec![],
|
pre_commit: vec![],
|
||||||
database,
|
database,
|
||||||
|
@ -12,11 +12,16 @@ pub use library::IMusicHoardLibrary;
|
|||||||
|
|
||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
|
|
||||||
use crate::core::collection::Collection;
|
use crate::core::{
|
||||||
|
collection::{
|
||||||
use crate::core::interface::{
|
album::{AlbumOwnership, AlbumPrimaryType, AlbumSecondaryType},
|
||||||
|
track::TrackFormat,
|
||||||
|
Collection,
|
||||||
|
},
|
||||||
|
interface::{
|
||||||
database::{LoadError as DatabaseLoadError, SaveError as DatabaseSaveError},
|
database::{LoadError as DatabaseLoadError, SaveError as DatabaseSaveError},
|
||||||
library::Error as LibraryError,
|
library::Error as LibraryError,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The Music Hoard. It is responsible for pulling information from both the library and the
|
/// The Music Hoard. It is responsible for pulling information from both the library and the
|
||||||
@ -24,6 +29,8 @@ use crate::core::interface::{
|
|||||||
// TODO: Split into inner and external/interfaces to facilitate building.
|
// TODO: Split into inner and external/interfaces to facilitate building.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MusicHoard<Database, Library> {
|
pub struct MusicHoard<Database, Library> {
|
||||||
|
filter: CollectionFilter,
|
||||||
|
filtered: Collection,
|
||||||
collection: Collection,
|
collection: Collection,
|
||||||
pre_commit: Collection,
|
pre_commit: Collection,
|
||||||
database: Database,
|
database: Database,
|
||||||
@ -32,6 +39,32 @@ pub struct MusicHoard<Database, Library> {
|
|||||||
library_cache: Collection,
|
library_cache: Collection,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Filter for a specifying subsets of the entire collection (e.g., for display).
|
||||||
|
// Filter is inclusive, not exclusive. To include something in the filtered collection, the filter
|
||||||
|
// must select it. It also means that the options below are additive - the more options are set, the
|
||||||
|
// more items will be included.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct CollectionFilter {
|
||||||
|
primary_types: Vec<AlbumPrimaryType>,
|
||||||
|
secondary_types: Vec<AlbumSecondaryType>,
|
||||||
|
include_untyped: bool,
|
||||||
|
ownership: Vec<AlbumOwnership>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for CollectionFilter {
|
||||||
|
fn default() -> Self {
|
||||||
|
CollectionFilter {
|
||||||
|
primary_types: vec![AlbumPrimaryType::Ep, AlbumPrimaryType::Album],
|
||||||
|
secondary_types: vec![],
|
||||||
|
include_untyped: true,
|
||||||
|
ownership: vec![
|
||||||
|
AlbumOwnership::Owned(TrackFormat::Mp3),
|
||||||
|
AlbumOwnership::Owned(TrackFormat::Flac),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Phantom type for when a library implementation is not needed.
|
/// Phantom type for when a library implementation is not needed.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NoLibrary;
|
pub struct NoLibrary;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user