pub unsafe fn smart_delete(&self, delete_all_rows: bool, app_ui: &Rc<AppUI>, pack_file_contents_ui: &Rc<PackFileContentsUI>) {

        // Get the selected indexes, the split them in two groups: one with full rows selected and another with single cells selected.
        let indexes = self.table_view_primary.selection_model().selection().indexes();
        let mut indexes_sorted = (0..indexes.count_0a()).map(|x| indexes.at(x)).collect::<Vec<Ref<QModelIndex>>>();
        sort_indexes_visually(&mut indexes_sorted, &self.get_mut_ptr_table_view_primary());
        let indexes_sorted = get_real_indexes(&indexes_sorted, &self.get_mut_ptr_table_view_filter());

        if delete_all_rows {
            let mut rows_to_delete: Vec<i32> = indexes_sorted.iter().filter_map(|x| if x.is_valid() { Some(x.row()) } else { None }).collect();

            // Dedup the list and reverse it.
            rows_to_delete.sort_unstable();
            rows_to_delete.dedup();
            rows_to_delete.reverse();

            self.set_data_on_cells(&[], 0, &rows_to_delete, app_ui, pack_file_contents_ui);
        } else {

            let mut cells: BTreeMap<i32, Vec<i32>> = BTreeMap::new();
            for model_index in &indexes_sorted {
                if model_index.is_valid() {
                    let row = model_index.row();
                    let column = model_index.column();

                    // Check if we have any cell in that row and add/insert the new one.
                    match cells.get_mut(&row) {
                        Some(row) => row.push(column),
                        None => { cells.insert(row, vec![column]); },
                    }
                }
            }

            let visible_column_count = (0..self.table_model.column_count_0a()).filter(|index| !self.table_view_primary.is_column_hidden(*index)).count();
            let full_rows = cells.iter()
                .filter(|(_, y)| y.len() >= visible_column_count)
                .map(|(x, _)| *x)
                .collect::<Vec<i32>>();

            let individual_cells = cells.iter()
                .filter(|(_, y)| y.len() < visible_column_count)
                .map(|(x, y)| (*x, y.to_vec()))
                .collect::<Vec<(i32, Vec<i32>)>>();

            let default_str = "".to_owned();
            let default_f32 = "0.0".to_owned();
            let default_f64 = "0.0".to_owned();
            let default_i32 = "0".to_owned();
            let default_bool = "false".to_owned();
            let default_colour_rgb = "000000".to_owned();

            let mut real_cells = vec![];
            let mut values = vec![];
            for (row, columns) in &individual_cells {
                for column in columns {
                    let index = self.table_model.index_2a(*row, *column);
                    if index.is_valid() {
                        match self.get_ref_table_definition().get_fields_processed()[*column as usize].get_ref_field_type() {
                            FieldType::Boolean => values.push(&*default_bool),
                            FieldType::F32 => values.push(&*default_f32),
                            FieldType::F64 => values.push(&*default_f64),
                            FieldType::I16 |
                            FieldType::I32 |
                            FieldType::I64 => values.push(&*default_i32),
                            FieldType::ColourRGB => values.push(&*default_colour_rgb),
                            FieldType::StringU8 |
                            FieldType::StringU16 |
                            FieldType::OptionalStringU8 |
                            FieldType::OptionalStringU16 => values.push(&*default_str),
                            FieldType::SequenceU16(_) |
                            FieldType::SequenceU32(_) => continue,
                        }
                        real_cells.push(index);
                    }
                }
            }


            let mut realer_cells = vec![];
            for index in (0..real_cells.len()).rev() {
                realer_cells.push((real_cells.pop().unwrap(), &*values[index]));
            }
            realer_cells.reverse();

            self.set_data_on_cells(&realer_cells, 0, &full_rows, app_ui, pack_file_contents_ui);
        }
    }
