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