From 2b5a699000f45c4139f09201d53d64723b3f7c01 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Thu, 23 Mar 2023 15:58:20 -0500 Subject: [PATCH] add next & previous fn These functions allow us to change the slide to the next and previous slides --- src/rust/slide_obj.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/rust/slide_obj.rs b/src/rust/slide_obj.rs index 36630ab..7d14324 100644 --- a/src/rust/slide_obj.rs +++ b/src/rust/slide_obj.rs @@ -3,6 +3,8 @@ mod slide_obj { // use cxx_qt_lib::QVariantValue; // use std::path::Path; + use std::task::Context; + unsafe extern "C++" { include!("cxx-qt-lib/qstring.h"); type QString = cxx_qt_lib::QString; @@ -188,7 +190,15 @@ mod slide_obj { }; } - // #[qinvokable] - // pub fn next(self: Pin<&mut Self>, next_item: QVariant, slide_model: slide_model) {} + #[qinvokable] + pub fn next(self: Pin<&mut Self>, next_item: QMap_QString_QVariant) -> bool { + self.change_slide(next_item, self.as_ref().slide_index() + 1); + true + } + #[qinvokable] + pub fn previous(self: Pin<&mut Self>, prev_item: QMap_QString_QVariant) -> bool { + self.change_slide(prev_item, self.as_ref().slide_index() - 1); + true + } } }