diff --git a/crates/cxx-qt-lib/include/core/qmodelindex.h b/crates/cxx-qt-lib/include/core/qmodelindex.h index 11df7f320..f49b2bd3f 100644 --- a/crates/cxx-qt-lib/include/core/qmodelindex.h +++ b/crates/cxx-qt-lib/include/core/qmodelindex.h @@ -9,12 +9,3 @@ #include #include - -namespace rust { -namespace cxxqtlib1 { - -::std::size_t -qmodelindexInternalId(const QModelIndex& index); - -} -} \ No newline at end of file diff --git a/crates/cxx-qt-lib/src/core/qmodelindex.cpp b/crates/cxx-qt-lib/src/core/qmodelindex.cpp index 75aeb604f..9664d4155 100644 --- a/crates/cxx-qt-lib/src/core/qmodelindex.cpp +++ b/crates/cxx-qt-lib/src/core/qmodelindex.cpp @@ -19,16 +19,3 @@ assert_alignment_and_size(QModelIndex, { }); static_assert(::std::is_trivially_copyable::value); - -namespace rust { -namespace cxxqtlib1 { - -::std::size_t -qmodelindexInternalId(const QModelIndex& index) -{ - // TODO: need to add support for quintptr - return static_cast<::std::size_t>(index.internalId()); -} - -} -} diff --git a/crates/cxx-qt-lib/src/core/qmodelindex.rs b/crates/cxx-qt-lib/src/core/qmodelindex.rs index de029dabc..d6c291020 100644 --- a/crates/cxx-qt-lib/src/core/qmodelindex.rs +++ b/crates/cxx-qt-lib/src/core/qmodelindex.rs @@ -14,6 +14,7 @@ mod ffi { type QModelIndex = super::QModelIndex; type QString = crate::QString; + type quintptr = crate::quintptr; /// Returns the column this model index refers to. fn column(self: &QModelIndex) -> i32; @@ -35,6 +36,9 @@ mod ffi { #[rust_name = "sibling_at_row"] fn siblingAtRow(self: &QModelIndex, row: i32) -> QModelIndex; + /// Returns a `quintptr` used by the model to associate the index with the internal data structure. + #[rust_name = "internal_id"] + fn internalId(self: &QModelIndex) -> quintptr; /// Returns a `*mut c_void` pointer used by the model to associate the index with the internal data structure. #[rust_name = "internal_pointer_mut"] fn internalPointer(self: &QModelIndex) -> *mut c_void; @@ -54,10 +58,6 @@ mod ffi { #[doc(hidden)] #[rust_name = "qmodelindex_to_qstring"] fn toQString(value: &QModelIndex) -> QString; - - #[doc(hidden)] - #[rust_name = "qmodelindex_internal_id"] - fn qmodelindexInternalId(index: &QModelIndex) -> usize; } } @@ -71,15 +71,6 @@ pub struct QModelIndex { _m: MaybeUninit, } -impl QModelIndex { - /// Returns a `usize` used by the model to associate the index with the internal data structure. - // - // TODO: need to add support for quintptr - pub fn internal_id(&self) -> usize { - ffi::qmodelindex_internal_id(self) - } -} - impl Default for QModelIndex { /// Creates a new empty model index. This type of model index is used to indicate that the position in the model is invalid. fn default() -> Self { diff --git a/tests/qt_types_standalone/rust/src/qmodelindex.rs b/tests/qt_types_standalone/rust/src/qmodelindex.rs index 8ed12131c..bb23b4bc2 100644 --- a/tests/qt_types_standalone/rust/src/qmodelindex.rs +++ b/tests/qt_types_standalone/rust/src/qmodelindex.rs @@ -10,6 +10,9 @@ mod qmodelindex_cxx { unsafe extern "C++" { include!("cxx-qt-lib/qmodelindex.h"); type QModelIndex = cxx_qt_lib::QModelIndex; + + include!("cxx-qt-lib/qtypes.h"); + type QUIntPtr = cxx_qt_lib::QUIntPtr; } #[namespace = "rust::cxxqtlib1"] @@ -23,7 +26,7 @@ mod qmodelindex_cxx { fn read_qmodelindex(i: &QModelIndex) -> bool; fn clone_qmodelindex(i: &QModelIndex) -> QModelIndex; fn internal_pointer_qmodelindex(i: &QModelIndex) -> *mut c_void; - fn internal_id_qmodelindex(i: &QModelIndex) -> usize; + fn internal_id_qmodelindex(i: &QModelIndex) -> QUIntPtr; } } @@ -43,6 +46,6 @@ fn internal_pointer_qmodelindex(i: &QModelIndex) -> *mut qmodelindex_cxx::c_void i.internal_pointer_mut() } -fn internal_id_qmodelindex(i: &QModelIndex) -> usize { +fn internal_id_qmodelindex(i: &QModelIndex) -> cxx_qt_lib::QUIntPtr { i.internal_id() }