mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 17:46:42 +01:00
add placeholders for editing whole directories
This commit is contained in:
parent
d443ccfc96
commit
13600a5837
1 changed files with 24 additions and 20 deletions
44
src/model.rs
44
src/model.rs
|
|
@ -18,14 +18,14 @@ pub struct Taggart {
|
||||||
pub editing: Option<(usize, String)>,
|
pub editing: Option<(usize, String)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Ord, Eq, PartialEq, PartialOrd)]
|
#[derive(Ord, Eq, PartialEq, PartialOrd, Debug)]
|
||||||
pub struct Entry {
|
pub struct Entry {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub depth: usize,
|
pub depth: usize,
|
||||||
pub info: EntryInfo,
|
pub info: EntryInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Ord, Eq, PartialEq, PartialOrd)]
|
#[derive(Ord, Eq, PartialEq, PartialOrd, Debug)]
|
||||||
pub enum EntryInfo {
|
pub enum EntryInfo {
|
||||||
Directory {
|
Directory {
|
||||||
hash_file: Option<()>,
|
hash_file: Option<()>,
|
||||||
|
|
@ -128,44 +128,48 @@ impl Entry {
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn set_artist (&mut self, value: &impl AsRef<str> ) {
|
|
||||||
match self.info {
|
|
||||||
EntryInfo::Music { ref mut artist, .. } => *artist = Some(value.as_ref().into()),
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn album (&self) -> Option<Arc<str>> {
|
pub fn album (&self) -> Option<Arc<str>> {
|
||||||
match self.info {
|
match self.info {
|
||||||
EntryInfo::Music { ref album, .. } => album.clone(),
|
EntryInfo::Music { ref album, .. } => album.clone(),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn set_album (&mut self, value: &impl AsRef<str> ) {
|
|
||||||
match self.info {
|
|
||||||
EntryInfo::Music { ref mut album, .. } => *album = Some(value.as_ref().into()),
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn title (&self) -> Option<Arc<str>> {
|
pub fn title (&self) -> Option<Arc<str>> {
|
||||||
match self.info {
|
match self.info {
|
||||||
EntryInfo::Music { ref title, .. } => title.clone(),
|
EntryInfo::Music { ref title, .. } => title.clone(),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn set_title (&mut self, value: &impl AsRef<str> ) {
|
|
||||||
match self.info {
|
|
||||||
EntryInfo::Music { ref mut title, .. } => *title = Some(value.as_ref().into()),
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn track (&self) -> Option<Arc<str>> {
|
pub fn track (&self) -> Option<Arc<str>> {
|
||||||
match self.info {
|
match self.info {
|
||||||
EntryInfo::Music { ref track, .. } => track.map(|t|format!("{t}").into()).clone(),
|
EntryInfo::Music { ref track, .. } => track.map(|t|format!("{t}").into()).clone(),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn set_artist (&mut self, value: &impl AsRef<str> ) {
|
||||||
|
match self.info {
|
||||||
|
EntryInfo::Directory { .. } => todo!("set artist for whole directory"),
|
||||||
|
EntryInfo::Music { ref mut artist, .. } => *artist = Some(value.as_ref().into()),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn set_album (&mut self, value: &impl AsRef<str> ) {
|
||||||
|
match self.info {
|
||||||
|
EntryInfo::Directory { .. } => todo!("set album for whole directory"),
|
||||||
|
EntryInfo::Music { ref mut album, .. } => *album = Some(value.as_ref().into()),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn set_title (&mut self, value: &impl AsRef<str> ) {
|
||||||
|
match self.info {
|
||||||
|
EntryInfo::Directory { .. } => todo!("set title for whole directory"),
|
||||||
|
EntryInfo::Music { ref mut title, .. } => *title = Some(value.as_ref().into()),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn set_track (&mut self, value: &impl AsRef<str> ) {
|
pub fn set_track (&mut self, value: &impl AsRef<str> ) {
|
||||||
match self.info {
|
match self.info {
|
||||||
|
EntryInfo::Directory { .. } => todo!("set track for whole directory"),
|
||||||
EntryInfo::Music { ref mut track, .. } => {
|
EntryInfo::Music { ref mut track, .. } => {
|
||||||
if let Ok(value) = value.as_ref().trim().parse::<u32>() {
|
if let Ok(value) = value.as_ref().trim().parse::<u32>() {
|
||||||
*track = Some(value)
|
*track = Some(value)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue