saving some updates

This commit is contained in:
Chris Cochrun 2024-09-17 15:32:34 -05:00
parent bb3a5d9b7b
commit 9b75c366de
4 changed files with 70 additions and 39 deletions

View file

@ -315,17 +315,10 @@ impl slide_model::SlideModel {
mut self: Pin<&mut Self>,
index: i32,
) -> bool {
let mut vector_roles = QVector_i32::default();
vector_roles
.append(self.get_role(SlideRoles::VideoThumbnail));
let (id, index, roles) = self.as_mut().get_indices(index, SlideRoles::VideoThumbnail);
let thread = self.qt_thread();
let model_index = self
.as_ref()
.index(index, 0, &QModelIndex::default())
.clone();
if let Some(slide) =
self.as_mut().rust_mut().slides.get_mut(index as usize)
self.as_mut().rust_mut().slides.get_mut(id)
{
if !slide.video_background.is_empty() {
let path =
@ -335,9 +328,7 @@ impl slide_model::SlideModel {
screenshot_string.insert_str(0, "file://");
slide.video_thumbnail = screenshot_string;
std::thread::spawn(move || {
let result =
ffmpeg::bg_from_video(&path, &screenshot);
match result {
match ffmpeg::bg_from_video(&path, &screenshot) {
Ok(_o) => {
debug!("Success making video background!")
}
@ -346,15 +337,14 @@ impl slide_model::SlideModel {
"Error making video background"
),
};
let result =
thread.queue(move |mut slide_model| {
slide_model.as_mut().data_changed(
&model_index,
&model_index,
&vector_roles,
)
});
match result {
match thread.queue(move |mut slide_model| {
slide_model.as_mut().data_changed(
&index,
&index,
&roles,
)
}) {
Ok(_o) => {
debug!("Success in creating qt_thread")
}
@ -466,14 +456,7 @@ impl slide_model::SlideModel {
}
let count = self.as_ref().count;
self.as_mut().set_count(count + 1);
let thread = self.qt_thread();
thread::spawn(move || {
thread
.queue(move |slidemodel| {
slidemodel.add_video_thumbnail(index);
})
.unwrap();
});
self.as_mut().add_video_thumbnail(index);
}
pub fn insert_item_from_service(
@ -1232,6 +1215,29 @@ impl slide_model::SlideModel {
_ => 0,
}
}
fn get_indices(
self: Pin<&mut Self>,
item_id: i32,
role: SlideRoles,
) -> (usize, QModelIndex, QVector_i32) {
let mut vector_roles = QVector_i32::default();
vector_roles.append(self.as_ref().get_role(role));
if let Some(index) =
self.as_ref().slides.iter().enumerate().nth(item_id)
{
let model_index = self.as_ref().index(
index as i32,
0,
&QModelIndex::default(),
);
(index, model_index, vector_roles)
} else {
error!(item_id, "This item appears to be missing");
(0, QModelIndex::default(), vector_roles)
}
}
}
// QAbstractListModel implementation