cxx_qt_lib/core/
qmodelindex.rs1use cxx::{type_id, ExternType};
6use std::fmt;
7use std::mem::MaybeUninit;
8
9#[cxx::bridge]
10mod ffi {
11 unsafe extern "C++" {
12 include!("cxx-qt-lib/qmodelindex.h");
13 include!("cxx-qt-lib/qstring.h");
14
15 type QModelIndex = super::QModelIndex;
16 type QString = crate::QString;
17
18 fn column(self: &QModelIndex) -> i32;
20 #[rust_name = "is_valid"]
24 fn isValid(self: &QModelIndex) -> bool;
25 fn parent(self: &QModelIndex) -> QModelIndex;
27 fn row(self: &QModelIndex) -> i32;
29 fn sibling(self: &QModelIndex, row: i32, column: i32) -> QModelIndex;
31 #[rust_name = "sibling_at_column"]
33 fn siblingAtColumn(self: &QModelIndex, column: i32) -> QModelIndex;
34 #[rust_name = "sibling_at_row"]
36 fn siblingAtRow(self: &QModelIndex, row: i32) -> QModelIndex;
37
38 #[rust_name = "internal_pointer_mut"]
40 fn internalPointer(self: &QModelIndex) -> *mut c_void;
41 }
42
43 #[namespace = "rust::cxxqtlib1"]
44 unsafe extern "C++" {
45 include!("cxx-qt-lib/common.h");
46 type c_void = crate::c_void;
47
48 #[doc(hidden)]
49 #[rust_name = "qmodelindex_init_default"]
50 fn construct() -> QModelIndex;
51 #[doc(hidden)]
52 #[rust_name = "qmodelindex_eq"]
53 fn operatorEq(a: &QModelIndex, b: &QModelIndex) -> bool;
54 #[doc(hidden)]
55 #[rust_name = "qmodelindex_to_qstring"]
56 fn toQString(value: &QModelIndex) -> QString;
57
58 #[doc(hidden)]
59 #[rust_name = "qmodelindex_internal_id"]
60 fn qmodelindexInternalId(index: &QModelIndex) -> usize;
61 }
62}
63
64#[derive(Clone)]
66#[repr(C)]
67pub struct QModelIndex {
68 _r: MaybeUninit<i32>,
69 _c: MaybeUninit<i32>,
70 _i: MaybeUninit<usize>,
71 _m: MaybeUninit<usize>,
72}
73
74impl QModelIndex {
75 pub fn internal_id(&self) -> usize {
79 ffi::qmodelindex_internal_id(self)
80 }
81}
82
83impl Default for QModelIndex {
84 fn default() -> Self {
86 ffi::qmodelindex_init_default()
87 }
88}
89
90impl std::cmp::PartialEq for QModelIndex {
91 fn eq(&self, other: &Self) -> bool {
92 ffi::qmodelindex_eq(self, other)
93 }
94}
95
96impl std::cmp::Eq for QModelIndex {}
97
98impl fmt::Display for QModelIndex {
99 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
100 write!(f, "{}", ffi::qmodelindex_to_qstring(self))
101 }
102}
103
104impl fmt::Debug for QModelIndex {
105 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
106 write!(f, "{self}")
107 }
108}
109
110unsafe impl ExternType for QModelIndex {
114 type Id = type_id!("QModelIndex");
115 type Kind = cxx::kind::Trivial;
116}