qtbridge_interfaces/qtable_model/
proxy_rust.rs

1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only
3
4use super::proxy_cpp_bridge::{QTableModelProxyCpp, ffi};
5use crate::{RustObjAccess, call_rust_trait_impl, call_cpp_impl};
6use qtbridge_runtime::qrustproxy::{QRustProxy, ConstructionMode};
7use qtbridge_runtime::{DispatchMetaCall, QObjectHolder};
8use qtbridge_runtime::QModelItem;
9use qtbridge_type_lib::{QByteArray, QHash, QMetaObject, QMetaType, QModelIndex, QVariant};
10use std::cell::RefCell;
11use std::rc::Rc;
12
13#[doc(hidden)]
14pub trait QTableModelAdapter: DispatchMetaCall {
15    fn index(&self, row: i32, column: i32, parent: &QModelIndex) -> QModelIndex;
16    fn parent(&self, child: &QModelIndex) -> QModelIndex;
17    fn row_count(&self, parent: &QModelIndex) -> i32;
18    fn column_count(&self, parent: &QModelIndex) -> i32;
19    fn data(&self, index: &QModelIndex, role: i32) -> QVariant;
20    fn role_names(&self) -> QHash<i32, QByteArray>;
21    fn set_data(&mut self, index: &QModelIndex, value: &QVariant, role: i32) -> bool;
22    fn remove_columns(&mut self, first: i32, count: i32, parent: &QModelIndex) -> bool;
23    fn remove_rows(&mut self, first: i32, count: i32, parent: &QModelIndex) -> bool;
24    fn sibling(&self, row: i32, column: i32, idx: &QModelIndex) -> QModelIndex;
25}
26
27impl<T> QTableModelAdapter for T
28where
29    T: QTableModel + QObjectHolder<ProxyRust = QTableModelProxyRust> {
30    fn index(&self, row: i32, column: i32, _: &QModelIndex) -> QModelIndex {
31        let proxy = <Self as QObjectHolder>::get_rust_proxy(self);
32        proxy.base_create_index(row, column, 0)
33    }
34    fn parent(&self, _: &QModelIndex) -> QModelIndex {
35        QModelIndex::default()
36    }
37    fn row_count(&self, _: &QModelIndex) -> i32 {
38        self.row_count() as i32
39    }
40    fn column_count(&self, _: &QModelIndex) -> i32 {
41        <Self as QTableModel>::column_count(&self) as i32
42    }
43    fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
44        let Some(item) = self.get((index.row() as usize, index.column() as usize))
45        else {
46            return QVariant::default();
47        };
48        item.get_role(role)
49    }
50    fn role_names(&self) -> QHash<i32, QByteArray> {
51        let names = T::Item::role_names();
52        let mut result = QHash::default();
53        names.iter()
54            .for_each(|(k, v)| result.insert(k, &QByteArray::from(v)));
55        result
56    }
57    fn set_data(&mut self, index: &QModelIndex, value: &QVariant, role: i32) -> bool {
58        if !index.is_valid() {
59            return false;
60        }
61        let Some(mut item) = self.get((index.row() as usize, index.column() as usize))
62            .cloned()
63        else {
64            return false;
65        };
66        let updated = item.set_role(role, value);
67        if updated {
68            self.set_unnotified((index.row() as usize, index.column() as usize), item);
69            self.get_rust_proxy_mut().base_data_changed(index, index);
70        }
71        updated
72    }
73    fn remove_columns(&mut self, first: i32, count: i32, parent: &QModelIndex) -> bool {
74        let first = first as usize;
75        let last = first + count as usize;
76        if last > self.column_count() {
77            return false;
78        }
79        self.get_rust_proxy_mut().base_begin_remove_columns(parent, first as i32, (last - 1) as i32);
80        for index in (first..last).rev() {
81            self.remove_row_unnotified(index);
82        }
83        self.get_rust_proxy_mut().base_end_remove_columns();
84        true
85    }
86    fn remove_rows(&mut self, first: i32, count: i32, parent: &QModelIndex) -> bool {
87        let first = first as usize;
88        let last = first + count as usize;
89        if last > self.row_count() {
90            return false;
91        }
92        self.get_rust_proxy_mut().base_begin_remove_rows(parent, first as i32, (last - 1) as i32);
93        for index in (first..last).rev() {
94            self.remove_row_unnotified(index);
95        }
96        self.get_rust_proxy_mut().base_end_remove_rows();
97        true
98    }
99    fn sibling(&self, row: i32, column: i32, idx: &QModelIndex) -> QModelIndex {
100        let proxy = self.get_rust_proxy();
101        proxy.base_sibling(row, column, idx)
102    }
103}
104
105
106/// A trait representing a table-based Qt model.
107///
108/// [`QTableModel`] provides an interface for table-like data structures
109/// that are exposed to Qt through the Model-View concept.
110/// <https://doc.qt.io/qt-6/qtquick-modelviewsdata-modelview.html>.
111///
112/// This trait requires the `qobject` macro to set up the correct Qt proxy.
113/// The macro will further generate functionality in the form of the
114/// [`QTableModelBase`] trait that supplements the [`QTableModel`] functionality.
115///
116/// ## Design
117///
118/// - The model owns items of associated type `Item` that has to implement
119///   the [`QModelItem`] trait. Roles are derived from the [`QModelItem`]
120///   implementation.
121/// - Mutation methods are provided in an **unnotified** form, meaning
122///   they modify the underlying data without emitting Qt model signals.
123/// - These methods are used by the automatically implemented [`QTableModelBase`]
124///   trait to create methods that collaborate the UI about changes in collections.
125///
126/// As a minimum you have to implement the methods [`QTableModel::row_count`],
127/// [`QTableModel::column_count`] and [`QTableModel::get`] to create a readable
128/// list model. Further methods can be implemented to make the model fully mutable.
129///
130/// Methods that do not return an [`Option`] or a boolean value must succeed
131/// and perform exactly the operation described in the documentation to avoid
132/// invalidating the synchronization between any views and the underlying data.
133/// No additional structural changes may occur outside the provided functions.
134///
135/// **Note, that default implementations may `panic!`** if the corresponding method is
136/// not overridden. It is your responsibility to make sure that these functions are
137/// not called from QML.
138///
139/// ## Example
140///
141/// ``` ignore
142/// use qtbridge::qobject;
143/// #[qobject(Base = QTableModel)]
144/// mod backend {
145///     use qtbridge::{QTableModel, QTableModelBase};
146///
147///     #[derive(Default)]
148///     pub struct Backend {
149///         string_data: Vec<Vec<String>>,
150///     }
151///     impl QTableModel for Backend {
152///         type Item = String;
153///
154///         fn len(&self) -> usize {
155///             self.string_data.len()
156///         }
157///         fn column_count(&self) -> usize {
158///             self.string_data[0].len
159///         }
160///         fn get(&self, index: (usize, usize)) -> Option<&Self::Item> {
161///             self.string_list.get(index.0)?.get(index.1)
162///         }
163///     }
164/// }
165///
166/// ```
167///
168/// The table model can be used in QML views as follows
169/// ``` qml, ignore
170/// TableView {
171///     model: backend
172///     delegate: Text {
173///         required property string value
174///         text: value
175///     }
176/// }
177/// ```
178pub trait QTableModel {
179    /// The item type stored in the model.
180    ///
181    /// Items must:
182    /// - Implement [`QModelItem`] to integrate with Qt
183    /// - Be [`Default`] for creating new items
184    /// - Be [`Clone`] for safe data access and copying
185    type Item: QModelItem + Default + Clone;
186
187    /// Returns the number of rows in the table.
188    fn row_count(&self) -> usize;
189
190    /// Returns the number of columns in the table.
191    fn column_count(&self) -> usize;
192
193    /// Returns a reference to the item at `index`, or `None` if the index
194    /// is out of bounds.
195    fn get(&self, index: (usize, usize)) -> Option<&Self::Item>;
196
197    /// Sets the item at `index`. Reimplement this function but call
198    /// [`QTableModelBase::set`] to notify Qt about the modification.
199    ///
200    /// Returns `true` if the value was successfully set, or `false` if the
201    /// operation failed (e.g., index out of bounds or value fails
202    /// validation by the business logic).
203    ///
204    /// The default implementation does nothing and returns `false`.
205    fn set_unnotified(&mut self, _index: (usize, usize), _value: Self::Item) -> bool {
206        false
207    }
208
209    /// Appends a row of items to the end of the model. Reimplement this
210    /// function but call [`QTableModelBase::push_row`] to notify Qt about the
211    /// modification.
212    ///
213    /// The function has to accept the value. Validation has to be
214    /// done before this function is called.
215    ///
216    /// The default implementation falls back to [`QTableModel::insert_row_unnotified`],
217    /// which in turn panics by default.
218    fn push_row_unnotified(&mut self, values: &[Self::Item]) {
219        self.insert_row_unnotified(self.row_count(), values);
220    }
221
222    /// Appends a column of items to the end of the model. Reimplement this
223    /// function but call [`QTableModelBase::push_column`] to notify Qt about the
224    /// modification.
225    ///
226    /// The function has to accept the value. Validation has to be
227    /// done before this function is called.
228    ///
229    /// The default implementation falls back to [`QTableModel::insert_column_unnotified`],
230    /// which in turn panics by default.
231    fn push_column_unnotified(&mut self, values: &[Self::Item]) {
232        self.insert_column_unnotified(self.column_count(), values);
233    }
234
235    /// Inserts a row with `value` at `index`. Reimplement this function but
236    /// call [`QTableModelBase::insert_row`] to notify Qt about the
237    /// modification.
238    ///
239    /// The function has to accept the value. Validation has to be
240    /// done before this function is called.
241    ///
242    /// Panics by default. Implementors must override this method to support
243    /// insertion.
244    fn insert_row_unnotified(&mut self, _index: usize, _value: &[Self::Item]) {
245        panic!("In order to use insert, implement insert_unnotified")
246    }
247
248    /// Inserts a column with `values` at `index`. Reimplement this function but
249    /// call [`QTableModelBase::insert_column`] to notify Qt about the
250    /// modification.
251    ///
252    /// The function has to accept the value. Validation has to be
253    /// done before this function is called.
254    ///
255    /// Panics by default. Implementors must override this method to support
256    /// insertion.
257    fn insert_column_unnotified(&mut self, _index: usize, _value: &[Self::Item]) {
258        panic!("In order to use insert, implement insert_unnotified")
259    }
260
261    /// Removes and returns the last row in the model. Reimplement this
262    /// function but call [`QTableModelBase::pop_row`] to notify Qt
263    /// about the modification.
264    ///
265    /// Returns `None` if the model is empty. If the model is not empty,
266    /// the function has to guarantee the success of the operation.
267    ///
268    /// The default implementation falls back to [`QTableModel::remove_row_unnotified`],
269    /// which in turn panics by default.
270    fn pop_row_unnotified(&mut self) -> Option<Vec<Self::Item>> {
271        (self.row_count() > 0)
272            .then(|| self.remove_row_unnotified(self.row_count() - 1))
273    }
274
275    /// Removes and returns the last column in the model. Reimplement this
276    /// function but call [`QTableModelBase::pop_column`] to notify Qt
277    /// about the modification.
278    ///
279    /// Returns `None` if the model is empty. If the model is not empty,
280    /// the function has to guarantee the success of the operation.
281    ///
282    /// The default implementation falls back to [`QTableModel::remove_column_unnotified`],
283    /// which in turn panics by default.
284    fn pop_column_unnotified(&mut self) -> Option<Vec<Self::Item>> {
285        (self.column_count() > 0)
286            .then(|| self.remove_column_unnotified(self.column_count() - 1))
287    }
288
289    /// Removes and returns the item at `index`. Reimplement this
290    /// function but call [`QTableModelBase::remove_row`] to notify Qt
291    /// about the modification.
292    ///
293    /// The index must be valid and the model has to guarantee the success of
294    /// the operation.
295    ///
296    /// Panics by default. Implementors must override this method to support
297    /// removal.
298    fn remove_row_unnotified(&mut self, _index: usize) -> Vec<Self::Item> {
299        panic!("In order to use remove, implement remove_unnotified")
300    }
301
302    /// Removes and returns the column at `index`. Reimplement this
303    /// function but call [`QTableModelBase::remove_column`] to notify Qt
304    /// about the modification.
305    ///
306    /// The index must be valid and the model has to guarantee the success of
307    /// the operation.
308    ///
309    /// Panics by default. Implementors must override this method to support
310    /// removal.
311    fn remove_column_unnotified(&mut self, _index: usize) -> Vec<Self::Item> {
312        panic!("In order to use remove, implement remove_unnotified")
313    }
314
315    /// Resets the model’s internal storage. Reimplement this function but
316    /// call [`QTableModelBase::reset`] to notify Qt about the modification.
317    ///
318    /// Panics by default. Implementors must override this method to support
319    /// a model reset.
320    ///
321    /// After [`QTableModel::reset_unnotified`] returns, the internal storage
322    /// must reflect the new model state: [`QTableModel::row_count`] and
323    /// [`QTableModel::get`] must be consistent with the updated storage.
324    fn reset_unnotified(&mut self) {
325        panic!("In order to use reset, implement reset_unnotified")
326    }
327
328}
329
330/// A data-change signaling extension of [`QTableModel`].
331///
332/// `QTableModelBase` provides the signaling mutation API for list models.
333/// The methods defined in this trait wrap the corresponding
334/// `*_unnotified` methods from [`QTableModel`] and automatically emit the
335/// required Qt model signals (such as `beginInsertRows`, `endInsertRows`,
336/// `dataChanged`, etc.). This allows the UI to react to changes in the
337/// underlying data.
338///
339/// This trait is automatically implemented by the [`qobject`] macro and
340/// should not be implemented manually.
341///
342/// ## Usage
343///
344/// When modifying data that you made accessible with [`QTableModel`], you
345/// have to use the functions provided by this trait. Do **not** call the
346/// `*_unnotified` methods from [`QTableModel`] directly unless you are
347/// manually handling Qt model notifications.
348///
349/// The correctness of this trait depends on implementors of [`QTableModel`]
350/// ensuring that:
351///
352/// * The `*_unnotified` methods perform the exact mutation corresponding
353///   to the emitted Qt signals.
354/// * No additional structural changes occur.
355///
356/// Violating this contract may result in undefined behavior in Qt views.
357pub trait QTableModelBase : QTableModel + QObjectHolder<ProxyRust = QTableModelProxyRust> {
358    /// Sets the item at `index` and notifies any attached views about
359    /// the change, if the operation is successful.
360    ///
361    /// This method calls [`QTableModel::set_unnotified`].
362    ///
363    /// Returns `true` if the value was successfully updated,
364    /// or `false` if the operation failed (for example, if the index
365    /// was out of bounds or validation failed).
366    fn set(&mut self, index: (usize, usize), value: <Self as QTableModel>::Item) -> bool {
367        if self.set_unnotified(index, value) {
368            let model_index = self.get_rust_proxy().index(index.0 as i32, index.1 as i32 , &QModelIndex::default());
369            self.get_rust_proxy_mut().base_data_changed(&model_index, &model_index);
370            true
371        } else {
372            false
373        }
374    }
375
376    /// Appends a row of `values` to the end of the model and notifies any attached views about
377    /// the change.
378    ///
379    /// This method calls [`QTableModel::push_row_unnotified`].
380    fn push_row(&mut self, values: &[Self::Item]) {
381        self.get_rust_proxy_mut().base_begin_insert_rows(&QModelIndex::default(), self.row_count() as i32, self.row_count() as i32);
382        self.push_row_unnotified(values);
383        self.get_rust_proxy_mut().base_end_insert_rows();
384    }
385
386    /// Appends a column of `value` to the end of the model and notifies any attached views about
387    /// the change.
388    ///
389    /// This method calls [`QTableModel::push_column_unnotified`].
390    fn push_column(&mut self, values: &[Self::Item]) {
391        self.get_rust_proxy_mut().base_begin_insert_columns(&QModelIndex::default(), self.column_count() as i32, self.column_count() as i32);
392        self.push_column_unnotified(values);
393        self.get_rust_proxy_mut().base_end_insert_columns();
394    }
395
396    /// Inserts a row with `values` at `index` and notifies any attached views about
397    /// the change.
398    ///
399    /// This method calls [`QTableModel::insert_row_unnotified`].
400    fn insert_row(&mut self, index: usize, values: &[Self::Item]) {
401        self.get_rust_proxy_mut().base_begin_insert_rows(&QModelIndex::default(), index as i32, index as i32);
402        self.insert_row_unnotified(index, values);
403        self.get_rust_proxy_mut().base_end_insert_rows();
404    }
405
406    /// Inserts a column with `values` at `index` and notifies any attached views about
407    /// the change.
408    ///
409    /// This method calls [`QTableModel::insert_column_unnotified`].
410    fn insert_column(&mut self, index: usize, values: &[Self::Item]) {
411        self.get_rust_proxy_mut().base_begin_insert_columns(&QModelIndex::default(), index as i32, index as i32);
412        self.insert_column_unnotified(index, values);
413        self.get_rust_proxy_mut().base_end_insert_columns();
414    }
415
416    /// Removes and returns the last row in the model and notifies any attached views about
417    /// the change.
418    ///
419    /// This method calls [`QTableModel::pop_row_unnotified`].
420    ///
421    /// Returns `None` if the model is empty. If the model is not empty,
422    /// the function has to guarantee the success of the operation.
423    fn pop_row(&mut self) -> Option<Vec<Self::Item>> {
424        if self.row_count() == 0 {
425            return None;
426        }
427        self.get_rust_proxy_mut().base_begin_remove_rows(&QModelIndex::default(), self.row_count() as i32 - 1, self.row_count() as i32 - 1);
428        let values = self.pop_row_unnotified();
429        self.get_rust_proxy_mut().base_end_remove_rows();
430        values
431    }
432
433    /// Removes and returns the last column in the model and notifies any attached views about
434    /// the change.
435    ///
436    /// This method calls [`QTableModel::pop_column_unnotified`].
437    ///
438    /// Returns `None` if the model is empty. If the model is not empty,
439    /// the function has to guarantee the success of the operation.
440    fn pop_column(&mut self) -> Option<Vec<Self::Item>> {
441        if self.column_count() == 0 {
442            return None;
443        }
444        self.get_rust_proxy_mut().base_begin_remove_columns(&QModelIndex::default(), self.column_count() as i32 - 1, self.column_count() as i32 - 1);
445        let values = self.pop_column_unnotified();
446        self.get_rust_proxy_mut().base_end_remove_columns();
447        values
448    }
449
450    /// Removes and returns the row at `index` and notifies any attached views about
451    /// the change.
452    ///
453    /// This method calls [`QTableModel::remove_row_unnotified`].
454    fn remove_row(&mut self, index: usize) -> Vec<Self::Item> {
455        self.get_rust_proxy_mut().base_begin_remove_rows(&QModelIndex::default(), index as i32, index as i32);
456        let values = self.remove_row_unnotified(index);
457        self.get_rust_proxy_mut().base_end_remove_rows();
458        values
459    }
460
461    /// Removes and returns the column at `index` and notifies any attached views about
462    /// the change.
463    ///
464    /// This method calls [`QTableModel::remove_column_unnotified`].
465    fn remove_column(&mut self, index: usize) -> Vec<Self::Item> {
466        self.get_rust_proxy_mut().base_begin_remove_columns(&QModelIndex::default(), index as i32, index as i32);
467        let values = self.remove_column_unnotified(index);
468        self.get_rust_proxy_mut().base_end_remove_columns();
469        values
470    }
471
472    /// Resets the entire model and notifies any attached views to resyncronize all data.
473    ///
474    /// This method calls [`QTableModel::reset_unnotified`].
475    fn reset(&mut self) {
476        self.get_rust_proxy_mut().base_begin_reset_model();
477        self.reset_unnotified();
478        self.get_rust_proxy_mut().base_end_reset_model();
479    }
480}
481
482impl<T> QTableModelBase for T
483where T: QTableModel + QObjectHolder<ProxyRust = QTableModelProxyRust> { }
484
485pub struct QTableModelProxyRust {
486    cpp_proxy: *mut QTableModelProxyCpp,
487    #[allow(dead_code)]
488    rust_obj: RustObjAccess<dyn QTableModelAdapter>,
489    on_drop: Box<dyn FnOnce()>,
490}
491
492impl QRustProxy for QTableModelProxyRust {
493
494    type ProxyCppType = QTableModelProxyCpp;
495    type AdapterType = dyn QTableModelAdapter;
496
497    fn new<OnDropFn: FnOnce() + 'static>(rust_obj: &Rc<RefCell<dyn QTableModelAdapter>>, construct: ConstructionMode, on_drop: OnDropFn) -> *mut Self {
498        let boxed_self = Box::new(Self {
499            cpp_proxy: std::ptr::null_mut(),
500            rust_obj: match construct {
501                ConstructionMode::Strong | ConstructionMode::AtAddress(_) => RustObjAccess::new_strong(rust_obj.clone()),
502                ConstructionMode::Weak => RustObjAccess::new_weak(Rc::downgrade(rust_obj)),
503            },
504            on_drop: Box::new(on_drop),
505        });
506        let raw_self = Box::into_raw(boxed_self);
507
508        unsafe{ (*raw_self).cpp_proxy = match construct {
509            ConstructionMode::AtAddress(addr) => {
510                ffi::create_qtable_model_proxy_cpp_at(addr,  raw_self)
511            }
512            ConstructionMode::Strong | ConstructionMode::Weak => {
513                ffi::create_qtable_model_proxy_cpp(raw_self)
514            }
515        }};
516        raw_self
517    }
518    fn get_static_meta_object() -> &'static QMetaObject {
519        ffi::static_qmeta_object_of_qtable_model_proxy_cpp()
520    }
521    fn get_size_of_cpp_proxy() -> usize {
522        ffi::size_of_qtable_model_proxy_cpp()
523    }
524    fn get_align_of_cpp_proxy() -> usize {
525        ffi::align_of_qtable_model_proxy_cpp()
526    }
527    fn get_qmetatype_list_of_cpp_proxy() -> QMetaType {
528        ffi::qmetatype_list_of_qtable_model_proxy_cpp()
529    }
530    fn get_cpp_proxy(&self) -> *const QTableModelProxyCpp {
531        self.cpp_proxy as *const _
532    }
533    fn get_cpp_proxy_mut(&self) -> *mut QTableModelProxyCpp {
534        self.cpp_proxy
535    }
536}
537
538impl QTableModelProxyRust {
539    pub fn drop_self(self_ptr: *mut Self) {
540        let boxed_self = unsafe { Box::from_raw(self_ptr) };
541        (boxed_self.on_drop)();
542    }
543    pub fn invoke_slot(&self, slot_id: u32, inputs: &[*const u8], outputs: &[*mut u8]) {
544        call_rust_trait_impl!(self, invoke_slot(slot_id, inputs, outputs))
545    }
546    pub fn invoke_slot_mut(&mut self, slot_id: u32, inputs: &[*const u8], outputs: &[*mut u8]) {
547        call_rust_trait_impl!(mut self, invoke_slot_mut(slot_id, inputs, outputs))
548    }
549    pub fn read_property(&self, prop_id: u32) -> QVariant {
550        call_rust_trait_impl!(self, read_property(prop_id))
551    }
552    pub fn write_property(&mut self, prop_id: u32, value: &QVariant) {
553        call_rust_trait_impl!(mut self, write_property(prop_id, value))
554    }
555    pub fn index(&self, row: i32, column: i32, parent: &QModelIndex) -> QModelIndex {
556        call_rust_trait_impl!(self, index(row, column, parent))
557    }
558    pub fn parent(&self, child: &QModelIndex) -> QModelIndex {
559        call_rust_trait_impl!(self, parent(child))
560    }
561    pub fn row_count(&self, parent: &QModelIndex) -> i32 {
562        call_rust_trait_impl!(self, row_count(parent))
563    }
564    pub fn column_count(&self, parent: &QModelIndex) -> i32 {
565        call_rust_trait_impl!(self, column_count(parent))
566    }
567    pub fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
568        call_rust_trait_impl!(self, data(index, role))
569    }
570    pub fn role_names(&self) -> QHash<i32, QByteArray> {
571        call_rust_trait_impl!(self, role_names())
572    }
573    pub fn set_data(&mut self, index: &QModelIndex, value: &QVariant, role: i32) -> bool {
574        call_rust_trait_impl!(mut self, set_data(index, value, role))
575    }
576    pub fn remove_columns(&mut self, first: i32, count: i32, parent: &QModelIndex) -> bool {
577        call_rust_trait_impl!(mut self, remove_columns(first, count, parent))
578    }
579    pub fn remove_rows(&mut self, first: i32, count: i32, parent: &QModelIndex) -> bool {
580        call_rust_trait_impl!(mut self, remove_rows(first, count, parent))
581    }
582    pub fn sibling(&self, row: i32, column: i32, idx: &QModelIndex) -> QModelIndex {
583        call_rust_trait_impl!(self, sibling(row, column, idx))
584    }
585    pub fn base_role_names(&self) -> QHash<i32, QByteArray> {
586        call_cpp_impl!(self, base_role_names())
587    }
588    pub fn base_set_data(&mut self, index: &QModelIndex, value: &QVariant, role: i32) -> bool {
589        call_cpp_impl!(mut self, base_set_data(index, value, role))
590    }
591    pub fn base_remove_columns(&mut self, first: i32, count: i32, parent: &QModelIndex) -> bool {
592        call_cpp_impl!(mut self, base_remove_columns(first, count, parent))
593    }
594    pub fn base_remove_rows(&mut self, first: i32, count: i32, parent: &QModelIndex) -> bool {
595        call_cpp_impl!(mut self, base_remove_rows(first, count, parent))
596    }
597    pub fn base_sibling(&self, row: i32, column: i32, idx: &QModelIndex) -> QModelIndex {
598        call_cpp_impl!(self, base_sibling(row, column, idx))
599    }
600    pub fn base_data_changed(&mut self, top_left: &QModelIndex, bottom_right: &QModelIndex) {
601        call_cpp_impl!(mut self, base_data_changed(top_left, bottom_right))
602    }
603    pub fn base_begin_insert_columns(&mut self, parent: &QModelIndex, first: i32, last: i32) {
604        call_cpp_impl!(mut self, base_begin_insert_columns(parent, first, last))
605    }
606    pub fn base_end_insert_columns(&mut self) {
607        call_cpp_impl!(mut self, base_end_insert_columns())
608    }
609    pub fn base_begin_insert_rows(&mut self, parent: &QModelIndex, first: i32, last: i32) {
610        call_cpp_impl!(mut self, base_begin_insert_rows(parent, first, last))
611    }
612    pub fn base_end_insert_rows(&mut self) {
613        call_cpp_impl!(mut self, base_end_insert_rows())
614    }
615    pub fn base_begin_move_columns(
616        &mut self,
617        source_parent: &QModelIndex,
618        source_first: i32,
619        source_last: i32,
620        destination_parent: &QModelIndex,
621        destination_child: i32,
622    ) {
623        call_cpp_impl!(mut self, base_begin_move_columns(source_parent, source_first, source_last, destination_parent, destination_child))
624    }
625    pub fn base_end_move_columns(&mut self) {
626        call_cpp_impl!(mut self, base_end_move_columns())
627    }
628    pub fn base_begin_move_rows(&mut self, source_parent: &QModelIndex, source_first: i32, source_last: i32, destination_parent: &QModelIndex, destination_child: i32) {
629        call_cpp_impl!(mut self, base_begin_move_rows(source_parent, source_first, source_last, destination_parent, destination_child))
630    }
631    pub fn base_end_move_rows(&mut self) {
632        call_cpp_impl!(mut self, base_end_move_rows())
633    }
634    pub fn base_begin_remove_columns(&mut self, parent: &QModelIndex, first: i32, last: i32) {
635        call_cpp_impl!(mut self, base_begin_remove_columns(parent, first, last))
636    }
637    pub fn base_end_remove_columns(&mut self) {
638        call_cpp_impl!(mut self, base_end_remove_columns())
639    }
640    pub fn base_begin_remove_rows(&mut self, parent: &QModelIndex, first: i32, last: i32) {
641        call_cpp_impl!(mut self, base_begin_remove_rows(parent, first, last))
642    }
643    pub fn base_end_remove_rows(&mut self) {
644        call_cpp_impl!(mut self, base_end_remove_rows())
645    }
646    pub fn base_begin_reset_model(&mut self) {
647        call_cpp_impl!(mut self, base_begin_reset_model())
648    }
649    pub fn base_end_reset_model(&mut self) {
650        call_cpp_impl!(mut self, base_end_reset_model())
651    }
652    pub fn base_create_index(&self, row: i32, column: i32, ptr: usize) -> QModelIndex {
653        call_cpp_impl!(self, base_create_index(row, column, ptr))
654    }
655}