trying to tweak song editor to work

This commit is contained in:
Chris Cochrun 2023-12-01 09:54:16 -06:00
parent 2fcfadb7f4
commit 3f9a1714c4
2 changed files with 66 additions and 76 deletions

View file

@ -248,7 +248,7 @@ use self::song_model::{
SongRoles,
};
#[derive(Default, Clone, Debug)]
#[derive(Clone, Debug)]
pub struct Song {
id: i32,
title: String,
@ -265,6 +265,18 @@ pub struct Song {
font_size: i32,
}
impl Default for Song {
fn default() -> Self {
Self {
horizontal_text_alignment: String::from("Center"),
vertical_text_alignment: String::from("Center"),
font: String::from("Quicksand Bold"),
font_size: 50,
..Default::default()
}
}
}
#[derive(Default, Debug)]
pub struct SongModelRust {
count: i32,
@ -451,18 +463,19 @@ impl song_model::SongModel {
) -> (usize, QModelIndex, QVector_i32) {
let mut vector_roles = QVector_i32::default();
vector_roles.append(self.as_ref().get_role(role));
let index = self
.as_ref()
.songs
.iter()
.position(|x| x.id == song_id)
.unwrap();
let model_index = self.as_ref().index(
index as i32,
0,
&QModelIndex::default(),
);
(index, model_index, vector_roles)
if let Some(index) =
self.as_ref().songs.iter().position(|x| x.id == song_id)
{
let model_index = self.as_ref().index(
index as i32,
0,
&QModelIndex::default(),
);
(index, model_index, vector_roles)
} else {
error!(song_id, "This song appears to be missing");
(0, QModelIndex::default(), vector_roles)
}
}
pub fn update_title(