/// This function takes care of the "Smart Delete" feature for tables.
This function takes care of the "Smart Delete" feature for tables.
This function takes care of the " Smart Delete " feature for tables .
pub unsafe fn smart_delete(&self, delete_all_rows: bool, app_ui: &Rc<AppUI>, pack_file_contents_ui: &Rc<PackFileContentsUI>) {
        // Get the selected indexes, the split them in two groups: one with full rows selected and another with single cells selected.
        let indexes = self.table_view_primary.selection_model().selection().indexes();
        let mut indexes_sorted = (0..indexes.count_0a()).map(|x| indexes.at(x)).collect::<Vec<Ref<QModelIndex>>>();
        sort_indexes_visually(&mut indexes_sorted, &self.get_mut_ptr_table_view_primary());
        let indexes_sorted = get_real_indexes(&indexes_sorted, &self.get_mut_ptr_table_view_filter());
        if delete_all_rows {
            let mut rows_to_delete: Vec<i32> = indexes_sorted.iter().filter_map(|x| if x.is_valid() { Some(x.row()) } else { None }).collect();
            // Dedup the list and reverse it.
            rows_to_delete.sort_unstable();
            rows_to_delete.dedup();
            rows_to_delete.reverse();
            self.set_data_on_cells(&[], 0, &rows_to_delete, app_ui, pack_file_contents_ui);
        } else {
            let mut cells: BTreeMap<i32, Vec<i32>> = BTreeMap::new();
            for model_index in &indexes_sorted {
                if model_index.is_valid() {
                    let row = model_index.row();
                    let column = model_index.column();
                    // Check if we have any cell in that row and add/insert the new one.
                    match cells.get_mut(&row) {
                        Some(row) => row.push(column),
                        None => { cells.insert(row, vec![column]); },
                    }
                }
            }
            let visible_column_count = (0..self.table_model.column_count_0a()).filter(|index| !self.table_view_primary.is_column_hidden(*index)).count();
            let full_rows = cells.iter()
                .filter(|(_, y)| y.len() >= visible_column_count)
                .map(|(x, _)| *x)
                .collect::<Vec<i32>>();
            let individual_cells = cells.iter()
                .filter(|(_, y)| y.len() < visible_column_count)
                .map(|(x, y)| (*x, y.to_vec()))
                .collect::<Vec<(i32, Vec<i32>)>>();
            let default_str = "".to_owned();
            let default_f32 = "0.0".to_owned();
            let default_f64 = "0.0".to_owned();
            let default_i32 = "0".to_owned();
            let default_bool = "false".to_owned();
            let default_colour_rgb = "000000".to_owned();
            let mut real_cells = vec![];
            let mut values = vec![];
            for (row, columns) in &individual_cells {
                for column in columns {
                    let index = self.table_model.index_2a(*row, *column);
                    if index.is_valid() {
                        match self.get_ref_table_definition().get_fields_processed()[*column as usize].get_ref_field_type() {
                            FieldType::Boolean => values.push(&*default_bool),
                            FieldType::F32 => values.push(&*default_f32),
                            FieldType::F64 => values.push(&*default_f64),
                            FieldType::I16 |
                            FieldType::I32 |
                            FieldType::I64 => values.push(&*default_i32),
                            FieldType::ColourRGB => values.push(&*default_colour_rgb),
                            FieldType::StringU8 |
                            FieldType::StringU16 |
                            FieldType::OptionalStringU8 |
                            FieldType::OptionalStringU16 => values.push(&*default_str),
                            FieldType::SequenceU16(_) |
                            FieldType::SequenceU32(_) => continue,
                        }
                        real_cells.push(index);
                    }
                }
            }
            let mut realer_cells = vec![];
            for index in (0..real_cells.len()).rev() {
                realer_cells.push((real_cells.pop().unwrap(), &*values[index]));
            }
            realer_cells.reverse();
            self.set_data_on_cells(&realer_cells, 0, &full_rows, app_ui, pack_file_contents_ui);
        }
    }
