rust side builds but having trouble linking in main.cpp

This commit is contained in:
Chris Cochrun 2025-03-12 09:35:36 -05:00
parent fbcb6afc7a
commit 92f2b18a20
14 changed files with 377 additions and 140 deletions

View file

@ -2,6 +2,7 @@
pub mod slide_model {
unsafe extern "C++" {
include!(< QAbstractListModel >);
type QAbstractListModel;
include!("cxx-qt-lib/qhash.h");
type QHash_i32_QByteArray =
cxx_qt_lib::QHash<cxx_qt_lib::QHashPair_i32_QByteArray>;
@ -18,20 +19,23 @@ pub mod slide_model {
type QVector_i32 = cxx_qt_lib::QVector<i32>;
include!("cxx-qt-lib/qlist.h");
type QList_QString = cxx_qt_lib::QList<QString>;
include!("cxx-qt-gen/slide_object.cxxqt.h");
type SlideObject =
crate::slide_object::slide_object::SlideObject;
include!("cxx-qt-gen/song_model.cxxqt.h");
include!("src/rust/slide_object.cxxqt.h");
type SlideObject = crate::slide_object::qobject::SlideObject;
include!("src/rust/songs/song_model.cxxqt.h");
type SongModel =
crate::songs::song_model::song_model::SongModel;
include!("cxx-qt-gen/video_model.cxxqt.h");
include!("src/rust/video_model.cxxqt.h");
type VideoModel = crate::video_model::video_model::VideoModel;
include!("cxx-qt-gen/image_model.cxxqt.h");
include!("src/rust/image_model.cxxqt.h");
type ImageModel = crate::image_model::image_model::ImageModel;
include!("cxx-qt-gen/presentation_model.cxxqt.h");
include!("src/rust/presentation_model.cxxqt.h");
type PresentationModel = crate::presentation_model::presentation_model::PresentationModel;
}
// extern "C++" {
// type SlideObject = crate::slide_object::qobject::SlideObject;
// }
#[qenum(SlideModel)]
enum SlideRoles {
Ty,
@ -58,7 +62,7 @@ pub mod slide_model {
unsafe extern "RustQt" {
#[qobject]
#[base = "QAbstractListModel"]
#[base = QAbstractListModel]
#[qml_element]
#[qproperty(i32, count)]
#[qproperty(*mut SlideObject, slide_object)]
@ -70,6 +74,7 @@ pub mod slide_model {
#[inherit]
#[qsignal]
#[cxx_name = "dataChanged"]
fn data_changed(
self: Pin<&mut SlideModel>,
top_left: &QModelIndex,
@ -155,6 +160,7 @@ pub mod slide_model {
unsafe extern "RustQt" {
#[inherit]
#[cxx_name = "beginInsertRows"]
unsafe fn begin_insert_rows(
self: Pin<&mut SlideModel>,
parent: &QModelIndex,
@ -163,9 +169,11 @@ pub mod slide_model {
);
#[inherit]
#[cxx_name = "endInsertRows"]
unsafe fn end_insert_rows(self: Pin<&mut SlideModel>);
#[inherit]
#[cxx_name = "beginRemoveRows"]
unsafe fn begin_remove_rows(
self: Pin<&mut SlideModel>,
parent: &QModelIndex,
@ -174,15 +182,19 @@ pub mod slide_model {
);
#[inherit]
#[cxx_name = "endRemoveRows"]
unsafe fn end_remove_rows(self: Pin<&mut SlideModel>);
#[inherit]
#[cxx_name = "beginResetModel"]
unsafe fn begin_reset_model(self: Pin<&mut SlideModel>);
#[inherit]
#[cxx_name = "endResetModel"]
unsafe fn end_reset_model(self: Pin<&mut SlideModel>);
#[inherit]
#[cxx_name = "beginMoveRows"]
unsafe fn begin_move_rows(
self: Pin<&mut SlideModel>,
source_parent: &QModelIndex,
@ -193,9 +205,11 @@ pub mod slide_model {
) -> bool;
#[inherit]
#[cxx_name = "endMoveRows"]
unsafe fn end_move_rows(self: Pin<&mut SlideModel>);
#[inherit]
#[cxx_name = "canFetchMore"]
fn can_fetch_more(
self: &SlideModel,
parent: &QModelIndex,
@ -219,12 +233,14 @@ pub mod slide_model {
#[qinvokable]
#[cxx_override]
#[cxx_name = "roleNames"]
fn role_names(self: &SlideModel) -> QHash_i32_QByteArray;
#[qinvokable]
#[cxx_override]
#[cxx_name = "rowCount"]
fn row_count(self: &SlideModel, _parent: &QModelIndex)
-> i32;
-> i32;
}
}
@ -238,12 +254,12 @@ use crate::presentation_model::{
};
use crate::slide_model::slide_model::QList_QString;
use crate::songs::song_model::song_model::{self, SongModel};
use crate::songs::song_model::{get_song, Song, SongModelRust};
use crate::songs::song_model::{Song, SongModelRust, get_song};
use crate::video_model::video_model::VideoModel;
use crate::video_model::{self, Video, VideoModelRust};
use crate::{ffmpeg, slide_types::SlideType};
use color_eyre::eyre::Result;
use color_eyre::Section;
use color_eyre::eyre::Result;
use cxx_qt::{CxxQtType, Threading};
use cxx_qt_lib::{
CaseSensitivity, QByteArray, QList, QModelIndex, QString,
@ -324,7 +340,9 @@ impl Display for ParseSlideError {
f: &mut std::fmt::Formatter<'_>,
) -> std::fmt::Result {
let message = match self {
Self::UnknownType => "The type does not exist. It needs to be one of 'song', 'video', 'image', 'presentation', or 'content'",
Self::UnknownType => {
"The type does not exist. It needs to be one of 'song', 'video', 'image', 'presentation', or 'content'"
}
};
write!(f, "Error: {message}")
}
@ -798,7 +816,9 @@ impl slide_model::SlideModel {
// Change the service_item_id of the moved slide
if count > 1 {
if move_down {
debug!("While moving down, change service items id of moved slide");
debug!(
"While moving down, change service items id of moved slide"
);
for (i, _slide) in slides_iter
.clone()
.enumerate()
@ -816,13 +836,16 @@ impl slide_model::SlideModel {
debug!(
?slide,
"rust: these ones right here officer. from {:?} to {:?}",
slide.service_item_id, destination_index
slide.service_item_id,
destination_index
);
slide.service_item_id = destination_index;
}
}
} else {
debug!("While moving up, change service items id of moved slide");
debug!(
"While moving up, change service items id of moved slide"
);
for (i, _slide) in slides_iter
.clone()
.enumerate()
@ -835,7 +858,8 @@ impl slide_model::SlideModel {
debug!(
?slide,
"rust: these ones right here officer. from {:?} to {:?}",
slide.service_item_id, destination_index
slide.service_item_id,
destination_index
);
slide.service_item_id = destination_index;
}
@ -907,7 +931,9 @@ impl slide_model::SlideModel {
// self.as_mut().end_reset_model();
// }
debug!("rust-move: {first_slide} to {dest_slide} with {count} slides");
debug!(
"rust-move: {first_slide} to {dest_slide} with {count} slides"
);
}
fn move_items(