727 lines
23 KiB
Rust
727 lines
23 KiB
Rust
#[cxx_qt::bridge]
|
|
mod video_model {
|
|
unsafe extern "C++" {
|
|
include!(< QAbstractListModel >);
|
|
include!("cxx-qt-lib/qhash.h");
|
|
type QHash_i32_QByteArray =
|
|
cxx_qt_lib::QHash<cxx_qt_lib::QHashPair_i32_QByteArray>;
|
|
include!("cxx-qt-lib/qmap.h");
|
|
type QMap_QString_QVariant =
|
|
cxx_qt_lib::QMap<cxx_qt_lib::QMapPair_QString_QVariant>;
|
|
include!("cxx-qt-lib/qvariant.h");
|
|
type QVariant = cxx_qt_lib::QVariant;
|
|
include!("cxx-qt-lib/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<i32>;
|
|
// 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<QString>;
|
|
}
|
|
|
|
#[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 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,
|
|
path: String,
|
|
start_time: f32,
|
|
end_time: f32,
|
|
looping: bool,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct VideoModelRust {
|
|
count: i32,
|
|
highest_id: i32,
|
|
videos: Vec<Video>,
|
|
inner_videos: Vec<Video>,
|
|
db: SqliteConnection,
|
|
}
|
|
|
|
impl Default for VideoModelRust {
|
|
fn default() -> Self {
|
|
Self {
|
|
count: 0,
|
|
highest_id: 0,
|
|
videos: vec![],
|
|
inner_videos: vec![],
|
|
db: {
|
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
let mut data = dirs::data_local_dir().unwrap();
|
|
data.push("lumina");
|
|
data.push("library-db.sqlite3");
|
|
let mut db_url = String::from("sqlite://");
|
|
db_url.push_str(data.to_str().unwrap());
|
|
rt.block_on(async {
|
|
SqliteConnection::connect(&db_url).await.expect("problems")
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
impl video_model::VideoModel {
|
|
pub fn clear(mut self: Pin<&mut Self>) {
|
|
unsafe {
|
|
self.as_mut().begin_reset_model();
|
|
self.as_mut().rust_mut().videos.clear();
|
|
self.as_mut().end_reset_model();
|
|
}
|
|
}
|
|
|
|
pub fn setup(mut self: Pin<&mut Self>) {
|
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
rt.block_on(async {
|
|
let result = query_as!(Video, r#"SELECT id as "id: i32", title as "title!", filePath as "path!", startTime as "start_time!: f32", endTime as "end_time!: f32", loop as "looping!" from videos"#).fetch_all(&mut self.as_mut().rust_mut().db).await;
|
|
match result {
|
|
Ok(v) => v.into_iter().for_each(|v| self.as_mut().add_video(v)),
|
|
Err(e) => error!("There was an error in converting songs: {e}"),
|
|
}
|
|
});
|
|
}
|
|
|
|
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) -> bool {
|
|
if index < 0 || (index as usize) >= self.videos.len() {
|
|
return false;
|
|
}
|
|
let video_id = self.videos.get(index as usize).unwrap().id;
|
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
|
|
rt.block_on(async {
|
|
let result = query!("delete from videos where id = ?", video_id).execute(&mut self.as_mut().rust_mut().db).await;
|
|
match result {
|
|
Ok(_i) => {
|
|
unsafe {
|
|
self.as_mut().begin_remove_rows(
|
|
&QModelIndex::default(),
|
|
index,
|
|
index,
|
|
);
|
|
self.as_mut()
|
|
.rust_mut()
|
|
.videos
|
|
.remove(index as usize);
|
|
self.as_mut()
|
|
.rust_mut()
|
|
.inner_videos
|
|
.remove(index as usize);
|
|
self.as_mut().end_remove_rows();
|
|
}
|
|
debug!("removed-item-at-index: {:?}", video_id);
|
|
true
|
|
}
|
|
Err(e) => {
|
|
error!("Cannot connect to database: {e}");
|
|
false
|
|
}
|
|
}
|
|
});
|
|
true
|
|
}
|
|
|
|
pub fn new_item(mut self: Pin<&mut Self>, url: QUrl) {
|
|
println!("LETS INSERT THIS SUCKER!");
|
|
let file_path = PathBuf::from(url.path().to_string());
|
|
let name = file_path.file_stem().unwrap().to_str().unwrap();
|
|
let video_id = self.rust().highest_id + 1;
|
|
let video_title = QString::from(name);
|
|
let video_path = url.to_qstring();
|
|
|
|
if self.as_mut().add_item(video_id, video_title, video_path) {
|
|
println!("filename: {:?}", name);
|
|
self.as_mut().rust_mut().highest_id = video_id;
|
|
} else {
|
|
println!("Error in inserting item");
|
|
}
|
|
}
|
|
|
|
pub fn add_item(
|
|
mut self: Pin<&mut Self>,
|
|
video_id: i32,
|
|
video_title: QString,
|
|
video_path: QString,
|
|
) -> bool {
|
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
rt.block_on(async {
|
|
let video_title = video_title.to_string();
|
|
let video_path = video_path.to_string();
|
|
let result = query!(r#"INSERT into videos (id, title, filePath, startTime, endTime, loop) VALUES (?, ?, ?, ?, ?, ?)"#,
|
|
video_id,
|
|
video_title,
|
|
video_path,
|
|
0.0,
|
|
0.0,
|
|
false).execute(&mut self.as_mut().rust_mut().db).await;
|
|
|
|
match result {
|
|
Ok(_i) => {
|
|
let video = Video {
|
|
id: video_id,
|
|
title: video_title.to_string(),
|
|
path: video_path.to_string(),
|
|
start_time: 0.0,
|
|
end_time: 0.0,
|
|
looping: false
|
|
};
|
|
self.as_mut().add_video(video);
|
|
debug!("{:?}", self.as_mut().videos);
|
|
true
|
|
}
|
|
Err(e) => {
|
|
error!(
|
|
"Cannot connect to database: {e}"
|
|
);
|
|
false
|
|
}
|
|
}
|
|
});
|
|
true
|
|
}
|
|
|
|
fn add_video(mut self: Pin<&mut Self>, video: self::Video) {
|
|
let index = self.as_ref().videos.len() as i32;
|
|
println!("{:?}", video);
|
|
let count = self.as_mut().count;
|
|
self.as_mut().set_count(count + 1);
|
|
unsafe {
|
|
self.as_mut().begin_insert_rows(
|
|
&QModelIndex::default(),
|
|
index,
|
|
index,
|
|
);
|
|
self.as_mut().rust_mut().videos.push(video.clone());
|
|
self.as_mut().rust_mut().inner_videos.push(video);
|
|
self.as_mut().end_insert_rows();
|
|
}
|
|
}
|
|
|
|
pub fn get_item(
|
|
self: Pin<&mut Self>,
|
|
index: i32,
|
|
) -> QMap_QString_QVariant {
|
|
println!("{index}");
|
|
let mut qvariantmap = QMap_QString_QVariant::default();
|
|
let idx = self.index(index, 0, &QModelIndex::default());
|
|
if !idx.is_valid() {
|
|
return qvariantmap;
|
|
}
|
|
let role_names = self.as_ref().role_names();
|
|
let role_names_iter = role_names.iter();
|
|
if let Some(video) = self.rust().videos.get(index as usize) {
|
|
for i in role_names_iter {
|
|
qvariantmap.insert(
|
|
QString::from(&i.1.to_string()),
|
|
self.as_ref().data(&idx, *i.0),
|
|
);
|
|
}
|
|
println!("gotted-video: {:?}", video);
|
|
};
|
|
qvariantmap
|
|
}
|
|
|
|
fn get_role(&self, role: VideoRoles) -> i32 {
|
|
match role {
|
|
VideoRoles::Id => 0,
|
|
VideoRoles::Title => 1,
|
|
VideoRoles::Path => 2,
|
|
VideoRoles::StartTime => 3,
|
|
VideoRoles::EndTime => 4,
|
|
VideoRoles::Looping => 5,
|
|
_ => 0,
|
|
}
|
|
}
|
|
|
|
pub fn update_loop(
|
|
mut self: Pin<&mut Self>,
|
|
index: i32,
|
|
loop_value: bool,
|
|
) -> bool {
|
|
let mut vector_roles = QVector_i32::default();
|
|
vector_roles
|
|
.append(self.as_ref().get_role(VideoRoles::Looping));
|
|
let model_index =
|
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
|
println!("rust-video: {:?}", index);
|
|
println!("rust-loop: {:?}", loop_value);
|
|
|
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
rt.block_on(async {
|
|
let result = query!("UPDATE videos SET loop = ? where id = ?", loop_value, index)
|
|
.execute(&mut self.as_mut().rust_mut().db)
|
|
.await;
|
|
match result {
|
|
Ok(_i) => {
|
|
for video in self
|
|
.as_mut()
|
|
.rust_mut()
|
|
.videos
|
|
.iter_mut()
|
|
.filter(|x| x.id == index)
|
|
{
|
|
video.looping = loop_value;
|
|
debug!(title = video.title,
|
|
looping = loop_value,
|
|
"updated video loop");
|
|
}
|
|
self.as_mut().data_changed(
|
|
model_index,
|
|
model_index,
|
|
&vector_roles,
|
|
);
|
|
true
|
|
}
|
|
Err(e) => {
|
|
error!("Error connecting to db: {e}");
|
|
false
|
|
},
|
|
}
|
|
});
|
|
true
|
|
}
|
|
|
|
pub fn update_end_time(
|
|
mut self: Pin<&mut Self>,
|
|
index: i32,
|
|
updated_end_time: f32,
|
|
) -> bool {
|
|
let mut vector_roles = QVector_i32::default();
|
|
vector_roles
|
|
.append(self.as_ref().get_role(VideoRoles::EndTime));
|
|
let model_index =
|
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
|
|
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
rt.block_on(async {
|
|
let result = query!("UPDATE videos SET endTime = ? where id = ?", updated_end_time, index)
|
|
.execute(&mut self.as_mut().rust_mut().db)
|
|
.await;
|
|
match result {
|
|
Ok(_i) => {
|
|
for video in self
|
|
.as_mut()
|
|
.rust_mut()
|
|
.videos
|
|
.iter_mut()
|
|
.filter(|x| x.id == index)
|
|
{
|
|
video.end_time = updated_end_time;
|
|
debug!(title = video.title,
|
|
end_time = updated_end_time,
|
|
"updated video end_time");
|
|
}
|
|
self.as_mut().data_changed(
|
|
model_index,
|
|
model_index,
|
|
&vector_roles,
|
|
);
|
|
true
|
|
}
|
|
Err(e) => {
|
|
error!("Error connecting to db: {e}");
|
|
false
|
|
},
|
|
}
|
|
});
|
|
true
|
|
}
|
|
|
|
pub fn update_start_time(
|
|
mut self: Pin<&mut Self>,
|
|
index: i32,
|
|
updated_start_time: f32,
|
|
) -> bool {
|
|
let mut vector_roles = QVector_i32::default();
|
|
vector_roles
|
|
.append(self.as_ref().get_role(VideoRoles::StartTime));
|
|
let model_index =
|
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
|
|
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
rt.block_on(async {
|
|
let result = query!("UPDATE videos SET startTime = ? where id = ?", updated_start_time, index)
|
|
.execute(&mut self.as_mut().rust_mut().db)
|
|
.await;
|
|
match result {
|
|
Ok(_i) => {
|
|
for video in self
|
|
.as_mut()
|
|
.rust_mut()
|
|
.videos
|
|
.iter_mut()
|
|
.filter(|x| x.id == index)
|
|
{
|
|
video.start_time = updated_start_time;
|
|
debug!(title = video.title,
|
|
start_time = updated_start_time,
|
|
"updated video start_time");
|
|
}
|
|
self.as_mut().data_changed(
|
|
model_index,
|
|
model_index,
|
|
&vector_roles,
|
|
);
|
|
true
|
|
}
|
|
Err(e) => {
|
|
error!("Error connecting to db: {e}");
|
|
false
|
|
},
|
|
}
|
|
});
|
|
true
|
|
}
|
|
|
|
pub fn update_title(
|
|
mut self: Pin<&mut Self>,
|
|
index: i32,
|
|
updated_title: QString,
|
|
) -> bool {
|
|
let mut vector_roles = QVector_i32::default();
|
|
vector_roles
|
|
.append(self.as_ref().get_role(VideoRoles::Title));
|
|
let model_index =
|
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
|
|
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
rt.block_on(async {
|
|
let title = updated_title.to_string();
|
|
let result = query!("UPDATE videos SET title = ? where id = ?", title, index)
|
|
.execute(&mut self.as_mut().rust_mut().db)
|
|
.await;
|
|
match result {
|
|
Ok(_i) => {
|
|
for video in self
|
|
.as_mut()
|
|
.rust_mut()
|
|
.videos
|
|
.iter_mut()
|
|
.filter(|x| x.id == index)
|
|
{
|
|
video.title = title.clone();
|
|
debug!(title = video.title,
|
|
title = title,
|
|
"updated video title");
|
|
}
|
|
self.as_mut().data_changed(
|
|
model_index,
|
|
model_index,
|
|
&vector_roles,
|
|
);
|
|
true
|
|
}
|
|
Err(e) => {
|
|
error!("Error connecting to db: {e}");
|
|
false
|
|
},
|
|
}
|
|
});
|
|
true
|
|
}
|
|
|
|
pub fn update_path(
|
|
mut self: Pin<&mut Self>,
|
|
index: i32,
|
|
updated_path: QString,
|
|
) -> bool {
|
|
let mut vector_roles = QVector_i32::default();
|
|
vector_roles.append(self.as_ref().get_role(VideoRoles::Path));
|
|
let model_index =
|
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
|
|
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
rt.block_on(async {
|
|
let updated_path = updated_path.to_string();
|
|
let result = query!("UPDATE videos SET filePath = ? where id = ?", updated_path, index)
|
|
.execute(&mut self.as_mut().rust_mut().db)
|
|
.await;
|
|
match result {
|
|
Ok(_i) => {
|
|
for video in self
|
|
.as_mut()
|
|
.rust_mut()
|
|
.videos
|
|
.iter_mut()
|
|
.filter(|x| x.id == index)
|
|
{
|
|
video.path = updated_path.clone();
|
|
debug!(title = video.title,
|
|
path = updated_path,
|
|
"updated video path");
|
|
}
|
|
self.as_mut().data_changed(
|
|
model_index,
|
|
model_index,
|
|
&vector_roles,
|
|
);
|
|
true
|
|
}
|
|
Err(e) => {
|
|
error!("Error connecting to db: {e}");
|
|
false
|
|
},
|
|
}
|
|
});
|
|
true
|
|
}
|
|
|
|
fn search(mut self: Pin<&mut Self>, search_term: QString) {
|
|
let search_term = search_term.to_string().to_lowercase();
|
|
debug!(search_term);
|
|
let searched_videos: Vec<Video> = self
|
|
.inner_videos
|
|
.iter()
|
|
.filter(|video| {
|
|
video.title.to_lowercase().contains(&search_term)
|
|
})
|
|
.cloned()
|
|
.collect();
|
|
debug!(search = ?&searched_videos);
|
|
unsafe {
|
|
self.as_mut().begin_reset_model();
|
|
if search_term.is_empty() {
|
|
self.as_mut().rust_mut().videos =
|
|
self.as_mut().rust_mut().inner_videos.clone();
|
|
} else {
|
|
self.as_mut().rust_mut().videos = searched_videos;
|
|
}
|
|
self.as_mut().end_reset_model();
|
|
}
|
|
}
|
|
}
|
|
|
|
// QAbstractListModel implementation
|
|
impl video_model::VideoModel {
|
|
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
|
let role = VideoRoles { repr: role };
|
|
if let Some(video) = self.videos.get(index.row() as usize) {
|
|
return match role {
|
|
VideoRoles::Id => QVariant::from(&video.id),
|
|
VideoRoles::Title => {
|
|
QVariant::from(&QString::from(&video.title))
|
|
}
|
|
VideoRoles::Path => {
|
|
QVariant::from(&QString::from(&video.path))
|
|
}
|
|
VideoRoles::StartTime => {
|
|
QVariant::from(&video.start_time)
|
|
}
|
|
VideoRoles::EndTime => {
|
|
QVariant::from(&video.end_time)
|
|
}
|
|
VideoRoles::Looping => QVariant::from(&video.looping),
|
|
_ => QVariant::default(),
|
|
};
|
|
}
|
|
|
|
QVariant::default()
|
|
}
|
|
|
|
// Example of overriding a C++ virtual method and calling the base class implementation.
|
|
|
|
// pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
|
// self.base_can_fetch_more(parent)
|
|
// }
|
|
|
|
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
|
let mut roles = QHash_i32_QByteArray::default();
|
|
roles.insert(VideoRoles::Id.repr, QByteArray::from("id"));
|
|
roles.insert(
|
|
VideoRoles::Title.repr,
|
|
QByteArray::from("title"),
|
|
);
|
|
roles.insert(
|
|
VideoRoles::Path.repr,
|
|
QByteArray::from("filePath"),
|
|
);
|
|
roles.insert(
|
|
VideoRoles::StartTime.repr,
|
|
QByteArray::from("startTime"),
|
|
);
|
|
roles.insert(
|
|
VideoRoles::EndTime.repr,
|
|
QByteArray::from("endTime"),
|
|
);
|
|
roles.insert(
|
|
VideoRoles::Looping.repr,
|
|
QByteArray::from("loop"),
|
|
);
|
|
roles
|
|
}
|
|
|
|
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
|
let cnt = self.rust().videos.len() as i32;
|
|
// println!("row count is {cnt}");
|
|
cnt
|
|
}
|
|
}
|