pub unsafe fn smart_delete ( & self , delete_all_rows : bool , app_ui : & Rc < AppUI > , pack_file_contents_ui : & Rc < PackFileContentsUI > ) { // Get the selected indexes, the split them in two groups: one with full rows selected and another with single cells selected. let indexes = self . table_view_primary . selection_model ( ) . selection ( ) . indexes ( ) ; let mut indexes_sorted = ( 0 .. indexes . count_0a ( ) ) . map ( | x | indexes . at ( x ) ) . collect :: < Vec < Ref < QModelIndex > > > ( ) ; sort_indexes_visually ( & mut indexes_sorted , & self . get_mut_ptr_table_view_primary ( ) ) ; let indexes_sorted = get_real_indexes ( & indexes_sorted , & self . get_mut_ptr_table_view_filter ( ) ) ; if delete_all_rows { let mut rows_to_delete : Vec < i32 > = indexes_sorted . iter ( ) . filter_map ( | x | if x . is_valid ( ) { Some ( x . row ( ) ) } else { None } ) . collect ( ) ; // Dedup the list and reverse it. rows_to_delete . sort_unstable ( ) ; rows_to_delete . dedup ( ) ; rows_to_delete . reverse ( ) ; self . set_data_on_cells ( & [ ] , 0 , & rows_to_delete , app_ui , pack_file_contents_ui ) ; } else { let mut cells : BTreeMap < i32 , Vec < i32 > > = BTreeMap :: new ( ) ; for model_index in & indexes_sorted { if model_index . is_valid ( ) { let row = model_index . row ( ) ; let column = model_index . column ( ) ; // Check if we have any cell in that row and add/insert the new one. match cells . get_mut ( & row ) { Some ( row ) => row . push ( column ) , None => { cells . insert ( row , vec ! [ column ] ) ; } , } } } let visible_column_count = ( 0 .. self . table_model . column_count_0a ( ) ) . filter ( | index | ! self . table_view_primary . is_column_hidden ( * index ) ) . count ( ) ; let full_rows = cells . iter ( ) . filter ( | ( _ , y ) | y . len ( ) >= visible_column_count ) . map ( | ( x , _ ) | * x ) . collect :: < Vec < i32 > > ( ) ; let individual_cells = cells . iter ( ) . filter ( | ( _ , y ) | y . len ( ) < visible_column_count ) . map ( | ( x , y ) | ( * x , y . to_vec ( ) ) ) . collect :: < Vec < ( i32 , Vec < i32 > ) > > ( ) ; let default_str = " " . to_owned ( ) ; let default_f32 = " " . to_owned ( ) ; let default_f64 = " " . to_owned ( ) ; let default_i32 = " " . to_owned ( ) ; let default_bool = " " . to_owned ( ) ; let default_colour_rgb = " " . to_owned ( ) ; let mut real_cells = vec ! [ ] ; let mut values = vec ! [ ] ; for ( row , columns ) in & individual_cells { for column in columns { let index = self . table_model . index_2a ( * row , * column ) ; if index . is_valid ( ) { match self . get_ref_table_definition ( ) . get_fields_processed ( ) [ * column as usize ] . get_ref_field_type ( ) { FieldType :: Boolean => values . push ( & * default_bool ) , FieldType :: F32 => values . push ( & * default_f32 ) , FieldType :: F64 => values . push ( & * default_f64 ) , FieldType :: I16 | FieldType :: I32 | FieldType :: I64 => values . push ( & * default_i32 ) , FieldType :: ColourRGB => values . push ( & * default_colour_rgb ) , FieldType :: StringU8 | FieldType :: StringU16 | FieldType :: OptionalStringU8 | FieldType :: OptionalStringU16 => values . push ( & * default_str ) , FieldType :: SequenceU16 ( _ ) | FieldType :: SequenceU32 ( _ ) => continue , } real_cells . push ( index ) ; } } } let mut realer_cells = vec ! [ ] ; for index in ( 0 .. real_cells . len ( ) ) . rev ( ) { realer_cells . push ( ( real_cells . pop ( ) . unwrap ( ) , & * values [ index ] ) ) ; } realer_cells . reverse ( ) ; self . set_data_on_cells ( & realer_cells , 0 , & full_rows , app_ui , pack_file_contents_ui ) ; } }
This function takes care of the "Smart Delete" feature for tables.
This function takes care of the " Smart Delete " feature for tables .
&self
delete_all_rows
bool
app_ui
&Rc<AppUI>
pack_file_contents_ui
&Rc<PackFileContentsUI>
&self
delete_all_rows
bool
app_ui
&Rc<AppUI>
pack_file_contents_ui
&Rc<PackFileContentsUI>