fixing name clobbering in qobjects.

Apparently qobjects need unique names or else they will name clobber.
This commit is contained in:
Chris Cochrun 2024-06-26 09:12:11 -05:00
parent b4ce082891
commit 27acbdc866
11 changed files with 40 additions and 38 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 qobject { mod file_helper {
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 qobject::FileHelper { impl file_helper::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 qobject { mod image_model {
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::qobject::{ use self::image_model::{
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 qobject::ImageModel { impl image_model::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 qobject::ImageModel {
} }
// QAbstractListModel implementation // QAbstractListModel implementation
impl qobject::ImageModel { impl image_model::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

@ -1,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod qobject { mod presentation_model {
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 qobject {
} }
} }
use crate::presentation_model::qobject::QMap_QString_QVariant; use crate::presentation_model::presentation_model::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,7 +187,9 @@ use std::path::PathBuf;
use std::pin::Pin; use std::pin::Pin;
use tracing::debug; use tracing::debug;
use self::qobject::{PresRoles, QHash_i32_QByteArray, QVector_i32}; use self::presentation_model::{
PresRoles, QHash_i32_QByteArray, QVector_i32,
};
#[derive(Default, Clone, Debug)] #[derive(Default, Clone, Debug)]
pub struct Presentation { pub struct Presentation {
@ -205,7 +207,7 @@ pub struct PresentationModelRust {
presentations: Vec<Presentation>, presentations: Vec<Presentation>,
} }
impl qobject::PresentationModel { impl presentation_model::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();
@ -579,7 +581,7 @@ impl qobject::PresentationModel {
} }
// QAbstractListModel implementation // QAbstractListModel implementation
impl qobject::PresentationModel { impl presentation_model::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 qobject { mod service_item_model {
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 qobject {
} }
use crate::obs::Obs; use crate::obs::Obs;
use crate::service_item_model::qobject::QList_QString; use crate::service_item_model::service_item_model::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,
@ -306,12 +306,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::qobject::{ use self::service_item_model::{
QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32, QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32,
ServiceRoles, ServiceRoles,
}; };
use super::service_item_model::qobject::ServiceItemModel; use super::service_item_model::service_item_model::ServiceItemModel;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ServiceItem { pub struct ServiceItem {
@ -1382,7 +1382,7 @@ impl service_item_model::ServiceItemModel {
} }
// QAbstractListModel implementation // QAbstractListModel implementation
impl qobject::ServiceItemModel { impl service_item_model::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 qobject { mod settings {
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 qobject::Settings { impl settings::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 qobject { mod slide_model {
unsafe extern "C++" { unsafe extern "C++" {
include!(< QAbstractListModel >); include!(< QAbstractListModel >);
include!("cxx-qt-lib/qhash.h"); include!("cxx-qt-lib/qhash.h");
@ -216,7 +216,7 @@ mod qobject {
use crate::ffmpeg; use crate::ffmpeg;
use crate::obs::Obs; use crate::obs::Obs;
use crate::slide_model::qobject::QList_QString; use crate::slide_model::slide_model::QList_QString;
use cxx_qt::{CxxQtType, Threading}; use cxx_qt::{CxxQtType, Threading};
use cxx_qt_lib::{ use cxx_qt_lib::{
CaseSensitivity, QByteArray, QMap, QModelIndex, QString, QStringList, QVariant CaseSensitivity, QByteArray, QMap, QModelIndex, QString, QStringList, QVariant
@ -226,7 +226,7 @@ use std::thread;
use std::{path::PathBuf, pin::Pin}; use std::{path::PathBuf, pin::Pin};
use tracing::{debug, error}; use tracing::{debug, error};
use self::qobject::{ use self::slide_model::{
QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32, QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32,
SlideRoles, SlideRoles,
}; };
@ -311,7 +311,7 @@ impl Default for SlideModelRust {
} }
} }
impl qobject::SlideModel { impl slide_model::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,
@ -1236,7 +1236,7 @@ impl qobject::SlideModel {
} }
// QAbstractListModel implementation // QAbstractListModel implementation
impl qobject::SlideModel { impl slide_model::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 qobject { mod slide_object {
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::qobject::QMap_QString_QVariant; use self::slide_object::QMap_QString_QVariant;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct SlideObjectRust { pub struct SlideObjectRust {
@ -139,7 +139,7 @@ impl Default for SlideObjectRust {
} }
} }
impl qobject::SlideObject { impl slide_object::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,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
pub mod qobject { pub mod song_editor {
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 =

View file

@ -1,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
pub mod qobject { pub mod song_model {
unsafe extern "C++" { unsafe extern "C++" {
include!(< QAbstractListModel >); include!(< QAbstractListModel >);
include!("cxx-qt-lib/qhash.h"); include!("cxx-qt-lib/qhash.h");
@ -242,7 +242,7 @@ pub mod qobject {
use crate::models::*; use crate::models::*;
use crate::schema::songs::dsl::*; use crate::schema::songs::dsl::*;
use crate::songs::song_editor::qobject::QList_QString; use crate::songs::song_editor::song_editor::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,
@ -254,7 +254,7 @@ use std::pin::Pin;
use std::slice::Iter; use std::slice::Iter;
use tracing::{debug, debug_span, error, info, instrument}; use tracing::{debug, debug_span, error, info, instrument};
use self::qobject::{ use self::song_model::{
QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32, QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32,
SongRoles, SongRoles,
}; };
@ -296,7 +296,7 @@ pub struct SongModelRust {
inner_songs: Vec<Song>, inner_songs: Vec<Song>,
} }
impl qobject::SongModel { impl song_model::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();
@ -1098,7 +1098,7 @@ impl qobject::SongModel {
} }
// QAbstractListModel implementation // QAbstractListModel implementation
impl qobject::SongModel { impl song_model::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

@ -1,5 +1,5 @@
#[cxx_qt::bridge] #[cxx_qt::bridge]
mod qobject { mod video_model {
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::PathBuf; use std::path::PathBuf;
use std::pin::Pin; use std::pin::Pin;
use self::qobject::{ use self::video_model::{
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 qobject::VideoModel { impl video_model::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();
@ -610,7 +610,7 @@ impl qobject::VideoModel {
} }
// QAbstractListModel implementation // QAbstractListModel implementation
impl qobject::VideoModel { impl video_model::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 qobject { mod ytdl {
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 qobject::Ytdl { impl ytdl::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