mirror of
				https://github.com/johrpan/musicus.git
				synced 2025-10-26 19:57:25 +01:00 
			
		
		
		
	Initialize work and recording editors
This commit is contained in:
		
							parent
							
								
									3339945380
								
							
						
					
					
						commit
						e2d36a88b8
					
				
					 5 changed files with 43 additions and 4 deletions
				
			
		
							
								
								
									
										1
									
								
								musicus/.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								musicus/.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -1,4 +1,5 @@ | ||||||
| /.flatpak-builder | /.flatpak-builder | ||||||
|  | /.vscode | ||||||
| /build | /build | ||||||
| /builddir | /builddir | ||||||
| /flatpak | /flatpak | ||||||
|  |  | ||||||
|  | @ -1,3 +1,4 @@ | ||||||
|  | use super::generate_id; | ||||||
| use super::schema::{ensembles, performances, persons, recordings}; | use super::schema::{ensembles, performances, persons, recordings}; | ||||||
| use super::{Database, Ensemble, Instrument, Person, Work}; | use super::{Database, Ensemble, Instrument, Person, Work}; | ||||||
| use anyhow::{anyhow, Error, Result}; | use anyhow::{anyhow, Error, Result}; | ||||||
|  | @ -93,6 +94,16 @@ pub struct Recording { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl Recording { | impl Recording { | ||||||
|  |     /// Initialize a new recording with a work.
 | ||||||
|  |     pub fn new(work: Work) -> Self { | ||||||
|  |         Self { | ||||||
|  |             id: generate_id(), | ||||||
|  |             work, | ||||||
|  |             comment: String::new(), | ||||||
|  |             performances: Vec::new(), | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     /// Get a string representation of the performances in this recording.
 |     /// Get a string representation of the performances in this recording.
 | ||||||
|     // TODO: Maybe replace with impl Display?
 |     // TODO: Maybe replace with impl Display?
 | ||||||
|     pub fn get_performers(&self) -> String { |     pub fn get_performers(&self) -> String { | ||||||
|  |  | ||||||
|  | @ -1,3 +1,4 @@ | ||||||
|  | use super::generate_id; | ||||||
| use super::schema::{instrumentations, work_parts, work_sections, works}; | use super::schema::{instrumentations, work_parts, work_sections, works}; | ||||||
| use super::{Database, Instrument, Person}; | use super::{Database, Instrument, Person}; | ||||||
| use anyhow::{anyhow, Error, Result}; | use anyhow::{anyhow, Error, Result}; | ||||||
|  | @ -83,6 +84,18 @@ pub struct Work { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl Work { | impl Work { | ||||||
|  |     /// Initialize a new work with a composer.
 | ||||||
|  |     pub fn new(composer: Person) -> Self { | ||||||
|  |         Self { | ||||||
|  |             id: generate_id(), | ||||||
|  |             title: String::new(), | ||||||
|  |             composer, | ||||||
|  |             instruments: Vec::new(), | ||||||
|  |             parts: Vec::new(), | ||||||
|  |             sections: Vec::new(), | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     /// Get a string including the composer and title of the work.
 |     /// Get a string including the composer and title of the work.
 | ||||||
|     // TODO: Replace with impl Display.
 |     // TODO: Replace with impl Display.
 | ||||||
|     pub fn get_title(&self) -> String { |     pub fn get_title(&self) -> String { | ||||||
|  |  | ||||||
|  | @ -47,9 +47,16 @@ impl RecordingSelector { | ||||||
|         this.selector.set_add_cb(clone!(@strong this => move || { |         this.selector.set_add_cb(clone!(@strong this => move || { | ||||||
|             let navigator = this.navigator.borrow().clone(); |             let navigator = this.navigator.borrow().clone(); | ||||||
|             if let Some(navigator) = navigator { |             if let Some(navigator) = navigator { | ||||||
|                 let editor = RecordingEditor::new(this.backend.clone(), None); |                 let recording = Recording::new(this.work.clone()); | ||||||
|  | 
 | ||||||
|  |                 let editor = RecordingEditor::new(this.backend.clone(), Some(recording)); | ||||||
|  |                 
 | ||||||
|                 editor |                 editor | ||||||
|                     .set_selected_cb(clone!(@strong this => move |recording| this.select(&recording))); |                     .set_selected_cb(clone!(@strong this, @strong navigator => move |recording| { | ||||||
|  |                         navigator.clone().pop(); | ||||||
|  |                         this.select(&recording); | ||||||
|  |                     })); | ||||||
|  |                 
 | ||||||
|                 navigator.push(editor); |                 navigator.push(editor); | ||||||
|             } |             } | ||||||
|         })); |         })); | ||||||
|  |  | ||||||
|  | @ -47,9 +47,16 @@ impl WorkSelector { | ||||||
|         this.selector.set_add_cb(clone!(@strong this => move || { |         this.selector.set_add_cb(clone!(@strong this => move || { | ||||||
|             let navigator = this.navigator.borrow().clone(); |             let navigator = this.navigator.borrow().clone(); | ||||||
|             if let Some(navigator) = navigator { |             if let Some(navigator) = navigator { | ||||||
|                 let editor = WorkEditor::new(this.backend.clone(), None); |                 let work = Work::new(this.person.clone()); | ||||||
|  | 
 | ||||||
|  |                 let editor = WorkEditor::new(this.backend.clone(), Some(work)); | ||||||
|  | 
 | ||||||
|                 editor |                 editor | ||||||
|                     .set_saved_cb(clone!(@strong this => move |work| this.select(&work))); |                     .set_saved_cb(clone!(@strong this, @strong navigator => move |work| { | ||||||
|  |                         navigator.clone().pop(); | ||||||
|  |                         this.select(&work); | ||||||
|  |                     })); | ||||||
|  | 
 | ||||||
|                 navigator.push(editor); |                 navigator.push(editor); | ||||||
|             } |             } | ||||||
|         })); |         })); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Elias Projahn
						Elias Projahn