trying to fix the slides not showing a newly created video_thumbnail

This commit is contained in:
Chris Cochrun 2024-09-18 09:35:06 -05:00
parent 9b75c366de
commit 4659cb6de5
2 changed files with 21 additions and 9 deletions

View file

@ -50,6 +50,12 @@ Item {
chosenFont: model.font chosenFont: model.font
text: model.text text: model.text
pdfIndex: model.slideIndex pdfIndex: model.slideIndex
Connections {
target: slideModel
function onDataChanged() {
Utils.dbg("hi")
}
}
} }
/* WebEngineView { */ /* WebEngineView { */

View file

@ -315,10 +315,16 @@ impl slide_model::SlideModel {
mut self: Pin<&mut Self>, mut self: Pin<&mut Self>,
index: i32, index: i32,
) -> bool { ) -> bool {
let (id, index, roles) = self.as_mut().get_indices(index, SlideRoles::VideoThumbnail); let mut vector_roles = QVector_i32::default();
vector_roles.append(self.get_role(SlideRoles::VideoThumbnail));
vector_roles.append(self.get_role(SlideRoles::VideoBackground));
vector_roles.append(self.get_role(SlideRoles::ImageBackground));
let rc = self.as_ref().count() - 1;
let tl = self.as_ref().index(0, 0, &QModelIndex::default());
let br = self.as_ref().index(rc, 0, &QModelIndex::default());
let thread = self.qt_thread(); let thread = self.qt_thread();
if let Some(slide) = if let Some(slide) =
self.as_mut().rust_mut().slides.get_mut(id) self.as_mut().rust_mut().slides.get_mut(index as usize)
{ {
if !slide.video_background.is_empty() { if !slide.video_background.is_empty() {
let path = let path =
@ -340,9 +346,9 @@ impl slide_model::SlideModel {
match thread.queue(move |mut slide_model| { match thread.queue(move |mut slide_model| {
slide_model.as_mut().data_changed( slide_model.as_mut().data_changed(
&index, &tl,
&index, &br,
&roles, &vector_roles,
) )
}) { }) {
Ok(_o) => { Ok(_o) => {
@ -1223,15 +1229,15 @@ impl slide_model::SlideModel {
) -> (usize, QModelIndex, QVector_i32) { ) -> (usize, QModelIndex, QVector_i32) {
let mut vector_roles = QVector_i32::default(); let mut vector_roles = QVector_i32::default();
vector_roles.append(self.as_ref().get_role(role)); vector_roles.append(self.as_ref().get_role(role));
if let Some(index) = if let Some(_slide) =
self.as_ref().slides.iter().enumerate().nth(item_id) self.as_ref().slides.get(item_id as usize)
{ {
let model_index = self.as_ref().index( let model_index = self.as_ref().index(
index as i32, item_id,
0, 0,
&QModelIndex::default(), &QModelIndex::default(),
); );
(index, model_index, vector_roles) (item_id as usize, model_index, vector_roles)
} else { } else {
error!(item_id, "This item appears to be missing"); error!(item_id, "This item appears to be missing");
(0, QModelIndex::default(), vector_roles) (0, QModelIndex::default(), vector_roles)