pub unsafe fn copy_selection(&self) {

        // Get the current selection. As we need his visual order, we get it directly from the table/filter, NOT FROM THE MODEL.
        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());

        // Create a string to keep all the values in a TSV format (x\tx\tx) and populate it.
        let mut copy = String::new();
        let mut row = 0;
        for (cycle, model_index) in indexes_sorted.iter().enumerate() {
            if model_index.is_valid() {

                // If this is the first time we loop, get the row. Otherwise, Replace the last \t with a \n and update the row.
                if cycle == 0 { row = model_index.row(); }
                else if model_index.row() != row {
                    copy.pop();
                    copy.push('\n');
                    row = model_index.row();
                }

                // If it's checkable, we need to get a bool. Otherwise it's a String.
                let item = self.table_model.item_from_index(model_index);
                if item.is_checkable() {
                    match item.check_state() {
                        CheckState::Checked => copy.push_str("true"),
                        CheckState::Unchecked => copy.push_str("false"),
                        _ => return
                    }
                }

                // Fix for weird precision issues on copy.
                else if self.table_definition.read().unwrap().get_fields_processed()[model_index.column() as usize].get_field_type() == FieldType::F32 {
                    copy.push_str(&format!("{}", (item.data_1a(2).to_float_0a() * 1000.0).round() / 1000.0));
                }
                else { copy.push_str(&QString::to_std_string(&item.text())); }

                // Add a \t to separate fields except if it's the last field.
                if cycle < (indexes_sorted.len() - 1) { copy.push('\t'); }
            }
        }

        // Put the baby into the oven.
        QGuiApplication::clipboard().set_text_1a(&QString::from_std_str(copy));
    }
/// This function copies the selected cells into the clipboard as a TSV file, so you can paste them in other programs.
This function copies the selected cells into the clipboard as a TSV file, so you can paste them in other programs.
This function copies the selected cells into the clipboard as a TSV file so you can paste them in other programs .
pub unsafe fn copy_selection(&self) {
        // Get the current selection. As we need his visual order, we get it directly from the table/filter, NOT FROM THE MODEL.
        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());
        // Create a string to keep all the values in a TSV format (x\tx\tx) and populate it.
        let mut copy = String::new();
        let mut row = 0;
        for (cycle, model_index) in indexes_sorted.iter().enumerate() {
            if model_index.is_valid() {
                // If this is the first time we loop, get the row. Otherwise, Replace the last \t with a \n and update the row.
                if cycle == 0 { row = model_index.row(); }
                else if model_index.row() != row {
                    copy.pop();
                    copy.push('\n');
                    row = model_index.row();
                }
                // If it's checkable, we need to get a bool. Otherwise it's a String.
                let item = self.table_model.item_from_index(model_index);
                if item.is_checkable() {
                    match item.check_state() {
                        CheckState::Checked => copy.push_str("true"),
                        CheckState::Unchecked => copy.push_str("false"),
                        _ => return
                    }
                }
                // Fix for weird precision issues on copy.
                else if self.table_definition.read().unwrap().get_fields_processed()[model_index.column() as usize].get_field_type() == FieldType::F32 {
                    copy.push_str(&format!("{}", (item.data_1a(2).to_float_0a() * 1000.0).round() / 1000.0));
                }
                else { copy.push_str(&QString::to_std_string(&item.text())); }
                // Add a \t to separate fields except if it's the last field.
                if cycle < (indexes_sorted.len() - 1) { copy.push('\t'); }
            }
        }
        // Put the baby into the oven.
        QGuiApplication::clipboard().set_text_1a(&QString::from_std_str(copy));
    }
pub unsafe fn copy_selection ( & self ) { // Get the current selection. As we need his visual order, we get it directly from the table/filter, NOT FROM THE MODEL. 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 ( ) ) ; // Create a string to keep all the values in a TSV format (x\tx\tx) and populate it. let mut copy = String :: new ( ) ; let mut row = 0 ; for ( cycle , model_index ) in indexes_sorted . iter ( ) . enumerate ( ) { if model_index . is_valid ( ) { // If this is the first time we loop, get the row. Otherwise, Replace the last \t with a \n and update the row. if cycle == 0 { row = model_index . row ( ) ; } else if model_index . row ( ) != row { copy . pop ( ) ; copy . push ( '\n' ) ; row = model_index . row ( ) ; } // If it's checkable, we need to get a bool. Otherwise it's a String. let item = self . table_model . item_from_index ( model_index ) ; if item . is_checkable ( ) { match item . check_state ( ) { CheckState :: Checked => copy . push_str ( " " ) , CheckState :: Unchecked => copy . push_str ( " " ) , _ => return } } // Fix for weird precision issues on copy. else if self . table_definition . read ( ) . unwrap ( ) . get_fields_processed ( ) [ model_index . column ( ) as usize ] . get_field_type ( ) == FieldType :: F32 { copy . push_str ( & format ! ( " " ( item data_1a ( 2 ) to_float_0a ( ) 1000.0 ) round ( ) 1000.0 ) ) ; } else { copy . push_str ( & QString :: to_std_string ( & item . text ( ) ) ) ; } // Add a \t to separate fields except if it's the last field. if cycle < ( indexes_sorted . len ( ) - 1 ) { copy . push ( '\t' ) ; } } } // Put the baby into the oven. QGuiApplication :: clipboard ( ) . set_text_1a ( & QString :: from_std_str ( copy ) ) ; }
This function copies the selected cells into the clipboard as a TSV file, so you can paste them in other programs.
This function copies the selected cells into the clipboard as a TSV file so you can paste them in other programs .
&self
&self