Quite a few of the models have been ported.. need more though.
Still need all the songs and some small utility modules
This commit is contained in:
parent
81b430e768
commit
62daf316a3
7 changed files with 2781 additions and 2535 deletions
14
TODO.org
14
TODO.org
|
@ -1,9 +1,21 @@
|
||||||
#+TITLE: Todo List
|
#+TITLE: Todo List
|
||||||
|
#+filetags: :projectdev:
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CATEGORY: dev
|
:CATEGORY: dev
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
* Tasks [61%] [47/76]
|
* Tasks [0%] [0/0]
|
||||||
|
** TODO Port to CXX-QT 6.0 [37%] [3/8]
|
||||||
|
[[file:~/dev/lumina/src/rust/lib.rs]]
|
||||||
|
|
||||||
|
*** DONE image_model.rs
|
||||||
|
*** DONE video_model.rs
|
||||||
|
*** DONE presentation_model.rs
|
||||||
|
*** TODO songs/song_model.rs
|
||||||
|
*** TODO songs/song_editor.rs
|
||||||
|
*** TODO ytdl.rs
|
||||||
|
*** TODO utils.rs
|
||||||
|
*** TODO obs.rs
|
||||||
** TODO Write a function to handle switching to the next fragment in revealjs
|
** TODO Write a function to handle switching to the next fragment in revealjs
|
||||||
[[file:~/dev/lumina/src/qml/presenter/Slide.qml::WebEngineView {]]
|
[[file:~/dev/lumina/src/qml/presenter/Slide.qml::WebEngineView {]]
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
mod image_model {
|
mod image_model {
|
||||||
use crate::image_model::image_model::Image;
|
|
||||||
use crate::schema::images::dsl::*;
|
|
||||||
use diesel::sqlite::SqliteConnection;
|
|
||||||
use diesel::{delete, insert_into, prelude::*, update};
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!(< QAbstractListModel >);
|
include!(< QAbstractListModel >);
|
||||||
include!("cxx-qt-lib/qhash.h");
|
include!("cxx-qt-lib/qhash.h");
|
||||||
|
@ -30,54 +24,160 @@ mod image_model {
|
||||||
type QList_QString = cxx_qt_lib::QList<QString>;
|
type QList_QString = cxx_qt_lib::QList<QString>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug)]
|
#[qenum(ImageModel)]
|
||||||
pub struct Image {
|
enum Role {
|
||||||
|
Id,
|
||||||
|
Path,
|
||||||
|
Title,
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "RustQt" {
|
||||||
|
#[qobject]
|
||||||
|
#[base = "QAbstractListModel"]
|
||||||
|
#[qml_element]
|
||||||
|
#[qproperty(i32, count_rows)]
|
||||||
|
type ImageModel = super::ImageModelRust;
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
#[qsignal]
|
||||||
|
fn data_changed(
|
||||||
|
self: Pin<&mut ImageModel>,
|
||||||
|
top_left: &QModelIndex,
|
||||||
|
bottom_right: &QModelIndex,
|
||||||
|
roles: &QVector_i32,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn clear(self: Pin<&mut ImageModel>);
|
||||||
|
#[qinvokable]
|
||||||
|
fn setup(self: Pin<&mut ImageModel>);
|
||||||
|
#[qinvokable]
|
||||||
|
fn remove_item(
|
||||||
|
self: Pin<&mut ImageModel>,
|
||||||
|
index: i32,
|
||||||
|
) -> bool;
|
||||||
|
#[qinvokable]
|
||||||
|
fn new_item(self: Pin<&mut ImageModel>, url: QUrl);
|
||||||
|
#[qinvokable]
|
||||||
|
fn update_title(
|
||||||
|
self: Pin<&mut ImageModel>,
|
||||||
|
index: i32,
|
||||||
|
updated_title: QString,
|
||||||
|
) -> bool;
|
||||||
|
#[qinvokable]
|
||||||
|
fn update_file_path(
|
||||||
|
self: Pin<&mut ImageModel>,
|
||||||
|
index: i32,
|
||||||
|
updated_file_path: QString,
|
||||||
|
) -> bool;
|
||||||
|
#[qinvokable]
|
||||||
|
fn get_item(
|
||||||
|
self: Pin<&mut ImageModel>,
|
||||||
|
index: i32,
|
||||||
|
) -> QMap_QString_QVariant;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl cxx_qt::Threading for ImageModel {}
|
||||||
|
|
||||||
|
unsafe extern "RustQt" {
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn begin_insert_rows(
|
||||||
|
self: Pin<&mut ImageModel>,
|
||||||
|
parent: &QModelIndex,
|
||||||
|
first: i32,
|
||||||
|
last: i32,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn end_insert_rows(self: Pin<&mut ImageModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn begin_remove_rows(
|
||||||
|
self: Pin<&mut ImageModel>,
|
||||||
|
parent: &QModelIndex,
|
||||||
|
first: i32,
|
||||||
|
last: i32,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn begin_move_rows(
|
||||||
|
self: Pin<&mut ImageModel>,
|
||||||
|
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 ImageModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn end_remove_rows(self: Pin<&mut ImageModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn begin_reset_model(self: Pin<&mut ImageModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn end_reset_model(self: Pin<&mut ImageModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
fn can_fetch_more(
|
||||||
|
self: &ImageModel,
|
||||||
|
parent: &QModelIndex,
|
||||||
|
) -> bool;
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
fn index(
|
||||||
|
self: &ImageModel,
|
||||||
|
row: i32,
|
||||||
|
column: i32,
|
||||||
|
parent: &QModelIndex,
|
||||||
|
) -> QModelIndex;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
#[cxx_override]
|
||||||
|
fn data(
|
||||||
|
self: &ImageModel,
|
||||||
|
index: &QModelIndex,
|
||||||
|
role: i32,
|
||||||
|
) -> QVariant;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
#[cxx_override]
|
||||||
|
fn role_names(self: &ImageModel) -> QHash_i32_QByteArray;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
#[cxx_override]
|
||||||
|
fn row_count(self: &ImageModel, _parent: &QModelIndex)
|
||||||
|
-> i32;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn count(self: &ImageModel) -> i32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
use crate::image_model::image_model::Image;
|
||||||
|
use crate::schema::images::dsl::*;
|
||||||
|
use diesel::sqlite::SqliteConnection;
|
||||||
|
use diesel::{delete, insert_into, prelude::*, update};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
#[derive(Default, Clone, Debug)]
|
||||||
|
pub struct Image {
|
||||||
id: i32,
|
id: i32,
|
||||||
title: QString,
|
title: QString,
|
||||||
path: QString,
|
path: QString,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cxx_qt::qobject(base = "QAbstractListModel")]
|
#[derive(Default, Debug)]
|
||||||
#[derive(Default, Debug)]
|
pub struct ImageModelRust {
|
||||||
pub struct ImageModel {
|
|
||||||
#[qproperty]
|
|
||||||
count_rows: i32,
|
count_rows: i32,
|
||||||
highest_id: i32,
|
highest_id: i32,
|
||||||
images: Vec<self::Image>,
|
images: Vec<self::Image>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cxx_qt::qsignals(ImageModel)]
|
impl qobject::ImageModel {
|
||||||
pub enum Signals<'a> {
|
|
||||||
#[inherit]
|
|
||||||
DataChanged {
|
|
||||||
top_left: &'a QModelIndex,
|
|
||||||
bottom_right: &'a QModelIndex,
|
|
||||||
roles: &'a QVector_i32,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
enum Role {
|
|
||||||
IdRole,
|
|
||||||
PathRole,
|
|
||||||
TitleRole,
|
|
||||||
}
|
|
||||||
|
|
||||||
// impl FromStr for Role {
|
|
||||||
// type Err = ();
|
|
||||||
// fn from_str(input: &str) -> Result<Role, Self::Err> {
|
|
||||||
// match input {
|
|
||||||
// "id" => Ok(Role::IdRole),
|
|
||||||
// "title" => Ok(Role::TitleRole),
|
|
||||||
// "path" => Ok(Role::PathRole),
|
|
||||||
// _ => Err(()),
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// use crate::entities::{images, prelude::Images};
|
|
||||||
// use sea_orm::{ConnectionTrait, Database, DbBackend, DbErr, Statement, ActiveValue};
|
|
||||||
impl qobject::ImageModel {
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn clear(mut self: Pin<&mut Self>) {
|
pub fn clear(mut self: Pin<&mut Self>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_reset_model();
|
self.as_mut().begin_reset_model();
|
||||||
|
@ -86,7 +186,6 @@ mod image_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn setup(mut self: Pin<&mut Self>) {
|
pub fn setup(mut self: Pin<&mut Self>) {
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
let results = images
|
let results = images
|
||||||
|
@ -118,18 +217,13 @@ mod image_model {
|
||||||
println!("--------------------------------------");
|
println!("--------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) -> bool {
|
||||||
pub fn remove_item(
|
|
||||||
mut self: Pin<&mut Self>,
|
|
||||||
index: i32,
|
|
||||||
) -> bool {
|
|
||||||
if index < 0 || (index as usize) >= self.images().len() {
|
if index < 0 || (index as usize) >= self.images().len() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
|
|
||||||
let image_id =
|
let image_id = self.images().get(index as usize).unwrap().id;
|
||||||
self.images().get(index as usize).unwrap().id;
|
|
||||||
|
|
||||||
let result =
|
let result =
|
||||||
delete(images.filter(id.eq(image_id))).execute(db);
|
delete(images.filter(id.eq(image_id))).execute(db);
|
||||||
|
@ -142,9 +236,7 @@ mod image_model {
|
||||||
index,
|
index,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut()
|
self.as_mut().images_mut().remove(index as usize);
|
||||||
.images_mut()
|
|
||||||
.remove(index as usize);
|
|
||||||
self.as_mut().end_remove_rows();
|
self.as_mut().end_remove_rows();
|
||||||
}
|
}
|
||||||
println!("removed-item-at-index: {:?}", image_id);
|
println!("removed-item-at-index: {:?}", image_id);
|
||||||
|
@ -166,26 +258,20 @@ mod image_model {
|
||||||
db_url.push_str(data.to_str().unwrap());
|
db_url.push_str(data.to_str().unwrap());
|
||||||
println!("DB: {:?}", db_url);
|
println!("DB: {:?}", db_url);
|
||||||
|
|
||||||
SqliteConnection::establish(&db_url).unwrap_or_else(
|
SqliteConnection::establish(&db_url).unwrap_or_else(|_| {
|
||||||
|_| panic!("error connecting to {}", db_url),
|
panic!("error connecting to {}", db_url)
|
||||||
)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn new_item(mut self: Pin<&mut Self>, url: QUrl) {
|
pub fn new_item(mut self: Pin<&mut Self>, url: QUrl) {
|
||||||
println!("LETS INSERT THIS SUCKER!");
|
println!("LETS INSERT THIS SUCKER!");
|
||||||
let file_path = PathBuf::from(url.path().to_string());
|
let file_path = PathBuf::from(url.path().to_string());
|
||||||
let name =
|
let name = file_path.file_stem().unwrap().to_str().unwrap();
|
||||||
file_path.file_stem().unwrap().to_str().unwrap();
|
|
||||||
let image_id = self.rust().highest_id + 1;
|
let image_id = self.rust().highest_id + 1;
|
||||||
let image_title = QString::from(name);
|
let image_title = QString::from(name);
|
||||||
let image_path = url.to_qstring();
|
let image_path = url.to_qstring();
|
||||||
|
|
||||||
if self.as_mut().add_item(
|
if self.as_mut().add_item(image_id, image_title, image_path) {
|
||||||
image_id,
|
|
||||||
image_title,
|
|
||||||
image_path,
|
|
||||||
) {
|
|
||||||
println!("filename: {:?}", name);
|
println!("filename: {:?}", name);
|
||||||
self.as_mut().set_highest_id(image_id);
|
self.as_mut().set_highest_id(image_id);
|
||||||
} else {
|
} else {
|
||||||
|
@ -244,7 +330,6 @@ mod image_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn update_title(
|
pub fn update_title(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -253,11 +338,8 @@ mod image_model {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles
|
||||||
.append(self.as_ref().get_role_id(Role::TitleRole));
|
.append(self.as_ref().get_role_id(Role::TitleRole));
|
||||||
let model_index = &self.as_ref().index(
|
let model_index =
|
||||||
index,
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
0,
|
|
||||||
&QModelIndex::default(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
let result = update(images.filter(id.eq(index)))
|
let result = update(images.filter(id.eq(index)))
|
||||||
|
@ -285,7 +367,6 @@ mod image_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn update_file_path(
|
pub fn update_file_path(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -294,11 +375,8 @@ mod image_model {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles
|
||||||
.append(self.as_ref().get_role_id(Role::PathRole));
|
.append(self.as_ref().get_role_id(Role::PathRole));
|
||||||
let model_index = &self.as_ref().index(
|
let model_index =
|
||||||
index,
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
0,
|
|
||||||
&QModelIndex::default(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
let result = update(images.filter(id.eq(index)))
|
let result = update(images.filter(id.eq(index)))
|
||||||
|
@ -326,7 +404,6 @@ mod image_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn get_item(
|
pub fn get_item(
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -339,9 +416,7 @@ mod image_model {
|
||||||
}
|
}
|
||||||
let role_names = self.as_ref().role_names();
|
let role_names = self.as_ref().role_names();
|
||||||
let role_names_iter = role_names.iter();
|
let role_names_iter = role_names.iter();
|
||||||
if let Some(image) =
|
if let Some(image) = self.rust().images.get(index as usize) {
|
||||||
self.rust().images.get(index as usize)
|
|
||||||
{
|
|
||||||
for i in role_names_iter {
|
for i in role_names_iter {
|
||||||
qvariantmap.insert(
|
qvariantmap.insert(
|
||||||
QString::from(&i.1.to_string()),
|
QString::from(&i.1.to_string()),
|
||||||
|
@ -354,72 +429,23 @@ mod image_model {
|
||||||
|
|
||||||
fn get_role_id(&self, role: Role) -> i32 {
|
fn get_role_id(&self, role: Role) -> i32 {
|
||||||
match role {
|
match role {
|
||||||
Role::IdRole => 0,
|
qobject::Role::Id => 0,
|
||||||
Role::TitleRole => 1,
|
qobject::Role::Title => 1,
|
||||||
Role::PathRole => 2,
|
qobject::Role::Path => 2,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Rust bindings for C++ functions of the base class (QAbstractItemModel)
|
// QAbstractListModel implementation
|
||||||
#[cxx_qt::inherit]
|
impl qobject::ImageModel {
|
||||||
extern "C++" {
|
|
||||||
unsafe fn begin_insert_rows(
|
|
||||||
self: Pin<&mut qobject::ImageModel>,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
first: i32,
|
|
||||||
last: i32,
|
|
||||||
);
|
|
||||||
unsafe fn end_insert_rows(
|
|
||||||
self: Pin<&mut qobject::ImageModel>,
|
|
||||||
);
|
|
||||||
|
|
||||||
unsafe fn begin_remove_rows(
|
|
||||||
self: Pin<&mut qobject::ImageModel>,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
first: i32,
|
|
||||||
last: i32,
|
|
||||||
);
|
|
||||||
unsafe fn end_remove_rows(
|
|
||||||
self: Pin<&mut qobject::ImageModel>,
|
|
||||||
);
|
|
||||||
|
|
||||||
unsafe fn begin_reset_model(
|
|
||||||
self: Pin<&mut qobject::ImageModel>,
|
|
||||||
);
|
|
||||||
unsafe fn end_reset_model(
|
|
||||||
self: Pin<&mut qobject::ImageModel>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cxx_qt::inherit]
|
|
||||||
unsafe extern "C++" {
|
|
||||||
#[cxx_name = "canFetchMore"]
|
|
||||||
fn base_can_fetch_more(
|
|
||||||
self: &qobject::ImageModel,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
) -> bool;
|
|
||||||
|
|
||||||
fn index(
|
|
||||||
self: &qobject::ImageModel,
|
|
||||||
row: i32,
|
|
||||||
column: i32,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
) -> QModelIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
// QAbstractListModel implementation
|
|
||||||
impl qobject::ImageModel {
|
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
||||||
if let Some(image) =
|
let role = qobject::Roles { repr: role };
|
||||||
self.images().get(index.row() as usize)
|
if let Some(image) = self.images().get(index.row() as usize) {
|
||||||
{
|
|
||||||
return match role {
|
return match role {
|
||||||
0 => QVariant::from(&image.id),
|
qobject::Roles::Id => QVariant::from(&image.id),
|
||||||
1 => QVariant::from(&image.title),
|
qobject::Roles::Title => QVariant::from(&image.title),
|
||||||
2 => QVariant::from(&image.path),
|
qobject::Roles::Path => QVariant::from(&image.path),
|
||||||
_ => QVariant::default(),
|
_ => QVariant::default(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -428,21 +454,28 @@ mod image_model {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example of overriding a C++ virtual method and calling the base class implementation.
|
// Example of overriding a C++ virtual method and calling the base class implementation.
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
||||||
self.base_can_fetch_more(parent)
|
self.base_can_fetch_more(parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
||||||
let mut roles = QHash_i32_QByteArray::default();
|
let mut roles = QHash_i32_QByteArray::default();
|
||||||
roles.insert(0, cxx_qt_lib::QByteArray::from("id"));
|
roles.insert(
|
||||||
roles.insert(1, cxx_qt_lib::QByteArray::from("title"));
|
qobject::Roles::Id.repr,
|
||||||
roles.insert(2, cxx_qt_lib::QByteArray::from("filePath"));
|
cxx_qt_lib::QByteArray::from("id"),
|
||||||
|
);
|
||||||
|
roles.insert(
|
||||||
|
qobject::Roles::Title.repr,
|
||||||
|
cxx_qt_lib::QByteArray::from("title"),
|
||||||
|
);
|
||||||
|
roles.insert(
|
||||||
|
qobject::Roles::Path.repr,
|
||||||
|
cxx_qt_lib::QByteArray::from("filePath"),
|
||||||
|
);
|
||||||
roles
|
roles
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
||||||
let cnt = self.rust().images.len() as i32;
|
let cnt = self.rust().images.len() as i32;
|
||||||
// self.as_mut().set_count(cnt);
|
// self.as_mut().set_count(cnt);
|
||||||
|
@ -450,11 +483,9 @@ mod image_model {
|
||||||
cnt
|
cnt
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn count(mut self: Pin<&mut Self>) -> i32 {
|
pub fn count(mut self: Pin<&mut Self>) -> i32 {
|
||||||
let cnt = self.rust().images.len() as i32;
|
let cnt = self.rust().images.len() as i32;
|
||||||
self.as_mut().set_count_rows(cnt);
|
self.as_mut().set_count_rows(cnt);
|
||||||
cnt
|
cnt
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,3 +16,4 @@ pub mod utils;
|
||||||
pub mod video_model;
|
pub mod video_model;
|
||||||
pub mod ytdl;
|
pub mod ytdl;
|
||||||
// mod video_thumbnail;
|
// mod video_thumbnail;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
mod presentation_model {
|
mod presentation_model {
|
||||||
use crate::presentation_model::presentation_model::Presentation;
|
|
||||||
use crate::reveal_js;
|
|
||||||
use crate::schema::presentations::dsl::*;
|
|
||||||
use diesel::sqlite::SqliteConnection;
|
|
||||||
use diesel::{delete, insert_into, prelude::*, update};
|
|
||||||
// use sqlx::Connection;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use tracing::debug;
|
|
||||||
|
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!(< QAbstractListModel >);
|
include!(< QAbstractListModel >);
|
||||||
include!("cxx-qt-lib/qhash.h");
|
include!("cxx-qt-lib/qhash.h");
|
||||||
|
@ -33,44 +24,194 @@ mod presentation_model {
|
||||||
type QList_QString = cxx_qt_lib::QList<QString>;
|
type QList_QString = cxx_qt_lib::QList<QString>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug)]
|
#[qenum(PresentationModel)]
|
||||||
pub struct Presentation {
|
enum Role {
|
||||||
|
Id,
|
||||||
|
Title,
|
||||||
|
Path,
|
||||||
|
Html,
|
||||||
|
PageCount,
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "RustQt" {
|
||||||
|
#[qobject]
|
||||||
|
#[base = "QAbstractListModel"]
|
||||||
|
#[qml_element]
|
||||||
|
#[qproperty(i32, count_rows)]
|
||||||
|
type PresentationModel = super::PresentationModelRust;
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
#[qsignal]
|
||||||
|
fn data_changed(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
top_left: &QModelIndex,
|
||||||
|
bottom_right: &QModelIndex,
|
||||||
|
roles: &QVector_i32,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn clear(self: Pin<&mut PresentationModel>);
|
||||||
|
#[qinvokable]
|
||||||
|
fn setup(self: Pin<&mut PresentationModel>);
|
||||||
|
#[qinvokable]
|
||||||
|
fn remove_item(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
index: i32,
|
||||||
|
) -> bool;
|
||||||
|
#[qinvokable]
|
||||||
|
fn new_item(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
url: QUrl,
|
||||||
|
new_page_count: i32,
|
||||||
|
);
|
||||||
|
#[qinvokable]
|
||||||
|
fn update_path(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
index: i32,
|
||||||
|
updated_path: QString,
|
||||||
|
) -> bool;
|
||||||
|
#[qinvokable]
|
||||||
|
fn get_item(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
index: i32,
|
||||||
|
) -> QMap_QString_QVariant;
|
||||||
|
#[qinvokable]
|
||||||
|
fn update_loop(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
index: i32,
|
||||||
|
loop_value: bool,
|
||||||
|
) -> bool;
|
||||||
|
#[qinvokable]
|
||||||
|
fn update_title(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
index: i32,
|
||||||
|
updated_title: QString,
|
||||||
|
) -> bool;
|
||||||
|
#[qinvokable]
|
||||||
|
fn update_page_count(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
index: i32,
|
||||||
|
updated_page_count: i32,
|
||||||
|
) -> bool;
|
||||||
|
#[qinvokable]
|
||||||
|
fn update_end_time(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
index: i32,
|
||||||
|
updated_end_stime: QString,
|
||||||
|
) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl cxx_qt::Threading for PresentationModel {}
|
||||||
|
|
||||||
|
unsafe extern "RustQt" {
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn begin_insert_rows(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
parent: &QModelIndex,
|
||||||
|
first: i32,
|
||||||
|
last: i32,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn end_insert_rows(self: Pin<&mut PresentationModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn begin_remove_rows(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
parent: &QModelIndex,
|
||||||
|
first: i32,
|
||||||
|
last: i32,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn begin_move_rows(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
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 PresentationModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn end_remove_rows(self: Pin<&mut PresentationModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn begin_reset_model(
|
||||||
|
self: Pin<&mut PresentationModel>,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn end_reset_model(self: Pin<&mut PresentationModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
fn can_fetch_more(
|
||||||
|
self: &PresentationModel,
|
||||||
|
parent: &QModelIndex,
|
||||||
|
) -> bool;
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
fn index(
|
||||||
|
self: &PresentationModel,
|
||||||
|
row: i32,
|
||||||
|
column: i32,
|
||||||
|
parent: &QModelIndex,
|
||||||
|
) -> QModelIndex;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
#[cxx_override]
|
||||||
|
fn data(
|
||||||
|
self: &PresentationModel,
|
||||||
|
index: &QModelIndex,
|
||||||
|
role: i32,
|
||||||
|
) -> QVariant;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
#[cxx_override]
|
||||||
|
fn role_names(
|
||||||
|
self: &PresentationModel,
|
||||||
|
) -> QHash_i32_QByteArray;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
#[cxx_override]
|
||||||
|
fn row_count(
|
||||||
|
self: &PresentationModel,
|
||||||
|
_parent: &QModelIndex,
|
||||||
|
) -> i32;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn count(self: &PresentationModel) -> i32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
use crate::presentation_model::presentation_model::Presentation;
|
||||||
|
use crate::reveal_js;
|
||||||
|
use crate::schema::presentations::dsl::*;
|
||||||
|
use diesel::sqlite::SqliteConnection;
|
||||||
|
use diesel::{delete, insert_into, prelude::*, update};
|
||||||
|
// use sqlx::Connection;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use tracing::debug;
|
||||||
|
|
||||||
|
#[derive(Default, Clone, Debug)]
|
||||||
|
pub struct Presentation {
|
||||||
id: i32,
|
id: i32,
|
||||||
title: String,
|
title: String,
|
||||||
html: bool,
|
html: bool,
|
||||||
path: String,
|
path: String,
|
||||||
page_count: i32,
|
page_count: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cxx_qt::qobject(base = "QAbstractListModel")]
|
#[derive(Default, Debug)]
|
||||||
#[derive(Default, Debug)]
|
pub struct PresentationModelRust {
|
||||||
pub struct PresentationModel {
|
|
||||||
highest_id: i32,
|
highest_id: i32,
|
||||||
presentations: Vec<self::Presentation>,
|
presentations: Vec<self::Presentation>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cxx_qt::qsignals(PresentationModel)]
|
impl qobject::PresentationModel {
|
||||||
pub enum Signals<'a> {
|
|
||||||
#[inherit]
|
|
||||||
DataChanged {
|
|
||||||
top_left: &'a QModelIndex,
|
|
||||||
bottom_right: &'a QModelIndex,
|
|
||||||
roles: &'a QVector_i32,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
enum Role {
|
|
||||||
IdRole,
|
|
||||||
PathRole,
|
|
||||||
TitleRole,
|
|
||||||
HtmlRole,
|
|
||||||
PageCountRole,
|
|
||||||
}
|
|
||||||
|
|
||||||
// use crate::entities::{presentations, prelude::Presentations};
|
|
||||||
// use sea_orm::{ConnectionTrait, Database, DbBackend, DbErr, Statement, ActiveValue};
|
|
||||||
impl qobject::PresentationModel {
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn clear(mut self: Pin<&mut Self>) {
|
pub fn clear(mut self: Pin<&mut Self>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_reset_model();
|
self.as_mut().begin_reset_model();
|
||||||
|
@ -79,7 +220,6 @@ mod presentation_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn setup(mut self: Pin<&mut Self>) {
|
pub fn setup(mut self: Pin<&mut Self>) {
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
// let table_info = diesel::sql_query("PRAGMA table_info(presentations)").load(db);
|
// let table_info = diesel::sql_query("PRAGMA table_info(presentations)").load(db);
|
||||||
|
@ -116,13 +256,8 @@ mod presentation_model {
|
||||||
println!("--------------------------------------");
|
println!("--------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) -> bool {
|
||||||
pub fn remove_item(
|
if index < 0 || (index as usize) >= self.presentations().len()
|
||||||
mut self: Pin<&mut Self>,
|
|
||||||
index: i32,
|
|
||||||
) -> bool {
|
|
||||||
if index < 0
|
|
||||||
|| (index as usize) >= self.presentations().len()
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -173,12 +308,11 @@ mod presentation_model {
|
||||||
db_url.push_str(data.to_str().unwrap());
|
db_url.push_str(data.to_str().unwrap());
|
||||||
println!("DB: {:?}", db_url);
|
println!("DB: {:?}", db_url);
|
||||||
|
|
||||||
SqliteConnection::establish(&db_url).unwrap_or_else(
|
SqliteConnection::establish(&db_url).unwrap_or_else(|_| {
|
||||||
|_| panic!("error connecting to {}", db_url),
|
panic!("error connecting to {}", db_url)
|
||||||
)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn new_item(
|
pub fn new_item(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
url: QUrl,
|
url: QUrl,
|
||||||
|
@ -186,8 +320,7 @@ mod presentation_model {
|
||||||
) {
|
) {
|
||||||
println!("LETS INSERT THIS SUCKER!");
|
println!("LETS INSERT THIS SUCKER!");
|
||||||
let file_path = PathBuf::from(url.path().to_string());
|
let file_path = PathBuf::from(url.path().to_string());
|
||||||
let name =
|
let name = 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;
|
let presentation_path = url;
|
||||||
|
@ -209,7 +342,6 @@ mod presentation_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn add_item(
|
pub fn add_item(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
presentation_id: i32,
|
presentation_id: i32,
|
||||||
|
@ -222,13 +354,10 @@ mod presentation_model {
|
||||||
// println!("{:?}", db);
|
// println!("{:?}", db);
|
||||||
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 =
|
||||||
presentation_path.path().to_string(),
|
PathBuf::from(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!(
|
||||||
page_count = actual_page_count,
|
page_count = actual_page_count,
|
||||||
|
@ -285,7 +414,6 @@ mod presentation_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn get_item(
|
pub fn get_item(
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -311,20 +439,15 @@ mod presentation_model {
|
||||||
qvariantmap
|
qvariantmap
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn update_title(
|
pub fn update_title(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
updated_title: QString,
|
updated_title: QString,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles.append(self.as_ref().get_role(Role::TitleRole));
|
||||||
.append(self.as_ref().get_role(Role::TitleRole));
|
let model_index =
|
||||||
let model_index = &self.as_ref().index(
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
index,
|
|
||||||
0,
|
|
||||||
&QModelIndex::default(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
let result = update(presentations.filter(id.eq(index)))
|
let result = update(presentations.filter(id.eq(index)))
|
||||||
|
@ -338,12 +461,8 @@ mod presentation_model {
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|x| x.id == index)
|
.filter(|x| x.id == index)
|
||||||
{
|
{
|
||||||
presentation.title =
|
presentation.title = updated_title.to_string();
|
||||||
updated_title.to_string();
|
println!("rust-title: {:?}", presentation.title);
|
||||||
println!(
|
|
||||||
"rust-title: {:?}",
|
|
||||||
presentation.title
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
// TODO this seems to not be updating in the actual list
|
// TODO this seems to not be updating in the actual list
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().emit_data_changed(
|
||||||
|
@ -359,7 +478,6 @@ mod presentation_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn update_page_count(
|
pub fn update_page_count(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -368,11 +486,8 @@ mod presentation_model {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles
|
||||||
.append(self.as_ref().get_role(Role::PageCountRole));
|
.append(self.as_ref().get_role(Role::PageCountRole));
|
||||||
let model_index = &self.as_ref().index(
|
let model_index =
|
||||||
index,
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
0,
|
|
||||||
&QModelIndex::default(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
let result = update(presentations.filter(id.eq(index)))
|
let result = update(presentations.filter(id.eq(index)))
|
||||||
|
@ -399,10 +514,7 @@ mod presentation_model {
|
||||||
&vector_roles,
|
&vector_roles,
|
||||||
);
|
);
|
||||||
// self.as_mut().emit_page_count_changed();
|
// self.as_mut().emit_page_count_changed();
|
||||||
println!(
|
println!("rust-page_count: {:?}", updated_page_count);
|
||||||
"rust-page_count: {:?}",
|
|
||||||
updated_page_count
|
|
||||||
);
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Err(_e) => false,
|
Err(_e) => false,
|
||||||
|
@ -419,72 +531,29 @@ mod presentation_model {
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Rust bindings for C++ functions of the base class (QAbstractItemModel)
|
// QAbstractListModel implementation
|
||||||
#[cxx_qt::inherit]
|
impl qobject::PresentationModel {
|
||||||
extern "C++" {
|
|
||||||
unsafe fn begin_insert_rows(
|
|
||||||
self: Pin<&mut qobject::PresentationModel>,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
first: i32,
|
|
||||||
last: i32,
|
|
||||||
);
|
|
||||||
unsafe fn end_insert_rows(
|
|
||||||
self: Pin<&mut qobject::PresentationModel>,
|
|
||||||
);
|
|
||||||
|
|
||||||
unsafe fn begin_remove_rows(
|
|
||||||
self: Pin<&mut qobject::PresentationModel>,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
first: i32,
|
|
||||||
last: i32,
|
|
||||||
);
|
|
||||||
unsafe fn end_remove_rows(
|
|
||||||
self: Pin<&mut qobject::PresentationModel>,
|
|
||||||
);
|
|
||||||
|
|
||||||
unsafe fn begin_reset_model(
|
|
||||||
self: Pin<&mut qobject::PresentationModel>,
|
|
||||||
);
|
|
||||||
unsafe fn end_reset_model(
|
|
||||||
self: Pin<&mut qobject::PresentationModel>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cxx_qt::inherit]
|
|
||||||
unsafe extern "C++" {
|
|
||||||
#[cxx_name = "canFetchMore"]
|
|
||||||
fn base_can_fetch_more(
|
|
||||||
self: &qobject::PresentationModel,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
) -> bool;
|
|
||||||
|
|
||||||
fn index(
|
|
||||||
self: &qobject::PresentationModel,
|
|
||||||
row: i32,
|
|
||||||
column: i32,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
) -> QModelIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
// QAbstractListModel implementation
|
|
||||||
impl qobject::PresentationModel {
|
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
||||||
|
let role = qobject::Roles { repr: role };
|
||||||
if let Some(presentation) =
|
if let Some(presentation) =
|
||||||
self.presentations().get(index.row() as usize)
|
self.presentations().get(index.row() as usize)
|
||||||
{
|
{
|
||||||
return match role {
|
return match role {
|
||||||
0 => QVariant::from(&presentation.id),
|
qobject::Role::Id => QVariant::from(&presentation.id),
|
||||||
1 => QVariant::from(&QString::from(
|
qobject::Role::Title => QVariant::from(
|
||||||
&presentation.title,
|
&QString::from(&presentation.title),
|
||||||
)),
|
),
|
||||||
2 => QVariant::from(&QString::from(
|
qobject::Role::Path => {
|
||||||
&presentation.path,
|
QVariant::from(&QString::from(&presentation.path))
|
||||||
)),
|
}
|
||||||
3 => QVariant::from(&presentation.html),
|
qobject::Role::Html => {
|
||||||
4 => QVariant::from(&presentation.page_count),
|
QVariant::from(&presentation.html)
|
||||||
|
}
|
||||||
|
qobject::Role::PageCount => {
|
||||||
|
QVariant::from(&presentation.page_count)
|
||||||
|
}
|
||||||
_ => QVariant::default(),
|
_ => QVariant::default(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -493,33 +562,43 @@ mod presentation_model {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example of overriding a C++ virtual method and calling the base class implementation.
|
// Example of overriding a C++ virtual method and calling the base class implementation.
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
||||||
self.base_can_fetch_more(parent)
|
self.base_can_fetch_more(parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
||||||
let mut roles = QHash_i32_QByteArray::default();
|
let mut roles = QHash_i32_QByteArray::default();
|
||||||
roles.insert(0, cxx_qt_lib::QByteArray::from("id"));
|
roles.insert(
|
||||||
roles.insert(1, cxx_qt_lib::QByteArray::from("title"));
|
qobject::Roles::Id.repr,
|
||||||
roles.insert(2, cxx_qt_lib::QByteArray::from("filePath"));
|
cxx_qt_lib::QByteArray::from("id"),
|
||||||
roles.insert(3, cxx_qt_lib::QByteArray::from("html"));
|
);
|
||||||
roles
|
roles.insert(
|
||||||
.insert(4, cxx_qt_lib::QByteArray::from("pageCount"));
|
qobject::Roles::Title.repr,
|
||||||
|
cxx_qt_lib::QByteArray::from("title"),
|
||||||
|
);
|
||||||
|
roles.insert(
|
||||||
|
qobject::Roles::Path.repr,
|
||||||
|
cxx_qt_lib::QByteArray::from("filePath"),
|
||||||
|
);
|
||||||
|
roles.insert(
|
||||||
|
qobject::Roles::Html.repr,
|
||||||
|
cxx_qt_lib::QByteArray::from("html"),
|
||||||
|
);
|
||||||
|
roles.insert(
|
||||||
|
qobject::Roles::PageCount.repr,
|
||||||
|
cxx_qt_lib::QByteArray::from("pageCount"),
|
||||||
|
);
|
||||||
roles
|
roles
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
||||||
let cnt = self.rust().presentations.len() as i32;
|
let cnt = self.rust().presentations.len() as i32;
|
||||||
// println!("row count is {cnt}");
|
// println!("row count is {cnt}");
|
||||||
cnt
|
cnt
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn count(&self) -> i32 {
|
pub fn count(&self) -> i32 {
|
||||||
self.rust().presentations.len() as i32
|
self.rust().presentations.len() as i32
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,44 +24,262 @@ mod service_item_model {
|
||||||
type QUrl = cxx_qt_lib::QUrl;
|
type QUrl = cxx_qt_lib::QUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::obs::Obs;
|
#[qenum(ServiceItemModel)]
|
||||||
use serde::{Deserialize, Serialize};
|
enum Role {
|
||||||
#[cxx_qt::qobject]
|
Name,
|
||||||
#[derive(Clone, Debug)]
|
Type,
|
||||||
pub struct ServiceItm {
|
Audio,
|
||||||
#[qproperty]
|
Background,
|
||||||
name: QString,
|
BackgroundType,
|
||||||
#[qproperty]
|
Text,
|
||||||
ty: QString,
|
Font,
|
||||||
#[qproperty]
|
FontSize,
|
||||||
audio: QString,
|
SlideCount,
|
||||||
#[qproperty]
|
Active,
|
||||||
background: QString,
|
Selected,
|
||||||
#[qproperty]
|
Looping,
|
||||||
background_type: QString,
|
VideoStartTime,
|
||||||
#[qproperty]
|
VideoEndTime,
|
||||||
text: QStringList,
|
|
||||||
#[qproperty]
|
|
||||||
font: QString,
|
|
||||||
#[qproperty]
|
|
||||||
font_size: i32,
|
|
||||||
#[qproperty]
|
|
||||||
slide_count: i32,
|
|
||||||
#[qproperty]
|
|
||||||
active: bool,
|
|
||||||
#[qproperty]
|
|
||||||
selected: bool,
|
|
||||||
#[qproperty]
|
|
||||||
looping: bool,
|
|
||||||
#[qproperty]
|
|
||||||
video_start_time: f32,
|
|
||||||
#[qproperty]
|
|
||||||
video_end_time: f32,
|
|
||||||
#[qproperty]
|
|
||||||
obs_scene: QString,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ServiceItm {
|
unsafe extern "RustQt" {
|
||||||
|
#[qobject]
|
||||||
|
#[base = "QAbstractListModel"]
|
||||||
|
#[qml_element]
|
||||||
|
type ServiceItemModel = super::ServiceItemModelRust;
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
#[qsignal]
|
||||||
|
fn data_changed(
|
||||||
|
self: Pin<&mut ServiceItemModel>,
|
||||||
|
top_left: &QModelIndex,
|
||||||
|
bottom_right: &QModelIndex,
|
||||||
|
roles: &QVector_i32,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[qsignal]
|
||||||
|
fn active_changed(self: Pin<&mut ServiceItemModel>, index: &i32);
|
||||||
|
#[qsignal]
|
||||||
|
fn selected_changed(self: Pin<&mut ServiceItemModel>);
|
||||||
|
#[qsignal]
|
||||||
|
fn item_inserted(self: Pin<&mut ServiceItemModel>, index: &i32, item: &QMap_QString_QVariant);
|
||||||
|
#[qsignal]
|
||||||
|
fn item_added(self: Pin<&mut ServiceItemModel>, index: &i32, item: &QMap_QString_QVariant);
|
||||||
|
#[qsignal]
|
||||||
|
fn item_removed(self: Pin<&mut ServiceItemModel>, index: &i32, item: &QMap_QString_QVariant);
|
||||||
|
#[qsignal]
|
||||||
|
fn item_moved(self: Pin<&mut ServiceItemModel>, source_index: &i32, dest_index: &i32, item: &QMap_QString_QVariant);
|
||||||
|
#[qsignal]
|
||||||
|
fn cleared(self: Pin<&mut ServiceItemModel>);
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn clear(self: Pin<&mut ServiceItemModel>);
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn remove_item(self: Pin<&mut ServiceItemModel>, index: i32);
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn add_item(
|
||||||
|
self: Pin<&mut ServiceItemModel>,
|
||||||
|
name: QString,
|
||||||
|
ty: QString,
|
||||||
|
background: QString,
|
||||||
|
background_type: QString,
|
||||||
|
text: QStringList,
|
||||||
|
audio: QString,
|
||||||
|
font: QString,
|
||||||
|
font_size: i32,
|
||||||
|
slide_count: i32,
|
||||||
|
looping: bool,
|
||||||
|
video_start_time: f32,
|
||||||
|
video_end_time: f32,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn insert_item(
|
||||||
|
self: Pin<&mut ServiceItemModel>,
|
||||||
|
index: i32,
|
||||||
|
name: QString,
|
||||||
|
text: QStringList,
|
||||||
|
ty: QString,
|
||||||
|
background: QString,
|
||||||
|
background_type: QString,
|
||||||
|
audio: QString,
|
||||||
|
font: QString,
|
||||||
|
font_size: i32,
|
||||||
|
slide_count: i32,
|
||||||
|
looping: bool,
|
||||||
|
video_start_time: f32,
|
||||||
|
video_end_time: f32,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn get_item(
|
||||||
|
self: Pin<&mut ServiceItemModel>,
|
||||||
|
index: i32,
|
||||||
|
) -> QMap_QString_QVariant;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn move_rows(
|
||||||
|
self: Pin<&mut ServiceItemModel>,
|
||||||
|
source_index: i32,
|
||||||
|
dest_index: i32,
|
||||||
|
count: i32,
|
||||||
|
) -> bool;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn move_up(self: Pin<&mut ServiceItemModel>, index: i32) -> bool;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn move_down(self: Pin<&mut ServiceItemModel>, index: i32) -> bool;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn select(self: Pin<&mut ServiceItemModel>, index: i32) -> bool;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn select_items(
|
||||||
|
self: Pin<&mut ServiceItemModel>,
|
||||||
|
final_index: i32,
|
||||||
|
) -> bool;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
pub fn activate(
|
||||||
|
self: Pin<&mut ServiceItemModel>,
|
||||||
|
index: i32,
|
||||||
|
) -> bool;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
pub fn deactivate(
|
||||||
|
self: Pin<&mut ServiceItemModel>,
|
||||||
|
index: i32,
|
||||||
|
) -> bool;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn save(self: Pin<&mut ServiceItemModel>, file: QUrl) -> bool;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn load(self: Pin<&mut ServiceItemModel>, file: QUrl) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl cxx_qt::Threading for ServiceItemModel {}
|
||||||
|
|
||||||
|
unsafe extern "RustQt" {
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn begin_insert_rows(
|
||||||
|
self: Pin<&mut ServiceItemModel>,
|
||||||
|
parent: &QModelIndex,
|
||||||
|
first: i32,
|
||||||
|
last: i32,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn end_insert_rows(self: Pin<&mut ServiceItemModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn begin_remove_rows(
|
||||||
|
self: Pin<&mut ServiceItemModel>,
|
||||||
|
parent: &QModelIndex,
|
||||||
|
first: i32,
|
||||||
|
last: i32,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn begin_move_rows(
|
||||||
|
self: Pin<&mut ServiceItemModel>,
|
||||||
|
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 ServiceItemModel>,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn end_remove_rows(self: Pin<&mut ServiceItemModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn begin_reset_model(self: Pin<&mut ServiceItemModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
unsafe fn end_reset_model(self: Pin<&mut ServiceItemModel>);
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
fn can_fetch_more(
|
||||||
|
self: &ServiceItemModel,
|
||||||
|
parent: &QModelIndex,
|
||||||
|
) -> bool;
|
||||||
|
|
||||||
|
#[inherit]
|
||||||
|
fn index(
|
||||||
|
self: &ServiceItemModel,
|
||||||
|
row: i32,
|
||||||
|
column: i32,
|
||||||
|
parent: &QModelIndex,
|
||||||
|
) -> QModelIndex;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
#[cxx_override]
|
||||||
|
fn data(
|
||||||
|
self: &ServiceItemModel,
|
||||||
|
index: &QModelIndex,
|
||||||
|
role: i32,
|
||||||
|
) -> QVariant;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
#[cxx_override]
|
||||||
|
fn role_names(self: &ServiceItemModel) -> QHash_i32_QByteArray;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
#[cxx_override]
|
||||||
|
fn row_count(self: &ServiceItemModel, _parent: &QModelIndex)
|
||||||
|
-> i32;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn count(self: &ServiceItemModel) -> i32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
use dirs;
|
||||||
|
use serde_json::{json, Deserializer, Map, Serializer, Value};
|
||||||
|
use std::ffi::{OsStr, OsString};
|
||||||
|
use std::io::{self, Read, Write};
|
||||||
|
use std::iter;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::str;
|
||||||
|
use std::{fs, println};
|
||||||
|
use tar::{Archive, Builder};
|
||||||
|
use tracing::{debug, debug_span, error, info, instrument};
|
||||||
|
use zstd::{Decoder, Encoder};
|
||||||
|
use crate::obs::Obs;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct ServiceItm {
|
||||||
|
name: QString,
|
||||||
|
ty: QString,
|
||||||
|
audio: QString,
|
||||||
|
background: QString,
|
||||||
|
background_type: QString,
|
||||||
|
text: QStringList,
|
||||||
|
font: QString,
|
||||||
|
font_size: i32,
|
||||||
|
slide_count: i32,
|
||||||
|
active: bool,
|
||||||
|
selected: bool,
|
||||||
|
looping: bool,
|
||||||
|
video_start_time: f32,
|
||||||
|
video_end_time: f32,
|
||||||
|
obs_scene: QString,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ServiceItm {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
name: QString::default(),
|
name: QString::default(),
|
||||||
|
@ -81,17 +299,16 @@ mod service_item_model {
|
||||||
obs_scene: QString::default(),
|
obs_scene: QString::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cxx_qt::qobject(base = "QAbstractListModel")]
|
#[derive(Debug)]
|
||||||
#[derive(Debug)]
|
pub struct ServiceItemModelRust {
|
||||||
pub struct ServiceItemMod {
|
|
||||||
id: i32,
|
id: i32,
|
||||||
service_items: Vec<ServiceItm>,
|
service_items: Vec<ServiceItm>,
|
||||||
obs: Option<Obs>,
|
obs: Option<Obs>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ServiceItemMod {
|
impl Default for ServiceItemModelRust {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let obs = tokio::runtime::Runtime::new()
|
let obs = tokio::runtime::Runtime::new()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -110,78 +327,13 @@ mod service_item_model {
|
||||||
obs,
|
obs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cxx_qt::qsignals(ServiceItemMod)]
|
impl qobject::ServiceItemModel {
|
||||||
pub enum Signals<'a> {
|
|
||||||
#[inherit]
|
|
||||||
DataChanged {
|
|
||||||
top_left: &'a QModelIndex,
|
|
||||||
bottom_right: &'a QModelIndex,
|
|
||||||
roles: &'a QVector_i32,
|
|
||||||
},
|
|
||||||
ActiveChanged {
|
|
||||||
index: &'a i32,
|
|
||||||
},
|
|
||||||
SelectedChanged,
|
|
||||||
ItemInserted {
|
|
||||||
index: &'a i32,
|
|
||||||
item: &'a QMap_QString_QVariant,
|
|
||||||
},
|
|
||||||
ItemAdded {
|
|
||||||
index: &'a i32,
|
|
||||||
item: &'a QMap_QString_QVariant,
|
|
||||||
},
|
|
||||||
ItemRemoved {
|
|
||||||
index: &'a i32,
|
|
||||||
item: &'a QMap_QString_QVariant,
|
|
||||||
},
|
|
||||||
ItemMoved {
|
|
||||||
source_index: &'a i32,
|
|
||||||
dest_index: &'a i32,
|
|
||||||
// index: &'a i32,
|
|
||||||
item: &'a QMap_QString_QVariant,
|
|
||||||
},
|
|
||||||
Cleared {},
|
|
||||||
}
|
|
||||||
|
|
||||||
enum Role {
|
|
||||||
NameRole,
|
|
||||||
TyRole,
|
|
||||||
AudioRole,
|
|
||||||
BackgroundRole,
|
|
||||||
BackgroundTypeRole,
|
|
||||||
TextRole,
|
|
||||||
FontRole,
|
|
||||||
FontSizeRole,
|
|
||||||
SlideCountRole,
|
|
||||||
ActiveRole,
|
|
||||||
SelectedRole,
|
|
||||||
LoopingRole,
|
|
||||||
VideoStartTimeRole,
|
|
||||||
VideoEndTimeRole,
|
|
||||||
}
|
|
||||||
|
|
||||||
// use crate::video_thumbnail;
|
|
||||||
// use image::{ImageBuffer, Rgba};
|
|
||||||
use dirs;
|
|
||||||
use serde_json::{json, Deserializer, Map, Serializer, Value};
|
|
||||||
use std::ffi::{OsStr, OsString};
|
|
||||||
use std::io::{self, Read, Write};
|
|
||||||
use std::iter;
|
|
||||||
use std::path::{Path, PathBuf};
|
|
||||||
use std::str;
|
|
||||||
use std::{fs, println};
|
|
||||||
use tar::{Archive, Builder};
|
|
||||||
use tracing::{debug, debug_span, error, info, instrument};
|
|
||||||
use zstd::{Decoder, Encoder};
|
|
||||||
|
|
||||||
impl qobject::ServiceItemMod {
|
|
||||||
pub fn setup(mut self: Pin<&mut Self>) {
|
pub fn setup(mut self: Pin<&mut Self>) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn clear(mut self: Pin<&mut Self>) {
|
pub fn clear(mut self: Pin<&mut Self>) {
|
||||||
println!("CLEARING ALL ITEMS");
|
println!("CLEARING ALL ITEMS");
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -192,7 +344,6 @@ mod service_item_model {
|
||||||
self.emit(Signals::Cleared {});
|
self.emit(Signals::Cleared {});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) {
|
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) {
|
||||||
if index < 0
|
if index < 0
|
||||||
|| (index as usize) >= self.service_items().len()
|
|| (index as usize) >= self.service_items().len()
|
||||||
|
@ -215,7 +366,6 @@ mod service_item_model {
|
||||||
self.as_mut().emit_item_removed(&index, &item);
|
self.as_mut().emit_item_removed(&index, &item);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn add_item(
|
pub fn add_item(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
name: QString,
|
name: QString,
|
||||||
|
@ -270,7 +420,6 @@ mod service_item_model {
|
||||||
self.as_mut().emit_item_added(&index, &item);
|
self.as_mut().emit_item_added(&index, &item);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn insert_item(
|
pub fn insert_item(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -327,7 +476,6 @@ mod service_item_model {
|
||||||
self.as_mut().emit_item_inserted(&id, &item);
|
self.as_mut().emit_item_inserted(&id, &item);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn get_item(
|
pub fn get_item(
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -353,7 +501,6 @@ mod service_item_model {
|
||||||
map
|
map
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn move_rows(
|
pub fn move_rows(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
source_index: i32,
|
source_index: i32,
|
||||||
|
@ -418,17 +565,14 @@ mod service_item_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn move_up(self: Pin<&mut Self>, index: i32) -> bool {
|
pub fn move_up(self: Pin<&mut Self>, index: i32) -> bool {
|
||||||
self.move_rows(index, index - 1, 1)
|
self.move_rows(index, index - 1, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn move_down(self: Pin<&mut Self>, index: i32) -> bool {
|
pub fn move_down(self: Pin<&mut Self>, index: i32) -> bool {
|
||||||
self.move_rows(index, index + 1, 1)
|
self.move_rows(index, index + 1, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn select(mut self: Pin<&mut Self>, index: i32) -> bool {
|
pub fn select(mut self: Pin<&mut Self>, index: i32) -> bool {
|
||||||
let rc = self.as_ref().count() - 1;
|
let rc = self.as_ref().count() - 1;
|
||||||
let tl =
|
let tl =
|
||||||
|
@ -464,7 +608,6 @@ mod service_item_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn select_items(
|
pub fn select_items(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
final_index: i32,
|
final_index: i32,
|
||||||
|
@ -592,7 +735,6 @@ mod service_item_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn activate(
|
pub fn activate(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -644,12 +786,10 @@ mod service_item_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn deactivate(
|
pub fn deactivate(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
todo!();
|
|
||||||
let rc = self.as_ref().count() - 1;
|
let rc = self.as_ref().count() - 1;
|
||||||
let tl =
|
let tl =
|
||||||
&self.as_ref().index(0, 0, &QModelIndex::default());
|
&self.as_ref().index(0, 0, &QModelIndex::default());
|
||||||
|
@ -689,7 +829,7 @@ mod service_item_model {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[qinvokable]
|
|
||||||
pub fn save(mut self: Pin<&mut Self>, file: QUrl) -> bool {
|
pub fn save(mut self: Pin<&mut Self>, file: QUrl) -> bool {
|
||||||
println!("rust-save-file: {file}");
|
println!("rust-save-file: {file}");
|
||||||
let path =
|
let path =
|
||||||
|
@ -888,7 +1028,6 @@ mod service_item_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn load(mut self: Pin<&mut Self>, file: QUrl) -> bool {
|
pub fn load(mut self: Pin<&mut Self>, file: QUrl) -> bool {
|
||||||
self.as_mut().clear();
|
self.as_mut().clear();
|
||||||
println!("file is: {file}");
|
println!("file is: {file}");
|
||||||
|
@ -1132,7 +1271,6 @@ mod service_item_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn load_last_saved(mut self: Pin<&mut Self>) -> bool {
|
pub fn load_last_saved(mut self: Pin<&mut Self>) -> bool {
|
||||||
todo!();
|
todo!();
|
||||||
// Don't actually need
|
// Don't actually need
|
||||||
|
@ -1157,94 +1295,34 @@ mod service_item_model {
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Rust bindings for C++ functions of the base class (QAbstractItem_Modelel)
|
// QAbstractListModel implementation
|
||||||
#[cxx_qt::inherit]
|
impl qobject::ServiceItemMod {
|
||||||
extern "C++" {
|
|
||||||
unsafe fn begin_insert_rows(
|
|
||||||
self: Pin<&mut qobject::ServiceItemMod>,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
first: i32,
|
|
||||||
last: i32,
|
|
||||||
);
|
|
||||||
unsafe fn end_insert_rows(
|
|
||||||
self: Pin<&mut qobject::ServiceItemMod>,
|
|
||||||
);
|
|
||||||
|
|
||||||
unsafe fn begin_move_rows(
|
|
||||||
self: Pin<&mut qobject::ServiceItemMod>,
|
|
||||||
source_parent: &QModelIndex,
|
|
||||||
source_first: i32,
|
|
||||||
source_last: i32,
|
|
||||||
destination_parent: &QModelIndex,
|
|
||||||
destination_child: i32,
|
|
||||||
) -> bool;
|
|
||||||
|
|
||||||
unsafe fn end_move_rows(
|
|
||||||
self: Pin<&mut qobject::ServiceItemMod>,
|
|
||||||
);
|
|
||||||
|
|
||||||
unsafe fn begin_remove_rows(
|
|
||||||
self: Pin<&mut qobject::ServiceItemMod>,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
first: i32,
|
|
||||||
last: i32,
|
|
||||||
);
|
|
||||||
unsafe fn end_remove_rows(
|
|
||||||
self: Pin<&mut qobject::ServiceItemMod>,
|
|
||||||
);
|
|
||||||
|
|
||||||
unsafe fn begin_reset_model(
|
|
||||||
self: Pin<&mut qobject::ServiceItemMod>,
|
|
||||||
);
|
|
||||||
unsafe fn end_reset_model(
|
|
||||||
self: Pin<&mut qobject::ServiceItemMod>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cxx_qt::inherit]
|
|
||||||
unsafe extern "C++" {
|
|
||||||
#[cxx_name = "canFetchMore"]
|
|
||||||
fn base_can_fetch_more(
|
|
||||||
self: &qobject::ServiceItemMod,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
) -> bool;
|
|
||||||
|
|
||||||
fn index(
|
|
||||||
self: &qobject::ServiceItemMod,
|
|
||||||
row: i32,
|
|
||||||
column: i32,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
) -> QModelIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
// QAbstractListModel implementation
|
|
||||||
impl qobject::ServiceItemMod {
|
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
||||||
|
let role = qobject::Roles { repr: role };
|
||||||
if let Some(service_item) =
|
if let Some(service_item) =
|
||||||
self.service_items().get(index.row() as usize)
|
self.service_items().get(index.row() as usize)
|
||||||
{
|
{
|
||||||
return match role {
|
return match role {
|
||||||
0 => QVariant::from(&service_item.name),
|
qobject::Roles::Name => QVariant::from(&service_item.name),
|
||||||
1 => QVariant::from(&service_item.ty),
|
qobject::Roles::Type => QVariant::from(&service_item.ty),
|
||||||
2 => QVariant::from(&service_item.audio),
|
qobject::Roles::Audio => QVariant::from(&service_item.audio),
|
||||||
3 => QVariant::from(&service_item.background),
|
qobject::Roles::Background => QVariant::from(&service_item.background),
|
||||||
4 => {
|
qobject::Roles::BackgroundType => {
|
||||||
QVariant::from(&service_item.background_type)
|
QVariant::from(&service_item.background_type)
|
||||||
}
|
}
|
||||||
5 => QVariant::from(&service_item.text),
|
qobject::Roles::Text => QVariant::from(&service_item.text),
|
||||||
6 => QVariant::from(&service_item.font),
|
qobject::Roles::Font => QVariant::from(&service_item.font),
|
||||||
7 => QVariant::from(&service_item.font_size),
|
qobject::Roles::FontSize => QVariant::from(&service_item.font_size),
|
||||||
8 => QVariant::from(&service_item.slide_count),
|
qobject::Roles::SlideCount => QVariant::from(&service_item.slide_count),
|
||||||
9 => QVariant::from(&service_item.active),
|
qobject::Roles::Active => QVariant::from(&service_item.active),
|
||||||
10 => QVariant::from(&service_item.selected),
|
qobject::Roles::Selected => QVariant::from(&service_item.selected),
|
||||||
11 => QVariant::from(&service_item.looping),
|
qobject::Roles::Looping => QVariant::from(&service_item.looping),
|
||||||
12 => {
|
qobject::Roles::VideoStartTime => {
|
||||||
QVariant::from(&service_item.video_start_time)
|
QVariant::from(&service_item.video_start_time)
|
||||||
}
|
}
|
||||||
13 => {
|
qobject::Roles::VideoEndTime => {
|
||||||
QVariant::from(&service_item.video_end_time)
|
QVariant::from(&service_item.video_end_time)
|
||||||
}
|
}
|
||||||
_ => QVariant::default(),
|
_ => QVariant::default(),
|
||||||
|
@ -1255,57 +1333,52 @@ mod service_item_model {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example of overriding a C++ virtual method and calling the base class implementation.
|
// Example of overriding a C++ virtual method and calling the base class implementation.
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
||||||
self.base_can_fetch_more(parent)
|
self.base_can_fetch_more(parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
||||||
let mut roles = QHash_i32_QByteArray::default();
|
let mut roles = QHash_i32_QByteArray::default();
|
||||||
roles.insert(0, cxx_qt_lib::QByteArray::from("name"));
|
roles.insert(qobject::Roles::Name.repr, cxx_qt_lib::QByteArray::from("name"));
|
||||||
roles.insert(1, cxx_qt_lib::QByteArray::from("ty"));
|
roles.insert(qobject::Roles::Type.repr, cxx_qt_lib::QByteArray::from("ty"));
|
||||||
roles.insert(2, cxx_qt_lib::QByteArray::from("audio"));
|
roles.insert(qobject::Roles::Audio.repr, cxx_qt_lib::QByteArray::from("audio"));
|
||||||
roles.insert(
|
roles.insert(
|
||||||
3,
|
qobject::Roles::Background.repr,
|
||||||
cxx_qt_lib::QByteArray::from("background"),
|
cxx_qt_lib::QByteArray::from("background"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
4,
|
qobject::Roles::BackgroundType,
|
||||||
cxx_qt_lib::QByteArray::from("backgroundType"),
|
cxx_qt_lib::QByteArray::from("backgroundType"),
|
||||||
);
|
);
|
||||||
roles.insert(5, cxx_qt_lib::QByteArray::from("text"));
|
roles.insert(qobject::Roles::Text.repr, cxx_qt_lib::QByteArray::from("text"));
|
||||||
roles.insert(6, cxx_qt_lib::QByteArray::from("font"));
|
roles.insert(qobject::Roles::Font.repr, cxx_qt_lib::QByteArray::from("font"));
|
||||||
roles.insert(7, cxx_qt_lib::QByteArray::from("fontSize"));
|
roles.insert(qobject::Roles::FontSize.repr, cxx_qt_lib::QByteArray::from("fontSize"));
|
||||||
roles.insert(
|
roles.insert(
|
||||||
8,
|
qobject::Roles::SlideCount.repr,
|
||||||
cxx_qt_lib::QByteArray::from("slideCount"),
|
cxx_qt_lib::QByteArray::from("slideCount"),
|
||||||
);
|
);
|
||||||
roles.insert(9, cxx_qt_lib::QByteArray::from("active"));
|
roles.insert(qobject::Roles::Active.repr, cxx_qt_lib::QByteArray::from("active"));
|
||||||
roles
|
roles
|
||||||
.insert(10, cxx_qt_lib::QByteArray::from("selected"));
|
.insert(qobject::Roles::Selected.repr, cxx_qt_lib::QByteArray::from("selected"));
|
||||||
roles.insert(11, cxx_qt_lib::QByteArray::from("looping"));
|
roles.insert(qobject::Roles::Looping.repr, cxx_qt_lib::QByteArray::from("looping"));
|
||||||
roles.insert(
|
roles.insert(
|
||||||
12,
|
qobject::Roles::VideoStartTime.repr,
|
||||||
cxx_qt_lib::QByteArray::from("videoStartTime"),
|
cxx_qt_lib::QByteArray::from("videoStartTime"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
13,
|
qobject::Roles::VideoEndTime.repr,
|
||||||
cxx_qt_lib::QByteArray::from("videoEndTime"),
|
cxx_qt_lib::QByteArray::from("videoEndTime"),
|
||||||
);
|
);
|
||||||
roles
|
roles
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
||||||
let cnt = self.rust().service_items.len() as i32;
|
let cnt = self.rust().service_items.len() as i32;
|
||||||
// println!("row count is {cnt}");
|
// println!("row count is {cnt}");
|
||||||
cnt
|
cnt
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn count(&self) -> i32 {
|
pub fn count(&self) -> i32 {
|
||||||
self.rust().service_items.len() as i32
|
self.rust().service_items.len() as i32
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,6 @@ pub struct SlideModelRust {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl qobject::SlideModel {
|
impl qobject::SlideModel {
|
||||||
#[qinvokable]
|
|
||||||
pub fn add_video_thumbnail(
|
pub fn add_video_thumbnail(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -285,7 +284,6 @@ impl qobject::SlideModel {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn clear(mut self: Pin<&mut Self>) {
|
pub fn clear(mut self: Pin<&mut Self>) {
|
||||||
println!("CLEARING ALL SLIDES");
|
println!("CLEARING ALL SLIDES");
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -295,7 +293,6 @@ impl qobject::SlideModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn remove_item_from_service(
|
pub fn remove_item_from_service(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -324,7 +321,6 @@ impl qobject::SlideModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) {
|
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) {
|
||||||
if index < 0 || (index as usize) >= self.slides().len() {
|
if index < 0 || (index as usize) >= self.slides().len() {
|
||||||
return;
|
return;
|
||||||
|
@ -394,7 +390,6 @@ impl qobject::SlideModel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn insert_item_from_service(
|
pub fn insert_item_from_service(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -586,7 +581,6 @@ impl qobject::SlideModel {
|
||||||
println!("Item added in slide model!");
|
println!("Item added in slide model!");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn add_item_from_service(
|
pub fn add_item_from_service(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -742,7 +736,6 @@ impl qobject::SlideModel {
|
||||||
println!("Item added in rust model!");
|
println!("Item added in rust model!");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn move_item_from_service(
|
pub fn move_item_from_service(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
source_index: i32,
|
source_index: i32,
|
||||||
|
@ -948,7 +941,6 @@ impl qobject::SlideModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn get_item(
|
pub fn get_item(
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -972,7 +964,6 @@ impl qobject::SlideModel {
|
||||||
qvariantmap
|
qvariantmap
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn get_slide_from_service(
|
pub fn get_slide_from_service(
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -992,7 +983,6 @@ impl qobject::SlideModel {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn activate(mut self: Pin<&mut Self>, index: i32) -> bool {
|
pub fn activate(mut self: Pin<&mut Self>, index: i32) -> bool {
|
||||||
let rc = self.as_ref().count() - 1;
|
let rc = self.as_ref().count() - 1;
|
||||||
let tl = &self.as_ref().index(0, 0, &QModelIndex::default());
|
let tl = &self.as_ref().index(0, 0, &QModelIndex::default());
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
mod video_model {
|
mod video_model {
|
||||||
use crate::models::*;
|
|
||||||
use crate::schema::videos::dsl::*;
|
|
||||||
use crate::video_model::video_model::Video;
|
|
||||||
use diesel::sqlite::SqliteConnection;
|
|
||||||
use diesel::{delete, insert_into, prelude::*, update};
|
|
||||||
use std::path::{Path, PathBuf};
|
|
||||||
|
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!(< QAbstractListModel >);
|
include!(< QAbstractListModel >);
|
||||||
include!("cxx-qt-lib/qhash.h");
|
include!("cxx-qt-lib/qhash.h");
|
||||||
|
@ -31,44 +24,184 @@ mod video_model {
|
||||||
type QList_QString = cxx_qt_lib::QList<QString>;
|
type QList_QString = cxx_qt_lib::QList<QString>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug)]
|
#[qenum(VideoModel)]
|
||||||
pub struct Video {
|
enum Role {
|
||||||
|
Id,
|
||||||
|
Title,
|
||||||
|
Path,
|
||||||
|
StartTime,
|
||||||
|
EndTime,
|
||||||
|
Looping,
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "RustQt" {
|
||||||
|
#[qobject]
|
||||||
|
#[base = "QAbstractListModel"]
|
||||||
|
#[qml_element]
|
||||||
|
#[qproperty(i32, count_rows)]
|
||||||
|
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: QString,
|
||||||
|
) -> bool;
|
||||||
|
#[qinvokable]
|
||||||
|
fn update_end_time(
|
||||||
|
self: Pin<&mut VideoModel>,
|
||||||
|
index: i32,
|
||||||
|
updated_end_time: QString,
|
||||||
|
) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
fn count(self: &VideoModel) -> i32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
use crate::models::*;
|
||||||
|
use crate::schema::videos::dsl::*;
|
||||||
|
use crate::video_model::video_model::Video;
|
||||||
|
use diesel::sqlite::SqliteConnection;
|
||||||
|
use diesel::{delete, insert_into, prelude::*, update};
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
#[derive(Default, Clone, Debug)]
|
||||||
|
pub struct Video {
|
||||||
id: i32,
|
id: i32,
|
||||||
title: QString,
|
title: QString,
|
||||||
path: QString,
|
path: QString,
|
||||||
start_time: f32,
|
start_time: f32,
|
||||||
end_time: f32,
|
end_time: f32,
|
||||||
looping: bool,
|
looping: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cxx_qt::qobject(base = "QAbstractListModel")]
|
#[derive(Default, Debug)]
|
||||||
#[derive(Default, Debug)]
|
pub struct VideoModelRust {
|
||||||
pub struct VideoModel {
|
|
||||||
highest_id: i32,
|
highest_id: i32,
|
||||||
videos: Vec<self::Video>,
|
videos: Vec<self::Video>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cxx_qt::qsignals(VideoModel)]
|
impl qobject::VideoModel {
|
||||||
pub enum Signals<'a> {
|
|
||||||
#[inherit]
|
|
||||||
DataChanged {
|
|
||||||
top_left: &'a QModelIndex,
|
|
||||||
bottom_right: &'a QModelIndex,
|
|
||||||
roles: &'a QVector_i32,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
enum Role {
|
|
||||||
IdRole,
|
|
||||||
TitleRole,
|
|
||||||
PathRole,
|
|
||||||
StartTimeRole,
|
|
||||||
EndTimeRole,
|
|
||||||
LoopingRole,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl qobject::VideoModel {
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn clear(mut self: Pin<&mut Self>) {
|
pub fn clear(mut self: Pin<&mut Self>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_reset_model();
|
self.as_mut().begin_reset_model();
|
||||||
|
@ -77,7 +210,6 @@ mod video_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn setup(mut self: Pin<&mut Self>) {
|
pub fn setup(mut self: Pin<&mut Self>) {
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
let results = videos
|
let results = videos
|
||||||
|
@ -112,18 +244,13 @@ mod video_model {
|
||||||
println!("--------------------------------------");
|
println!("--------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) -> bool {
|
||||||
pub fn remove_item(
|
|
||||||
mut self: Pin<&mut Self>,
|
|
||||||
index: i32,
|
|
||||||
) -> bool {
|
|
||||||
if index < 0 || (index as usize) >= self.videos().len() {
|
if index < 0 || (index as usize) >= self.videos().len() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
|
|
||||||
let video_id =
|
let video_id = self.videos().get(index as usize).unwrap().id;
|
||||||
self.videos().get(index as usize).unwrap().id;
|
|
||||||
|
|
||||||
let result =
|
let result =
|
||||||
delete(videos.filter(id.eq(video_id))).execute(db);
|
delete(videos.filter(id.eq(video_id))).execute(db);
|
||||||
|
@ -136,9 +263,7 @@ mod video_model {
|
||||||
index,
|
index,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut()
|
self.as_mut().videos_mut().remove(index as usize);
|
||||||
.videos_mut()
|
|
||||||
.remove(index as usize);
|
|
||||||
self.as_mut().end_remove_rows();
|
self.as_mut().end_remove_rows();
|
||||||
}
|
}
|
||||||
println!("removed-item-at-index: {:?}", video_id);
|
println!("removed-item-at-index: {:?}", video_id);
|
||||||
|
@ -160,26 +285,20 @@ mod video_model {
|
||||||
db_url.push_str(data.to_str().unwrap());
|
db_url.push_str(data.to_str().unwrap());
|
||||||
println!("DB: {:?}", db_url);
|
println!("DB: {:?}", db_url);
|
||||||
|
|
||||||
SqliteConnection::establish(&db_url).unwrap_or_else(
|
SqliteConnection::establish(&db_url).unwrap_or_else(|_| {
|
||||||
|_| panic!("error connecting to {}", db_url),
|
panic!("error connecting to {}", db_url)
|
||||||
)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn new_item(mut self: Pin<&mut Self>, url: QUrl) {
|
pub fn new_item(mut self: Pin<&mut Self>, url: QUrl) {
|
||||||
println!("LETS INSERT THIS SUCKER!");
|
println!("LETS INSERT THIS SUCKER!");
|
||||||
let file_path = PathBuf::from(url.path().to_string());
|
let file_path = PathBuf::from(url.path().to_string());
|
||||||
let name =
|
let name = file_path.file_stem().unwrap().to_str().unwrap();
|
||||||
file_path.file_stem().unwrap().to_str().unwrap();
|
|
||||||
let video_id = self.rust().highest_id + 1;
|
let video_id = self.rust().highest_id + 1;
|
||||||
let video_title = QString::from(name);
|
let video_title = QString::from(name);
|
||||||
let video_path = url.to_qstring();
|
let video_path = url.to_qstring();
|
||||||
|
|
||||||
if self.as_mut().add_item(
|
if self.as_mut().add_item(video_id, video_title, video_path) {
|
||||||
video_id,
|
|
||||||
video_title,
|
|
||||||
video_path,
|
|
||||||
) {
|
|
||||||
println!("filename: {:?}", name);
|
println!("filename: {:?}", name);
|
||||||
self.as_mut().set_highest_id(video_id);
|
self.as_mut().set_highest_id(video_id);
|
||||||
} else {
|
} else {
|
||||||
|
@ -187,7 +306,6 @@ mod video_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn add_item(
|
pub fn add_item(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
video_id: i32,
|
video_id: i32,
|
||||||
|
@ -247,7 +365,6 @@ mod video_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn get_item(
|
pub fn get_item(
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -260,9 +377,7 @@ mod video_model {
|
||||||
}
|
}
|
||||||
let role_names = self.as_ref().role_names();
|
let role_names = self.as_ref().role_names();
|
||||||
let role_names_iter = role_names.iter();
|
let role_names_iter = role_names.iter();
|
||||||
if let Some(video) =
|
if let Some(video) = self.rust().videos.get(index as usize) {
|
||||||
self.rust().videos.get(index as usize)
|
|
||||||
{
|
|
||||||
for i in role_names_iter {
|
for i in role_names_iter {
|
||||||
qvariantmap.insert(
|
qvariantmap.insert(
|
||||||
QString::from(&i.1.to_string()),
|
QString::from(&i.1.to_string()),
|
||||||
|
@ -286,7 +401,6 @@ mod video_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn update_loop(
|
pub fn update_loop(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -295,11 +409,8 @@ mod video_model {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles
|
||||||
.append(self.as_ref().get_role(Role::LoopingRole));
|
.append(self.as_ref().get_role(Role::LoopingRole));
|
||||||
let model_index = &self.as_ref().index(
|
let model_index =
|
||||||
index,
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
0,
|
|
||||||
&QModelIndex::default(),
|
|
||||||
);
|
|
||||||
println!("rust-video: {:?}", index);
|
println!("rust-video: {:?}", index);
|
||||||
println!("rust-loop: {:?}", loop_value);
|
println!("rust-loop: {:?}", loop_value);
|
||||||
|
|
||||||
|
@ -330,7 +441,6 @@ mod video_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn update_end_time(
|
pub fn update_end_time(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -339,11 +449,8 @@ mod video_model {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles
|
||||||
.append(self.as_ref().get_role(Role::EndTimeRole));
|
.append(self.as_ref().get_role(Role::EndTimeRole));
|
||||||
let model_index = &self.as_ref().index(
|
let model_index =
|
||||||
index,
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
0,
|
|
||||||
&QModelIndex::default(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
let result = update(videos.filter(id.eq(index)))
|
let result = update(videos.filter(id.eq(index)))
|
||||||
|
@ -371,7 +478,6 @@ mod video_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn update_start_time(
|
pub fn update_start_time(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -380,11 +486,8 @@ mod video_model {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles
|
||||||
.append(self.as_ref().get_role(Role::StartTimeRole));
|
.append(self.as_ref().get_role(Role::StartTimeRole));
|
||||||
let model_index = &self.as_ref().index(
|
let model_index =
|
||||||
index,
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
0,
|
|
||||||
&QModelIndex::default(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
let result = update(videos.filter(id.eq(index)))
|
let result = update(videos.filter(id.eq(index)))
|
||||||
|
@ -405,30 +508,22 @@ mod video_model {
|
||||||
model_index,
|
model_index,
|
||||||
&vector_roles,
|
&vector_roles,
|
||||||
);
|
);
|
||||||
println!(
|
println!("rust-start-time: {:?}", updated_start_time);
|
||||||
"rust-start-time: {:?}",
|
|
||||||
updated_start_time
|
|
||||||
);
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Err(_e) => false,
|
Err(_e) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn update_title(
|
pub fn update_title(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
updated_title: QString,
|
updated_title: QString,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles.append(self.as_ref().get_role(Role::TitleRole));
|
||||||
.append(self.as_ref().get_role(Role::TitleRole));
|
let model_index =
|
||||||
let model_index = &self.as_ref().index(
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
index,
|
|
||||||
0,
|
|
||||||
&QModelIndex::default(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
let result = update(videos.filter(id.eq(index)))
|
let result = update(videos.filter(id.eq(index)))
|
||||||
|
@ -459,20 +554,15 @@ mod video_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn update_path(
|
pub fn update_path(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
updated_path: QString,
|
updated_path: QString,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles.append(self.as_ref().get_role(Role::PathRole));
|
||||||
.append(self.as_ref().get_role(Role::PathRole));
|
let model_index =
|
||||||
let model_index = &self.as_ref().index(
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
index,
|
|
||||||
0,
|
|
||||||
&QModelIndex::default(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
let result = update(videos.filter(id.eq(index)))
|
let result = update(videos.filter(id.eq(index)))
|
||||||
|
@ -500,69 +590,26 @@ mod video_model {
|
||||||
Err(_e) => false,
|
Err(_e) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Rust bindings for C++ functions of the base class (QAbstractItemModel)
|
// QAbstractListModel implementation
|
||||||
#[cxx_qt::inherit]
|
impl qobject::VideoModel {
|
||||||
extern "C++" {
|
|
||||||
unsafe fn begin_insert_rows(
|
|
||||||
self: Pin<&mut qobject::VideoModel>,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
first: i32,
|
|
||||||
last: i32,
|
|
||||||
);
|
|
||||||
unsafe fn end_insert_rows(
|
|
||||||
self: Pin<&mut qobject::VideoModel>,
|
|
||||||
);
|
|
||||||
|
|
||||||
unsafe fn begin_remove_rows(
|
|
||||||
self: Pin<&mut qobject::VideoModel>,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
first: i32,
|
|
||||||
last: i32,
|
|
||||||
);
|
|
||||||
unsafe fn end_remove_rows(
|
|
||||||
self: Pin<&mut qobject::VideoModel>,
|
|
||||||
);
|
|
||||||
|
|
||||||
unsafe fn begin_reset_model(
|
|
||||||
self: Pin<&mut qobject::VideoModel>,
|
|
||||||
);
|
|
||||||
unsafe fn end_reset_model(
|
|
||||||
self: Pin<&mut qobject::VideoModel>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cxx_qt::inherit]
|
|
||||||
unsafe extern "C++" {
|
|
||||||
#[cxx_name = "canFetchMore"]
|
|
||||||
fn base_can_fetch_more(
|
|
||||||
self: &qobject::VideoModel,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
) -> bool;
|
|
||||||
|
|
||||||
fn index(
|
|
||||||
self: &qobject::VideoModel,
|
|
||||||
row: i32,
|
|
||||||
column: i32,
|
|
||||||
parent: &QModelIndex,
|
|
||||||
) -> QModelIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
// QAbstractListModel implementation
|
|
||||||
impl qobject::VideoModel {
|
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
||||||
if let Some(video) =
|
let role = qobject::Roles { repr: role };
|
||||||
self.videos().get(index.row() as usize)
|
if let Some(video) = self.videos().get(index.row() as usize) {
|
||||||
{
|
|
||||||
return match role {
|
return match role {
|
||||||
0 => QVariant::from(&video.id),
|
qobject::Role::Id => QVariant::from(&video.id),
|
||||||
1 => QVariant::from(&video.title),
|
qobject::Role::Title => QVariant::from(&video.title),
|
||||||
2 => QVariant::from(&video.path),
|
qobject::Role::Path => QVariant::from(&video.path),
|
||||||
3 => QVariant::from(&video.start_time),
|
qobject::Role::StartTime => {
|
||||||
4 => QVariant::from(&video.end_time),
|
QVariant::from(&video.start_time)
|
||||||
5 => QVariant::from(&video.looping),
|
}
|
||||||
|
qobject::Role::EndTime => {
|
||||||
|
QVariant::from(&video.end_time)
|
||||||
|
}
|
||||||
|
qobject::Role::Looping => {
|
||||||
|
QVariant::from(&video.looping)
|
||||||
|
}
|
||||||
_ => QVariant::default(),
|
_ => QVariant::default(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -571,34 +618,47 @@ mod video_model {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example of overriding a C++ virtual method and calling the base class implementation.
|
// Example of overriding a C++ virtual method and calling the base class implementation.
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
||||||
self.base_can_fetch_more(parent)
|
self.base_can_fetch_more(parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
||||||
let mut roles = QHash_i32_QByteArray::default();
|
let mut roles = QHash_i32_QByteArray::default();
|
||||||
roles.insert(0, cxx_qt_lib::QByteArray::from("id"));
|
roles.insert(
|
||||||
roles.insert(1, cxx_qt_lib::QByteArray::from("title"));
|
qobject::Roles::Id.repr,
|
||||||
roles.insert(2, cxx_qt_lib::QByteArray::from("filePath"));
|
cxx_qt_lib::QByteArray::from("id"),
|
||||||
roles
|
);
|
||||||
.insert(3, cxx_qt_lib::QByteArray::from("startTime"));
|
roles.insert(
|
||||||
roles.insert(4, cxx_qt_lib::QByteArray::from("endTime"));
|
qobject::Roles::Title.repr,
|
||||||
roles.insert(5, cxx_qt_lib::QByteArray::from("loop"));
|
cxx_qt_lib::QByteArray::from("title"),
|
||||||
|
);
|
||||||
|
roles.insert(
|
||||||
|
qobject::Roles::Path.repr,
|
||||||
|
cxx_qt_lib::QByteArray::from("filePath"),
|
||||||
|
);
|
||||||
|
roles.insert(
|
||||||
|
qobject::Roles::StartTime.repr,
|
||||||
|
cxx_qt_lib::QByteArray::from("startTime"),
|
||||||
|
);
|
||||||
|
roles.insert(
|
||||||
|
qobject::Roles::EndTime.repr,
|
||||||
|
cxx_qt_lib::QByteArray::from("endTime"),
|
||||||
|
);
|
||||||
|
roles.insert(
|
||||||
|
qobject::Roles::Looping.repr,
|
||||||
|
cxx_qt_lib::QByteArray::from("loop"),
|
||||||
|
);
|
||||||
roles
|
roles
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable(cxx_override)]
|
|
||||||
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
||||||
let cnt = self.rust().videos.len() as i32;
|
let cnt = self.rust().videos.len() as i32;
|
||||||
// println!("row count is {cnt}");
|
// println!("row count is {cnt}");
|
||||||
cnt
|
cnt
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn count(&self) -> i32 {
|
pub fn count(&self) -> i32 {
|
||||||
self.rust().videos.len() as i32
|
self.rust().videos.len() as i32
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue