rename all cxx_qt::bridge modules to qobject for clarity

This commit is contained in:
Chris Cochrun 2024-06-24 16:40:37 -05:00
parent f6964cf06a
commit aa0eeaaeed
13 changed files with 49 additions and 52 deletions

View file

@ -1,7 +1,7 @@
// The purpose of this file is to provide validation // The purpose of this file is to provide validation
// of whether or not a file exists // of whether or not a file exists
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod file_helper { mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!("cxx-qt-lib/qstring.h"); include!("cxx-qt-lib/qstring.h");
type QString = cxx_qt_lib::QString; type QString = cxx_qt_lib::QString;
@ -56,7 +56,7 @@ impl Default for FileHelperRust {
} }
} }
impl file_helper::FileHelper { impl qobject::FileHelper {
pub fn load(self: Pin<&mut Self>, file: QUrl) -> Vec<String> { pub fn load(self: Pin<&mut Self>, file: QUrl) -> Vec<String> {
println!("{file}"); println!("{file}");
vec!["hi".to_string()] vec!["hi".to_string()]

View file

@ -1,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod image_model { mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!(< QAbstractListModel >); include!(< QAbstractListModel >);
include!("cxx-qt-lib/qhash.h"); include!("cxx-qt-lib/qhash.h");
@ -162,7 +162,7 @@ use diesel::{delete, insert_into, prelude::*, update};
use std::path::PathBuf; use std::path::PathBuf;
use std::pin::Pin; use std::pin::Pin;
use self::image_model::{ use self::qobject::{
ImageRoles, QHash_i32_QByteArray, QMap_QString_QVariant, ImageRoles, QHash_i32_QByteArray, QMap_QString_QVariant,
QVector_i32, QVector_i32,
}; };
@ -182,7 +182,7 @@ pub struct ImageModelRust {
images: Vec<Image>, images: Vec<Image>,
} }
impl image_model::ImageModel { impl qobject::ImageModel {
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();
@ -450,7 +450,7 @@ impl image_model::ImageModel {
} }
// QAbstractListModel implementation // QAbstractListModel implementation
impl image_model::ImageModel { impl qobject::ImageModel {
fn data(&self, index: &QModelIndex, role: i32) -> QVariant { fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
let role = ImageRoles { repr: role }; let role = ImageRoles { repr: role };
if let Some(image) = self.images.get(index.row() as usize) { if let Some(image) = self.images.get(index.row() as usize) {

View file

@ -8,7 +8,7 @@ use std::time::Duration;
use std::{error::Error, pin::Pin}; use std::{error::Error, pin::Pin};
use tracing::{debug, error}; use tracing::{debug, error};
use crate::obs::obs_model::QList_QString; use crate::obs::qobject::QList_QString;
pub struct Obs { pub struct Obs {
scenes: Scenes, scenes: Scenes,
@ -123,7 +123,7 @@ fn make_client() -> Client {
} }
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod obs_model { mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!("cxx-qt-lib/qstring.h"); include!("cxx-qt-lib/qstring.h");
type QString = cxx_qt_lib::QString; type QString = cxx_qt_lib::QString;
@ -160,7 +160,7 @@ pub struct ObsModelRust {
current_program_scene: QString, current_program_scene: QString,
} }
impl obs_model::ObsModel { impl qobject::ObsModel {
pub fn update_scenes(mut self: Pin<&mut Self>) -> QStringList { pub fn update_scenes(mut self: Pin<&mut Self>) -> QStringList {
debug!("updating scenes"); debug!("updating scenes");
let mut scenes_list = QList_QString::default(); let mut scenes_list = QList_QString::default();

View file

@ -1,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod presentation_model { mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!(< QAbstractListModel >); include!(< QAbstractListModel >);
include!("cxx-qt-lib/qhash.h"); include!("cxx-qt-lib/qhash.h");
@ -175,7 +175,7 @@ mod presentation_model {
} }
} }
use crate::presentation_model::presentation_model::QMap_QString_QVariant; use crate::presentation_model::qobject::QMap_QString_QVariant;
use crate::reveal_js; use crate::reveal_js;
use crate::schema::presentations::dsl::*; use crate::schema::presentations::dsl::*;
use cxx_qt::CxxQtType; use cxx_qt::CxxQtType;
@ -187,9 +187,7 @@ use std::path::PathBuf;
use std::pin::Pin; use std::pin::Pin;
use tracing::debug; use tracing::debug;
use self::presentation_model::{ use self::qobject::{PresRoles, QHash_i32_QByteArray, QVector_i32};
PresRoles, QHash_i32_QByteArray, QVector_i32,
};
#[derive(Default, Clone, Debug)] #[derive(Default, Clone, Debug)]
pub struct Presentation { pub struct Presentation {
@ -207,7 +205,7 @@ pub struct PresentationModelRust {
presentations: Vec<Presentation>, presentations: Vec<Presentation>,
} }
impl presentation_model::PresentationModel { impl qobject::PresentationModel {
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();
@ -581,7 +579,7 @@ impl presentation_model::PresentationModel {
} }
// QAbstractListModel implementation // QAbstractListModel implementation
impl presentation_model::PresentationModel { impl qobject::PresentationModel {
fn data(&self, index: &QModelIndex, role: i32) -> QVariant { fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
let role = PresRoles { repr: role }; let role = PresRoles { repr: role };
if let Some(presentation) = if let Some(presentation) =

View file

@ -1,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod service_item_model { mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!(< QAbstractListModel >); include!(< QAbstractListModel >);
include!("cxx-qt-lib/qhash.h"); include!("cxx-qt-lib/qhash.h");
@ -291,7 +291,7 @@ mod service_item_model {
} }
use crate::obs::Obs; use crate::obs::Obs;
use crate::service_item_model::service_item_model::QList_QString; use crate::service_item_model::qobject::QList_QString;
use cxx_qt::{CxxQtType, Threading}; use cxx_qt::{CxxQtType, Threading};
use cxx_qt_lib::{ use cxx_qt_lib::{
QByteArray, QModelIndex, QString, QStringList, QUrl, QVariant, QByteArray, QModelIndex, QString, QStringList, QUrl, QVariant,
@ -307,12 +307,12 @@ use std::{fs, println};
use tar::{Archive, Builder}; use tar::{Archive, Builder};
use tracing::{debug, error}; use tracing::{debug, error};
use zstd::{Decoder, Encoder}; use zstd::{Decoder, Encoder};
use self::service_item_model::{ use self::qobject::{
QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32, QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32,
ServiceRoles, ServiceRoles,
}; };
use super::service_item_model::service_item_model::ServiceItemModel; use super::service_item_model::qobject::ServiceItemModel;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ServiceItem { pub struct ServiceItem {
@ -396,7 +396,7 @@ impl Default for ServiceItemModelRust {
} }
} }
impl service_item_model::ServiceItemModel { impl qobject::ServiceItemModel {
pub fn setup(mut self: Pin<&mut Self>) { pub fn setup(mut self: Pin<&mut Self>) {
todo!() todo!()
} }
@ -1378,7 +1378,7 @@ impl service_item_model::ServiceItemModel {
} }
// QAbstractListModel implementation // QAbstractListModel implementation
impl service_item_model::ServiceItemModel { impl qobject::ServiceItemModel {
fn data(&self, index: &QModelIndex, role: i32) -> QVariant { fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
let role = ServiceRoles { repr: role }; let role = ServiceRoles { repr: role };
if let Some(service_item) = if let Some(service_item) =

View file

@ -1,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod settings { mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!("cxx-qt-lib/qstring.h"); include!("cxx-qt-lib/qstring.h");
type QString = cxx_qt_lib::QString; type QString = cxx_qt_lib::QString;
@ -60,7 +60,7 @@ impl Default for SettingsRust {
} }
} }
impl settings::Settings { impl qobject::Settings {
pub fn setup(mut self: Pin<&mut Self>) { pub fn setup(mut self: Pin<&mut Self>) {
let home = dirs::config_dir(); let home = dirs::config_dir();
println!("{:?}", home); println!("{:?}", home);

View file

@ -1,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod slide_model { mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!(< QAbstractListModel >); include!(< QAbstractListModel >);
include!("cxx-qt-lib/qhash.h"); include!("cxx-qt-lib/qhash.h");
@ -213,7 +213,7 @@ mod slide_model {
use crate::ffmpeg; use crate::ffmpeg;
use crate::obs::Obs; use crate::obs::Obs;
use crate::slide_model::slide_model::QList_QString; use crate::slide_model::qobject::QList_QString;
use cxx_qt::{CxxQtType, Threading}; use cxx_qt::{CxxQtType, Threading};
use cxx_qt_lib::{ use cxx_qt_lib::{
CaseSensitivity, QByteArray, QModelIndex, QString, QStringList, CaseSensitivity, QByteArray, QModelIndex, QString, QStringList,
@ -223,7 +223,7 @@ use std::thread;
use std::{path::PathBuf, pin::Pin}; use std::{path::PathBuf, pin::Pin};
use tracing::{debug, debug_span, error, info, instrument}; use tracing::{debug, debug_span, error, info, instrument};
use self::slide_model::{ use self::qobject::{
QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32, QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32,
SlideRoles, SlideRoles,
}; };
@ -308,7 +308,7 @@ impl Default for SlideModelRust {
} }
} }
impl slide_model::SlideModel { impl qobject::SlideModel {
pub fn add_video_thumbnail( pub fn add_video_thumbnail(
mut self: Pin<&mut Self>, mut self: Pin<&mut Self>,
index: i32, index: i32,
@ -1280,7 +1280,7 @@ impl slide_model::SlideModel {
} }
// QAbstractListModel implementation // QAbstractListModel implementation
impl slide_model::SlideModel { impl qobject::SlideModel {
pub fn data(&self, index: &QModelIndex, role: i32) -> QVariant { pub fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
let role = SlideRoles { repr: role }; let role = SlideRoles { repr: role };
if let Some(slide) = self.slides.get(index.row() as usize) { if let Some(slide) = self.slides.get(index.row() as usize) {

View file

@ -1,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod slide_object { mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!("cxx-qt-lib/qstring.h"); include!("cxx-qt-lib/qstring.h");
type QString = cxx_qt_lib::QString; type QString = cxx_qt_lib::QString;
@ -90,7 +90,7 @@ use cxx_qt::CxxQtType;
use cxx_qt_lib::{CaseSensitivity, QString, QVariant}; use cxx_qt_lib::{CaseSensitivity, QString, QVariant};
use tracing::debug; use tracing::debug;
use self::slide_object::QMap_QString_QVariant; use self::qobject::QMap_QString_QVariant;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct SlideObjectRust { pub struct SlideObjectRust {
@ -139,7 +139,7 @@ impl Default for SlideObjectRust {
} }
} }
impl slide_object::SlideObject { impl qobject::SlideObject {
pub fn change_slide( pub fn change_slide(
mut self: Pin<&mut Self>, mut self: Pin<&mut Self>,
item: QMap_QString_QVariant, item: QMap_QString_QVariant,

View file

@ -1,7 +1,5 @@
// use crate::songs::song_model::song_model::SongModel;
#[cxx_qt::bridge] #[cxx_qt::bridge]
pub mod song_editor { pub mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!("cxx-qt-lib/qmap.h"); include!("cxx-qt-lib/qmap.h");
type QMap_QString_QVariant = type QMap_QString_QVariant =
@ -16,8 +14,8 @@ pub mod song_editor {
type QStringList = cxx_qt_lib::QStringList; type QStringList = cxx_qt_lib::QStringList;
include!("cxx-qt-lib/qlist.h"); include!("cxx-qt-lib/qlist.h");
type QList_QString = cxx_qt_lib::QList<QString>; type QList_QString = cxx_qt_lib::QList<QString>;
// #[cxx_name = "SongModel"]
// type SongModel = crate::songs::song_model::qobject::SongModel; // type SongModel = super::song_model::qobject::SongModel;
} }
unsafe extern "RustQt" { unsafe extern "RustQt" {
@ -48,6 +46,7 @@ pub mod song_editor {
} }
} }
// use crate::songs::song_model::qobject::SongModel;
use cxx_qt_lib::QString; use cxx_qt_lib::QString;
use std::{path::PathBuf, pin::Pin}; use std::{path::PathBuf, pin::Pin};
use tracing::{debug, debug_span, error, info, instrument}; use tracing::{debug, debug_span, error, info, instrument};
@ -95,7 +94,7 @@ impl Default for SongEditorRust {
} }
} }
impl song_editor::SongEditor { impl qobject::SongEditor {
fn idk(mut self: Pin<&mut Self>) { fn idk(mut self: Pin<&mut Self>) {
// if let Some(model) = unsafe { self.song_model().as_mut() } { // if let Some(model) = unsafe { self.song_model().as_mut() } {
// let pinned_model = unsafe { Pin::new_unchecked(model) }; // let pinned_model = unsafe { Pin::new_unchecked(model) };

View file

@ -1,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
pub mod song_model { pub mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!(< QAbstractListModel >); include!(< QAbstractListModel >);
include!("cxx-qt-lib/qhash.h"); include!("cxx-qt-lib/qhash.h");
@ -240,7 +240,7 @@ pub mod song_model {
use crate::models::*; use crate::models::*;
use crate::schema::songs::dsl::*; use crate::schema::songs::dsl::*;
use crate::songs::song_editor::song_editor::QList_QString; use crate::songs::song_editor::qobject::QList_QString;
use cxx_qt::CxxQtType; use cxx_qt::CxxQtType;
use cxx_qt_lib::{ use cxx_qt_lib::{
QByteArray, QModelIndex, QString, QStringList, QVariant, QByteArray, QModelIndex, QString, QStringList, QVariant,
@ -251,7 +251,7 @@ use std::collections::HashMap;
use std::pin::Pin; use std::pin::Pin;
use tracing::{debug, debug_span, error, info, instrument}; use tracing::{debug, debug_span, error, info, instrument};
use self::song_model::{ use self::qobject::{
QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32, QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32,
SongRoles, SongRoles,
}; };
@ -292,7 +292,7 @@ pub struct SongModelRust {
songs: Vec<Song>, songs: Vec<Song>,
} }
impl song_model::SongModel { impl qobject::SongModel {
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();
@ -1074,7 +1074,7 @@ impl song_model::SongModel {
} }
// QAbstractListModel implementation // QAbstractListModel implementation
impl song_model::SongModel { impl qobject::SongModel {
fn data(&self, index: &QModelIndex, role: i32) -> QVariant { fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
let role = SongRoles { repr: role }; let role = SongRoles { repr: role };
if let Some(song) = self.songs.get(index.row() as usize) { if let Some(song) = self.songs.get(index.row() as usize) {

View file

@ -8,7 +8,7 @@ use tracing_subscriber::{
EnvFilter, EnvFilter,
}; };
use self::utilities::{QString, QUrl}; use self::qobject::{QString, QUrl};
mod db { mod db {
use diesel::{Connection, SqliteConnection}; use diesel::{Connection, SqliteConnection};
@ -52,7 +52,7 @@ mod db {
} }
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod utilities { mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!("cxx-qt-lib/qstring.h"); include!("cxx-qt-lib/qstring.h");
type QString = cxx_qt_lib::QString; type QString = cxx_qt_lib::QString;
@ -92,7 +92,7 @@ impl Default for UtilsRust {
} }
} }
impl utilities::Utils { impl qobject::Utils {
pub fn setup(self: Pin<&mut Self>) { pub fn setup(self: Pin<&mut Self>) {
crate::utils::setup(); crate::utils::setup();
} }

View file

@ -1,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod video_model { mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!(< QAbstractListModel >); include!(< QAbstractListModel >);
include!("cxx-qt-lib/qhash.h"); include!("cxx-qt-lib/qhash.h");
@ -185,7 +185,7 @@ use diesel::{delete, insert_into, prelude::*, update};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::pin::Pin; use std::pin::Pin;
use self::video_model::{ use self::qobject::{
QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32, QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32,
VideoRoles, VideoRoles,
}; };
@ -207,7 +207,7 @@ pub struct VideoModelRust {
videos: Vec<self::Video>, videos: Vec<self::Video>,
} }
impl video_model::VideoModel { impl qobject::VideoModel {
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();
@ -609,7 +609,7 @@ impl video_model::VideoModel {
} }
// QAbstractListModel implementation // QAbstractListModel implementation
impl video_model::VideoModel { impl qobject::VideoModel {
fn data(&self, index: &QModelIndex, role: i32) -> QVariant { fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
let role = VideoRoles { repr: role }; let role = VideoRoles { repr: role };
if let Some(video) = self.videos.get(index.row() as usize) { if let Some(video) = self.videos.get(index.row() as usize) {

View file

@ -1,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod ytdl { mod qobject {
unsafe extern "C++" { unsafe extern "C++" {
include!("cxx-qt-lib/qurl.h"); include!("cxx-qt-lib/qurl.h");
type QUrl = cxx_qt_lib::QUrl; type QUrl = cxx_qt_lib::QUrl;
@ -40,7 +40,7 @@ pub struct YtdlRust {
file: QUrl, file: QUrl,
} }
impl ytdl::Ytdl { impl qobject::Ytdl {
pub fn get_video(mut self: Pin<&mut Self>, url: QUrl) -> bool { pub fn get_video(mut self: Pin<&mut Self>, url: QUrl) -> bool {
if !url.is_valid() { if !url.is_valid() {
false false