adding the removal of items work on the slides
This isn't finished yet, but the core is there. I have yet to fully remove slides after a service_item is removed.
This commit is contained in:
parent
7a36b70a6d
commit
f8ac7feea0
5 changed files with 35 additions and 10 deletions
|
@ -165,6 +165,15 @@ mod slide_model {
|
|||
}
|
||||
}
|
||||
|
||||
#[qinvokable]
|
||||
pub fn remove_item_from_service(
|
||||
mut self: Pin<&mut Self>,
|
||||
index: i32,
|
||||
service_item: &QMap_QString_QVariant,
|
||||
) {
|
||||
println!("Removing: {:?}", index);
|
||||
}
|
||||
|
||||
#[qinvokable]
|
||||
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) {
|
||||
if index < 0 || (index as usize) >= self.slides().len() {
|
||||
|
@ -387,6 +396,14 @@ mod slide_model {
|
|||
video_thumbnail: QString::from(""),
|
||||
};
|
||||
|
||||
// We need to move all the current slides service_item_id's up by one.
|
||||
let slides_len = self.as_mut().slides_mut().len() as i32;
|
||||
for slide in index..slides_len {
|
||||
if let Some(slide) = self.as_mut().slides_mut().get_mut(slide as usize) {
|
||||
slide.service_item_id += 1;
|
||||
}
|
||||
}
|
||||
|
||||
match ty {
|
||||
Some(ty) if ty == QString::from("image") => {
|
||||
slide.ty = ty;
|
||||
|
@ -624,12 +641,15 @@ mod slide_model {
|
|||
slide.active = false;
|
||||
}
|
||||
if let Some(slide) = self.as_mut().slides_mut().get_mut(index as usize) {
|
||||
println!("slide is activating {:?}", index);
|
||||
println!("slide-title: {:?}", slide.service_item_id);
|
||||
println!("slide-image-background: {:?}", slide.image_background);
|
||||
println!("slide-video-background: {:?}", slide.video_background);
|
||||
slide.active = true;
|
||||
self.as_mut().emit_data_changed(tl, br, &vector_roles);
|
||||
// We use this signal generated by our signals enum to tell QML that
|
||||
// the active slide has changed which is used to reposition views.
|
||||
self.as_mut().emit_active_changed();
|
||||
println!("slide is activating {:?}", index);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue