pub unsafe fn append_rows(&self, clone: bool) {

        // Get the indexes ready for battle.
        let selection = self.table_view_primary.selection_model().selection();
        let indexes = self.table_filter.map_selection_to_source(&selection).indexes();
        let mut indexes_sorted = (0..indexes.count_0a()).map(|x| indexes.at(x)).collect::<Vec<Ref<QModelIndex>>>();
        sort_indexes_by_model(&mut indexes_sorted);
        dedup_indexes_per_row(&mut indexes_sorted);
        let mut row_numbers = vec![];

        let rows = if clone {
            let mut rows = vec![];
            for index in indexes_sorted.iter() {
                row_numbers.push(index.row());

                let columns = self.table_model.column_count_0a();
                let qlist = QListOfQStandardItem::new();
                for column in 0..columns {
                    let original_item = self.table_model.item_2a(index.row(), column);
                    let item = (*original_item).clone();
                    item.set_data_2a(&QVariant::from_bool(true), ITEM_IS_ADDED);
                    item.set_data_2a(&QVariant::from_bool(false), ITEM_IS_MODIFIED);
                    qlist.append_q_standard_item(&item.as_mut_raw_ptr());
                }

                rows.push(qlist);
            }
            rows
        } else {
            let row = get_new_row(&self.get_ref_table_definition(), self.get_ref_table_name().as_deref());
            for index in 0..row.count_0a() {
                row.value_1a(index).set_data_2a(&QVariant::from_bool(true), ITEM_IS_ADDED);
            }
            vec![row]
        };

        let selection_model = self.table_view_primary.selection_model();
        selection_model.clear();
        for row in &rows {
            self.table_model.append_row_q_list_of_q_standard_item(row.as_ref());

            // Select the row and scroll to it.
            let model_index_filtered = self.table_filter.map_from_source(&self.table_model.index_2a(self.table_filter.row_count_0a() - 1, 0));
            if model_index_filtered.is_valid() {
                selection_model.select_q_model_index_q_flags_selection_flag(
                    &model_index_filtered,
                    SelectionFlag::Select | SelectionFlag::Rows
                );

                self.table_view_primary.scroll_to_2a(
                    model_index_filtered.as_ref(),
                    ScrollHint::EnsureVisible
                );
            }
        }

        // Update the undo stuff. Cloned rows are the amount of rows - the amount of cloned rows.
        let total_rows = self.table_model.row_count_0a();
        let range = (total_rows - rows.len() as i32..total_rows).collect::<Vec<i32>>();
        self.history_undo.write().unwrap().push(TableOperations::AddRows(range));
        self.history_redo.write().unwrap().clear();
        self.start_delayed_updates_timer();
        self.update_line_counter();
        update_undo_model(&self.get_mut_ptr_table_model(), &self.get_mut_ptr_undo_model());
        //unsafe { undo_redo_enabler.as_mut().unwrap().trigger(); }
    }
/// This function is used to append new rows to a table.
///
/// If clone = true, the appended rows are copies of the selected ones.
This function is used to append new rows to a table.
If clone = true, the appended rows are copies of the selected ones.
This function is used to append new rows to a table . If clone = true the appended rows are copies of the selected ones .
pub unsafe fn append_rows(&self, clone: bool) {
        // Get the indexes ready for battle.
        let selection = self.table_view_primary.selection_model().selection();
        let indexes = self.table_filter.map_selection_to_source(&selection).indexes();
        let mut indexes_sorted = (0..indexes.count_0a()).map(|x| indexes.at(x)).collect::<Vec<Ref<QModelIndex>>>();
        sort_indexes_by_model(&mut indexes_sorted);
        dedup_indexes_per_row(&mut indexes_sorted);
        let mut row_numbers = vec![];
        let rows = if clone {
            let mut rows = vec![];
            for index in indexes_sorted.iter() {
                row_numbers.push(index.row());
                let columns = self.table_model.column_count_0a();
                let qlist = QListOfQStandardItem::new();
                for column in 0..columns {
                    let original_item = self.table_model.item_2a(index.row(), column);
                    let item = (*original_item).clone();
                    item.set_data_2a(&QVariant::from_bool(true), ITEM_IS_ADDED);
                    item.set_data_2a(&QVariant::from_bool(false), ITEM_IS_MODIFIED);
                    qlist.append_q_standard_item(&item.as_mut_raw_ptr());
                }
                rows.push(qlist);
            }
            rows
        } else {
            let row = get_new_row(&self.get_ref_table_definition(), self.get_ref_table_name().as_deref());
            for index in 0..row.count_0a() {
                row.value_1a(index).set_data_2a(&QVariant::from_bool(true), ITEM_IS_ADDED);
            }
            vec![row]
        };
        let selection_model = self.table_view_primary.selection_model();
        selection_model.clear();
        for row in &rows {
            self.table_model.append_row_q_list_of_q_standard_item(row.as_ref());
            // Select the row and scroll to it.
            let model_index_filtered = self.table_filter.map_from_source(&self.table_model.index_2a(self.table_filter.row_count_0a() - 1, 0));
            if model_index_filtered.is_valid() {
                selection_model.select_q_model_index_q_flags_selection_flag(
                    &model_index_filtered,
                    SelectionFlag::Select | SelectionFlag::Rows
                );
                self.table_view_primary.scroll_to_2a(
                    model_index_filtered.as_ref(),
                    ScrollHint::EnsureVisible
                );
            }
        }
        // Update the undo stuff. Cloned rows are the amount of rows - the amount of cloned rows.
        let total_rows = self.table_model.row_count_0a();
        let range = (total_rows - rows.len() as i32..total_rows).collect::<Vec<i32>>();
        self.history_undo.write().unwrap().push(TableOperations::AddRows(range));
        self.history_redo.write().unwrap().clear();
        self.start_delayed_updates_timer();
        self.update_line_counter();
        update_undo_model(&self.get_mut_ptr_table_model(), &self.get_mut_ptr_undo_model());
        //unsafe { undo_redo_enabler.as_mut().unwrap().trigger(); }
    }
