adding a SlideType enum that can parse from a string

This will start to allow us to have a much better data model for the
slides and service items. They can have a type associated with them
and parse which they are from this type.
This commit is contained in:
Chris Cochrun 2024-09-17 06:23:27 -05:00
parent 0cac11cb89
commit 273dd76d23
4 changed files with 182 additions and 37 deletions

View file

@ -6,8 +6,8 @@ mod slide_object {
include!("cxx-qt-lib/qmap.h");
type QMap_QString_QVariant =
cxx_qt_lib::QMap<cxx_qt_lib::QMapPair_QString_QVariant>;
include!("cxx-qt-lib/qvariant.h");
type QVariant = cxx_qt_lib::QVariant;
// include!("cxx-qt-lib/qvariant.h");
// type QVariant = cxx_qt_lib::QVariant;
// #[cxx_name = "SlideModel"]
// type SlideModel = crate::slide_model::SlideModelRust;
}
@ -88,7 +88,12 @@ use std::pin::Pin;
use cxx_qt::CxxQtType;
use cxx_qt_lib::{CaseSensitivity, QString, QVariant};
use tracing::debug;
use tracing::{debug, error};
use crate::{
slide_types::{PresType, SlideType},
songs::song_model::{song_model::SongModel, SongModelRust},
};
use self::slide_object::QMap_QString_QVariant;
@ -145,6 +150,38 @@ impl slide_object::SlideObject {
item: QMap_QString_QVariant,
slide_index: i32,
) {
// This function will grab the item from the relevant model
// and load it into the slide_object
let kind = item
.get(&QString::from("type"))
.unwrap_or(QVariant::from(&QString::default()))
.value()
.unwrap_or(QString::default());
match SlideType::try_from(kind) {
Ok(st) => {
debug!(kind = ?st, "Changing slide");
// let slide = match st {
// SlideType::Song => {
// SongModel::get_item(slide_index)
// }
// SlideType::Image => {
// ImageModel::get_item(slide_index)
// }
// SlideType::Video => {
// VideoModel::get_item(slide_index)
// }
// SlideType::Presentation(_) => {
// PresentationModel::get_item(slide_index)
// }
// SlideType::Content => {
// PresentationModel::get_item(slide_index)
// }
// };
// debug!(slide);
}
Err(e) => error!(?e),
}
let _current_index = self.as_ref().get_ref().slide_index();
let icount_variant = item
.get(&QString::from("imageCount"))