Refactoring to slide_model and service_item getting the data from db

This is kinda a broken commit. There isn't any order to the adding of
the slide anymore. So it'll need to find a way of keeping track of
where all the current slides are and then insert the new ones in the
correct order while moving the others around as well.
This commit is contained in:
Chris Cochrun 2024-10-02 14:48:16 -05:00
parent 6052cd01ac
commit 2c014e242f
9 changed files with 347 additions and 604 deletions

View file

@ -78,7 +78,6 @@ mod service_item_model {
#[qsignal]
fn item_added(
self: Pin<&mut ServiceItemModel>,
index: &i32,
id: &i32,
kind: &QString,
);
@ -122,16 +121,6 @@ mod service_item_model {
self: Pin<&mut ServiceItemModel>,
name: QString,
ty: QString,
background: QString,
background_type: QString,
text: QStringList,
audio: QString,
font: QString,
font_size: i32,
slide_count: i32,
looping: bool,
video_start_time: f32,
video_end_time: f32,
id: i32,
);
@ -140,17 +129,7 @@ mod service_item_model {
self: Pin<&mut ServiceItemModel>,
index: i32,
name: QString,
text: QStringList,
ty: QString,
background: QString,
background_type: QString,
audio: QString,
font: QString,
font_size: i32,
slide_count: i32,
looping: bool,
video_start_time: f32,
video_end_time: f32,
id: i32,
);
@ -423,31 +402,11 @@ impl service_item_model::ServiceItemModel {
mut self: Pin<&mut Self>,
name: QString,
ty: QString,
background: QString,
background_type: QString,
text: QStringList,
audio: QString,
font: QString,
font_size: i32,
slide_count: i32,
looping: bool,
video_start_time: f32,
video_end_time: f32,
id: i32,
) {
let service_item = ServiceItem {
name,
ty: ty.try_into().unwrap(),
text,
background,
background_type,
audio,
font,
font_size,
slide_count,
looping,
video_start_time,
video_end_time,
id,
..Default::default()
};
@ -474,39 +433,19 @@ impl service_item_model::ServiceItemModel {
self.as_mut().end_insert_rows();
}
debug!("ADDING: {:?}", &service_item);
self.as_mut().item_added(&index, &service_item.id, &service_item.ty.to_string());
self.as_mut().item_added(&service_item.id, &QString::from(&service_item.ty.to_string()));
}
pub fn insert_item(
mut self: Pin<&mut Self>,
index: i32,
name: QString,
text: QStringList,
ty: QString,
background: QString,
background_type: QString,
audio: QString,
font: QString,
font_size: i32,
slide_count: i32,
looping: bool,
video_start_time: f32,
video_end_time: f32,
id: i32,
) {
let service_item = ServiceItem {
name,
ty: ty.try_into().unwrap(),
text,
background,
background_type,
audio,
font,
font_size,
slide_count,
looping,
video_start_time,
video_end_time,
id,
..Default::default()
};
@ -533,7 +472,7 @@ impl service_item_model::ServiceItemModel {
self.as_mut().end_insert_rows();
}
debug!("ADDING: {:?}", &service_item);
self.as_mut().item_inserted(&index, &service_item.id, &service_item.ty.to_string());
self.as_mut().item_inserted(&index, &service_item.id, &QString::from(&service_item.ty.to_string()));
}
pub fn get_item(