From affaf7a53ba451696bd3f026051409b24f6d5f6b Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Fri, 29 Sep 2023 16:32:45 -0500 Subject: [PATCH] make adding presentations properly add the right number of slides To make sure we know how many slides are in a presentation we needed to ensure we are using Urls appropriately and that we are looking in the correct key in the QVariantMap --- src/rust/presentation_model.rs | 8 ++++---- src/rust/reveal_js.rs | 6 +++--- src/rust/slide_model.rs | 12 +++++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/rust/presentation_model.rs b/src/rust/presentation_model.rs index 50fc3ab..a5d4907 100644 --- a/src/rust/presentation_model.rs +++ b/src/rust/presentation_model.rs @@ -191,7 +191,7 @@ mod presentation_model { file_path.file_stem().unwrap().to_str().unwrap(); let presentation_id = self.rust().highest_id + 1; let presentation_title = QString::from(name); - let presentation_path = url.to_qstring(); + let presentation_path = url; let presentation_html = file_path.extension().unwrap() == "html"; debug!(html = presentation_html, ?file_path, extension = ?file_path.extension()); @@ -215,7 +215,7 @@ mod presentation_model { mut self: Pin<&mut Self>, presentation_id: i32, presentation_title: QString, - presentation_path: QString, + presentation_path: QUrl, presentation_html: bool, new_page_count: i32, ) -> bool { @@ -224,11 +224,11 @@ mod presentation_model { let mut actual_page_count = new_page_count; if presentation_html { let actual_path = PathBuf::from( - presentation_path.clone().to_string(), + presentation_path.path().to_string(), ); actual_page_count = reveal_js::count_slides_and_fragments( - &actual_path, + actual_path, ); } debug!( diff --git a/src/rust/reveal_js.rs b/src/rust/reveal_js.rs index 876671a..027e5f8 100644 --- a/src/rust/reveal_js.rs +++ b/src/rust/reveal_js.rs @@ -1,9 +1,9 @@ // use dirs; -use std::{fs::read_to_string, path::Path}; +use std::{fs::read_to_string, path::PathBuf}; use tracing::{debug, debug_span, error, info, instrument}; -pub fn count_slides_and_fragments(html_file_path: Path) -> i32 { - debug!("Starting slide counter"); +pub fn count_slides_and_fragments(html_file_path: PathBuf) -> i32 { + debug!(path = ?html_file_path, "Starting slide counter"); // Read the HTML file let html_content = read_to_string(html_file_path) .expect("Failed to read HTML file"); diff --git a/src/rust/slide_model.rs b/src/rust/slide_model.rs index 6b86b36..b6373fc 100644 --- a/src/rust/slide_model.rs +++ b/src/rust/slide_model.rs @@ -1,5 +1,6 @@ #[cxx_qt::bridge] mod slide_model { + use tracing::{debug, debug_span, error, info, instrument}; unsafe extern "C++" { include!(< QAbstractListModel >); include!("cxx-qt-lib/qhash.h"); @@ -262,10 +263,11 @@ mod slide_model { service_item: &QMap_QString_QVariant, ) { for (key, data) in service_item.iter() { - println!( - "{:?}: {:?}", - key, - data.value_or_default::() + debug!( + ?key, + data = data + .value_or_default::() + .to_string() ); } let ty = service_item @@ -349,7 +351,7 @@ mod slide_model { .value() .unwrap_or(0); slide.slide_count = service_item - .get(&QString::from("slideNumber")) + .get(&QString::from("slideCount")) .unwrap_or(QVariant::from(&1)) .value() .unwrap_or(1);