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
This commit is contained in:
parent
1858822094
commit
affaf7a53b
3 changed files with 14 additions and 12 deletions
|
@ -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!(
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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::<QString>()
|
||||
debug!(
|
||||
?key,
|
||||
data = data
|
||||
.value_or_default::<QString>()
|
||||
.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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue