fixed slide_object tracking the index so the previewer can follow

This commit is contained in:
Chris Cochrun 2024-03-22 06:44:51 -05:00
parent 85b9f9cede
commit 64e10dd765
2 changed files with 20 additions and 14 deletions

View file

@ -4,13 +4,14 @@
:CATEGORY: dev
:END:
* Tasks [62%] [50/80]
** TODO [#A] Fix updating things in the song editor
* Tasks [62%] [51/82]
** TODO [#B] Fix updating things in the song editor
[[file:~/dev/lumina/src/qml/presenter/SongEditor.qml::function updateLyrics(lyrics) {]]
The core problem with this is that when we set the song, the index to get the item is the index of the item in the vector, not the ID in the DB. So, when we get a song, we can't use that index to update things, we need to make sure we are using the id so that all the new work in updating the right item is done correctly.
*** TODO Seems that updating songs aren't reflected well
[[file:~/dev/lumina/src/rust/songs/song_model.rs::updated_background.to_string();]]
** TODO [#B] Fix switching songs in editor not showing the right lyrics
** TODO Create a song_lyrics searching and importer for the song_editor
[[file:~/dev/lumina/src/rust/songs/song_lyrics.rs::pub fn search_song(s: &str) -> Result<Vec<Song>, Error> {]]
@ -257,6 +258,7 @@ Like this..
target_link_libraries(${APP_NAME} PRIVATE ${APP_NAME}_lib)
#+end_src
** DONE [#A] Fix using arrows shows the right slide, but the slide preview list doesn't follow it
** DONE Write a function to handle switching to the next fragment in revealjs
[[file:~/dev/lumina/src/qml/presenter/Slide.qml::WebEngineView {]]

View file

@ -143,7 +143,7 @@ impl slide_object::SlideObject {
pub fn change_slide(
mut self: Pin<&mut Self>,
item: QMap_QString_QVariant,
index: i32,
slide_index: i32,
) {
let current_index = self.as_ref().get_ref().slide_index();
let icount_variant = item
@ -154,7 +154,7 @@ impl slide_object::SlideObject {
let slindex = item
.get(&QString::from("slideIndex"))
.unwrap_or(QVariant::from(&0));
let slide_index = slindex.value::<i32>().unwrap_or_default();
// let slide_index = slindex.value::<i32>().unwrap_or_default();
// let html = item
// .get(&QString::from("html"))
@ -175,7 +175,7 @@ impl slide_object::SlideObject {
// }
// }
// }
debug!(index, "Changing slide");
debug!(slide_index, "Changing slide");
println!("## Slide Details ##");
let text = item
@ -326,7 +326,9 @@ impl slide_object::SlideObject {
self.as_mut().set_slide_index(slide_index);
self.as_mut().slide_changed(index);
// This is pointing to the slide in the overall model. So to get it
// we need to either track the overall slide index, or get it from
self.as_mut().slide_changed(slide_index);
// self.as_mut().emit(Signals::SlideChanged { slide: &index });
println!("## Slide End ##");
}
@ -346,11 +348,11 @@ impl slide_object::SlideObject {
&QString::from(".html"),
CaseSensitivity::CaseInsensitive,
);
let service_item = next_item
.get(&QString::from("serviceItemId"))
.unwrap()
.value::<i32>()
.unwrap_or_default();
// let service_item = next_item
// .get(&QString::from("serviceItemId"))
// .unwrap()
// .value::<i32>()
// .unwrap_or_default();
if html {
// Check to see if current slide is at the end
// if not, advance to the next one.
@ -362,16 +364,17 @@ impl slide_object::SlideObject {
if self.as_ref().slide_index
< self.as_ref().image_count - 1
{
self.as_mut().set_slide_index(new_id);
// self.as_mut().set_slide_index(new_id);
self.as_mut().reveal_next();
debug!("returning false");
return false;
}
}
self.as_mut().set_slide_index(new_id);
// reset to empty before change to ensure that the web source gets unloaded
self.as_mut().set_image_background(QString::from(""));
self.as_mut().change_slide(next_item, service_item);
debug!(service_item, "returning true");
self.as_mut().change_slide(next_item, new_id);
debug!(new_id, "returning true");
true
}
pub fn previous(
@ -398,6 +401,7 @@ impl slide_object::SlideObject {
return false;
}
}
self.as_mut().set_slide_index(new_id);
// reset to empty before change to ensure that the web source gets unloaded
self.as_mut().set_image_background(QString::from(""));
self.as_mut().change_slide(prev_item, new_id);