mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Store source track index in track
This commit is contained in:
parent
622f1312fb
commit
d410be75dc
6 changed files with 15 additions and 4 deletions
|
|
@ -66,6 +66,7 @@ CREATE TABLE "tracks" (
|
|||
"index" INTEGER NOT NULL,
|
||||
"recording" TEXT NOT NULL REFERENCES "recordings"("id"),
|
||||
"work_parts" TEXT NOT NULL,
|
||||
"source_index" INTEGER NOT NULL,
|
||||
"path" TEXT NOT NULL
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ pub struct Track {
|
|||
/// work parts of the work that is associated with the recording.
|
||||
pub work_parts: Vec<usize>,
|
||||
|
||||
/// The index of the track within its source. This is used to associate
|
||||
/// the metadata with the audio data from the source when importing.
|
||||
pub source_index: usize,
|
||||
|
||||
/// The path to the audio file containing this track. This will not be
|
||||
/// included when communicating with the server.
|
||||
#[serde(skip)]
|
||||
|
|
@ -57,6 +61,7 @@ struct TrackRow {
|
|||
pub index: i32,
|
||||
pub recording: String,
|
||||
pub work_parts: String,
|
||||
pub source_index: i32,
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
|
|
@ -105,6 +110,7 @@ impl Database {
|
|||
index: index as i32,
|
||||
recording: track.recording.id.clone(),
|
||||
work_parts,
|
||||
source_index: track.source_index as i32,
|
||||
path: track.path.clone(),
|
||||
};
|
||||
|
||||
|
|
@ -274,6 +280,7 @@ impl Database {
|
|||
let track = Track {
|
||||
recording,
|
||||
work_parts: part_indices,
|
||||
source_index: row.source_index as usize,
|
||||
path: row.path,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ table! {
|
|||
index -> Integer,
|
||||
recording -> Text,
|
||||
work_parts -> Text,
|
||||
source_index -> Integer,
|
||||
path -> Text,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use glib::clone;
|
|||
use gtk::prelude::*;
|
||||
use gtk_macros::get_widget;
|
||||
use libadwaita::prelude::*;
|
||||
use log::debug;
|
||||
use musicus_backend::Error;
|
||||
use musicus_backend::db::Medium;
|
||||
use musicus_backend::import::ImportSession;
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ impl MediumEditor {
|
|||
let track = Track {
|
||||
recording: track_set_data.recording.clone(),
|
||||
work_parts: track_data.work_parts.clone(),
|
||||
source_index: track_data.track_source,
|
||||
path: String::new(),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ impl Screen<(Arc<ImportSession>, Medium), ()> for MediumPreview {
|
|||
let mut last_recording_id = "";
|
||||
let mut last_list = None::<gtk::ListBox>;
|
||||
|
||||
let import_tracks = this.session.tracks();
|
||||
|
||||
for track in &this.medium.tracks {
|
||||
if track.recording.id != last_recording_id {
|
||||
last_recording_id = &track.recording.id;
|
||||
|
|
@ -109,7 +111,7 @@ impl Screen<(Arc<ImportSession>, Medium), ()> for MediumPreview {
|
|||
let row = libadwaita::ActionRowBuilder::new()
|
||||
.activatable(false)
|
||||
.title(&title)
|
||||
.subtitle(&track.path)
|
||||
.subtitle(&import_tracks[track.source_index].name)
|
||||
.margin_start(12)
|
||||
.build();
|
||||
|
||||
|
|
@ -170,12 +172,12 @@ impl MediumPreview {
|
|||
let mut tracks = Vec::new();
|
||||
let import_tracks = self.session.tracks();
|
||||
|
||||
for (index, track) in self.medium.tracks.iter().enumerate() {
|
||||
for track in &self.medium.tracks {
|
||||
let mut track = track.clone();
|
||||
|
||||
// Set the track path to the new audio file location.
|
||||
|
||||
let import_track = &import_tracks[index];
|
||||
let import_track = &import_tracks[track.source_index];
|
||||
let track_path = directory.join(import_track.path.file_name().unwrap());
|
||||
track.path = track_path.to_str().unwrap().to_owned();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue