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();
|
file_path.file_stem().unwrap().to_str().unwrap();
|
||||||
let presentation_id = self.rust().highest_id + 1;
|
let presentation_id = self.rust().highest_id + 1;
|
||||||
let presentation_title = QString::from(name);
|
let presentation_title = QString::from(name);
|
||||||
let presentation_path = url.to_qstring();
|
let presentation_path = url;
|
||||||
let presentation_html =
|
let presentation_html =
|
||||||
file_path.extension().unwrap() == "html";
|
file_path.extension().unwrap() == "html";
|
||||||
debug!(html = presentation_html, ?file_path, extension = ?file_path.extension());
|
debug!(html = presentation_html, ?file_path, extension = ?file_path.extension());
|
||||||
|
@ -215,7 +215,7 @@ mod presentation_model {
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
presentation_id: i32,
|
presentation_id: i32,
|
||||||
presentation_title: QString,
|
presentation_title: QString,
|
||||||
presentation_path: QString,
|
presentation_path: QUrl,
|
||||||
presentation_html: bool,
|
presentation_html: bool,
|
||||||
new_page_count: i32,
|
new_page_count: i32,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
@ -224,11 +224,11 @@ mod presentation_model {
|
||||||
let mut actual_page_count = new_page_count;
|
let mut actual_page_count = new_page_count;
|
||||||
if presentation_html {
|
if presentation_html {
|
||||||
let actual_path = PathBuf::from(
|
let actual_path = PathBuf::from(
|
||||||
presentation_path.clone().to_string(),
|
presentation_path.path().to_string(),
|
||||||
);
|
);
|
||||||
actual_page_count =
|
actual_page_count =
|
||||||
reveal_js::count_slides_and_fragments(
|
reveal_js::count_slides_and_fragments(
|
||||||
&actual_path,
|
actual_path,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
debug!(
|
debug!(
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// use dirs;
|
// 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};
|
use tracing::{debug, debug_span, error, info, instrument};
|
||||||
|
|
||||||
pub fn count_slides_and_fragments(html_file_path: Path) -> i32 {
|
pub fn count_slides_and_fragments(html_file_path: PathBuf) -> i32 {
|
||||||
debug!("Starting slide counter");
|
debug!(path = ?html_file_path, "Starting slide counter");
|
||||||
// Read the HTML file
|
// Read the HTML file
|
||||||
let html_content = read_to_string(html_file_path)
|
let html_content = read_to_string(html_file_path)
|
||||||
.expect("Failed to read HTML file");
|
.expect("Failed to read HTML file");
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
mod slide_model {
|
mod slide_model {
|
||||||
|
use tracing::{debug, debug_span, error, info, instrument};
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!(< QAbstractListModel >);
|
include!(< QAbstractListModel >);
|
||||||
include!("cxx-qt-lib/qhash.h");
|
include!("cxx-qt-lib/qhash.h");
|
||||||
|
@ -262,10 +263,11 @@ mod slide_model {
|
||||||
service_item: &QMap_QString_QVariant,
|
service_item: &QMap_QString_QVariant,
|
||||||
) {
|
) {
|
||||||
for (key, data) in service_item.iter() {
|
for (key, data) in service_item.iter() {
|
||||||
println!(
|
debug!(
|
||||||
"{:?}: {:?}",
|
?key,
|
||||||
key,
|
data = data
|
||||||
data.value_or_default::<QString>()
|
.value_or_default::<QString>()
|
||||||
|
.to_string()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let ty = service_item
|
let ty = service_item
|
||||||
|
@ -349,7 +351,7 @@ mod slide_model {
|
||||||
.value()
|
.value()
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
slide.slide_count = service_item
|
slide.slide_count = service_item
|
||||||
.get(&QString::from("slideNumber"))
|
.get(&QString::from("slideCount"))
|
||||||
.unwrap_or(QVariant::from(&1))
|
.unwrap_or(QVariant::from(&1))
|
||||||
.value()
|
.value()
|
||||||
.unwrap_or(1);
|
.unwrap_or(1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue