#[cxx_qt::bridge] pub mod video_model { unsafe extern "C++" { include!(< QAbstractListModel >); include!("cxx-qt-lib/qhash.h"); type QHash_i32_QByteArray = cxx_qt_lib::QHash; include!("cxx-qt-lib/qmap.h"); type QMap_QString_QVariant = cxx_qt_lib::QMap; include!("cxx-qt-lib/qvariant.h"); type QVariant = cxx_qt_lib::QVariant; include!("cxx-qt-lib/qstring.h"); type QString = cxx_qt_lib::QString; include!("cxx-qt-lib/qurl.h"); type QUrl = cxx_qt_lib::QUrl; include!("cxx-qt-lib/qmodelindex.h"); type QModelIndex = cxx_qt_lib::QModelIndex; include!("cxx-qt-lib/qvector.h"); type QVector_i32 = cxx_qt_lib::QVector; // include!("cxx-qt-lib/qstringlist.h"); // type QStringList = cxx_qt_lib::QStringList; // include!("cxx-qt-lib/qlist.h"); // type QList_QString = cxx_qt_lib::QList; } #[qenum(VideoModel)] enum VideoRoles { Id, Title, Path, StartTime, EndTime, Looping, } unsafe extern "RustQt" { #[qobject] #[base = "QAbstractListModel"] #[qml_element] #[qproperty(i32, count)] type VideoModel = super::VideoModelRust; #[inherit] #[qsignal] fn data_changed( self: Pin<&mut VideoModel>, top_left: &QModelIndex, bottom_right: &QModelIndex, roles: &QVector_i32, ); #[qinvokable] fn clear(self: Pin<&mut VideoModel>); #[qinvokable] fn setup(self: Pin<&mut VideoModel>); #[qinvokable] fn remove_item( self: Pin<&mut VideoModel>, index: i32, ) -> bool; #[qinvokable] fn new_item(self: Pin<&mut VideoModel>, url: QUrl); #[qinvokable] fn update_path( self: Pin<&mut VideoModel>, index: i32, updated_path: QString, ) -> bool; #[qinvokable] fn get_item( self: Pin<&mut VideoModel>, index: i32, ) -> QMap_QString_QVariant; #[qinvokable] fn update_loop( self: Pin<&mut VideoModel>, index: i32, loop_value: bool, ) -> bool; #[qinvokable] fn update_title( self: Pin<&mut VideoModel>, index: i32, updated_title: QString, ) -> bool; #[qinvokable] fn update_start_time( self: Pin<&mut VideoModel>, index: i32, updated_start_time: f32, ) -> bool; #[qinvokable] fn update_end_time( self: Pin<&mut VideoModel>, index: i32, updated_end_time: f32, ) -> bool; #[qinvokable] fn search(self: Pin<&mut VideoModel>, search_term: QString); } impl cxx_qt::Threading for VideoModel {} unsafe extern "RustQt" { #[inherit] unsafe fn begin_insert_rows( self: Pin<&mut VideoModel>, parent: &QModelIndex, first: i32, last: i32, ); #[inherit] unsafe fn end_insert_rows(self: Pin<&mut VideoModel>); #[inherit] unsafe fn begin_remove_rows( self: Pin<&mut VideoModel>, parent: &QModelIndex, first: i32, last: i32, ); #[inherit] unsafe fn begin_move_rows( self: Pin<&mut VideoModel>, source_parent: &QModelIndex, source_first: i32, source_last: i32, destination_parent: &QModelIndex, destination_child: i32, ) -> bool; #[inherit] unsafe fn end_move_rows(self: Pin<&mut VideoModel>); #[inherit] unsafe fn end_remove_rows(self: Pin<&mut VideoModel>); #[inherit] unsafe fn begin_reset_model(self: Pin<&mut VideoModel>); #[inherit] unsafe fn end_reset_model(self: Pin<&mut VideoModel>); #[inherit] fn can_fetch_more( self: &VideoModel, parent: &QModelIndex, ) -> bool; #[inherit] fn index( self: &VideoModel, row: i32, column: i32, parent: &QModelIndex, ) -> QModelIndex; #[qinvokable] #[cxx_override] fn data( self: &VideoModel, index: &QModelIndex, role: i32, ) -> QVariant; #[qinvokable] #[cxx_override] fn role_names(self: &VideoModel) -> QHash_i32_QByteArray; #[qinvokable] #[cxx_override] fn row_count(self: &VideoModel, _parent: &QModelIndex) -> i32; } } use color_eyre::eyre::Error; use cxx_qt::{CxxQtType, Threading}; use cxx_qt_lib::{QByteArray, QModelIndex, QString, QUrl, QVariant}; use sqlx::{query, query_as, Connection, SqliteConnection}; use std::path::PathBuf; use std::pin::Pin; use tracing::{debug, error}; use self::video_model::{ QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32, VideoRoles, }; #[derive(Default, Clone, Debug)] pub struct Video { id: i32, title: String, pub path: String, pub start_time: f32, pub end_time: f32, pub looping: bool, } #[derive(Debug)] pub struct VideoModelRust { count: i32, highest_id: i32, videos: Vec