pub unsafe fn append_rows ( & self , clone : bool ) { // Get the indexes ready for battle. let selection = self . table_view_primary . selection_model ( ) . selection ( ) ; let indexes = self . table_filter . map_selection_to_source ( & selection ) . indexes ( ) ; let mut indexes_sorted = ( 0 .. indexes . count_0a ( ) ) . map ( | x | indexes . at ( x ) ) . collect :: < Vec < Ref < QModelIndex > > > ( ) ; sort_indexes_by_model ( & mut indexes_sorted ) ; dedup_indexes_per_row ( & mut indexes_sorted ) ; let mut row_numbers = vec ! [ ] ; let rows = if clone { let mut rows = vec ! [ ] ; for index in indexes_sorted . iter ( ) { row_numbers . push ( index . row ( ) ) ; let columns = self . table_model . column_count_0a ( ) ; let qlist = QListOfQStandardItem :: new ( ) ; for column in 0 .. columns { let original_item = self . table_model . item_2a ( index . row ( ) , column ) ; let item = ( * original_item ) . clone ( ) ; item . set_data_2a ( & QVariant :: from_bool ( true ) , ITEM_IS_ADDED ) ; item . set_data_2a ( & QVariant :: from_bool ( false ) , ITEM_IS_MODIFIED ) ; qlist . append_q_standard_item ( & item . as_mut_raw_ptr ( ) ) ; } rows . push ( qlist ) ; } rows } else { let row = get_new_row ( & self . get_ref_table_definition ( ) , self . get_ref_table_name ( ) . as_deref ( ) ) ; for index in 0 .. row . count_0a ( ) { row . value_1a ( index ) . set_data_2a ( & QVariant :: from_bool ( true ) , ITEM_IS_ADDED ) ; } vec ! [ row ] } ; let selection_model = self . table_view_primary . selection_model ( ) ; selection_model . clear ( ) ; for row in & rows { self . table_model . append_row_q_list_of_q_standard_item ( row . as_ref ( ) ) ; // Select the row and scroll to it. let model_index_filtered = self . table_filter . map_from_source ( & self . table_model . index_2a ( self . table_filter . row_count_0a ( ) - 1 , 0 ) ) ; if model_index_filtered . is_valid ( ) { selection_model . select_q_model_index_q_flags_selection_flag ( & model_index_filtered , SelectionFlag :: Select | SelectionFlag :: Rows ) ; self . table_view_primary . scroll_to_2a ( model_index_filtered . as_ref ( ) , ScrollHint :: EnsureVisible ) ; } } // Update the undo stuff. Cloned rows are the amount of rows - the amount of cloned rows. let total_rows = self . table_model . row_count_0a ( ) ; let range = ( total_rows - rows . len ( ) as i32 .. total_rows ) . collect :: < Vec < i32 > > ( ) ; self . history_undo . write ( ) . unwrap ( ) . push ( TableOperations :: AddRows ( range ) ) ; self . history_redo . write ( ) . unwrap ( ) . clear ( ) ; self . start_delayed_updates_timer ( ) ; self . update_line_counter ( ) ; update_undo_model ( & self . get_mut_ptr_table_model ( ) , & self . get_mut_ptr_undo_model ( ) ) ; //unsafe { undo_redo_enabler.as_mut().unwrap().trigger(); } }
This function is used to append new rows to a table.
This function is used to append new rows to a table .
&self
clone
bool
&self
clone
bool