unsafe fn escape_string_from_index(&self, index: Ref<QModelIndex>) -> String {
        let item = self.table_model.item_from_index(index);
        let definition = &self.get_ref_table_definition().clone();
        match definition.get_fields_processed()[index.column() as usize].get_ref_field_type() {
            FieldType::Boolean => if let CheckState::Checked = item.check_state() { "true".to_owned() } else { "false".to_owned() },

            // Floats need to be tweaked to fix trailing zeroes and precision issues, like turning 0.5000004 into 0.5.
            FieldType::F32 => {
                let data_str = format!("{}", item.data_1a(2).to_float_0a());

                // If we have more than 3 decimals, we limit it to three, then do magic to remove trailing zeroes.
                if let Some(position) = data_str.find('.') {
                    let decimals = &data_str[position..].len();
                    if *decimals > 4 { format!("{}", format!("{:.4}", item.data_1a(2).to_float_0a()).parse::<f32>().unwrap()) }
                    else { data_str }
                }
                else { data_str }
            },

            // Floats need to be tweaked to fix trailing zeroes and precision issues, like turning 0.5000004 into 0.5.
            FieldType::F64 => {
                let data_str = format!("{}", item.data_1a(2).to_float_0a());

                // If we have more than 3 decimals, we limit it to three, then do magic to remove trailing zeroes.
                if let Some(position) = data_str.find('.') {
                    let decimals = &data_str[position..].len();
                    if *decimals > 4 { format!("{}", format!("{:.4}", item.data_1a(2).to_double_0a()).parse::<f64>().unwrap()) }
                    else { data_str }
                }
                else { data_str }
            },
            FieldType::I16 |
            FieldType::I32 |
            FieldType::I64 => format!("{}", item.data_1a(2).to_long_long_0a()),
            FieldType::ColourRGB => format!("\"{}\"", item.text().to_std_string().escape_default().to_string()),

            // All these are Strings, so they need to escape certain chars and include commas in Lua.
            FieldType::StringU8 |
            FieldType::StringU16 |
            FieldType::OptionalStringU8 |
            FieldType::OptionalStringU16 => format!("\"{}\"", item.text().to_std_string().escape_default().to_string()),
            FieldType::SequenceU16(_) => "\"SequenceU16\"".to_owned(),
            FieldType::SequenceU32(_) => "\"SequenceU32\"".to_owned(),
        }
    }
/// This function escapes the value inside an index.
This function escapes the value inside an index.
This function escapes the value inside an index .
unsafe fn escape_string_from_index(&self, index: Ref<QModelIndex>) -> String {
        let item = self.table_model.item_from_index(index);
        let definition = &self.get_ref_table_definition().clone();
        match definition.get_fields_processed()[index.column() as usize].get_ref_field_type() {
            FieldType::Boolean => if let CheckState::Checked = item.check_state() { "true".to_owned() } else { "false".to_owned() },
            // Floats need to be tweaked to fix trailing zeroes and precision issues, like turning 0.5000004 into 0.5.
            FieldType::F32 => {
                let data_str = format!("{}", item.data_1a(2).to_float_0a());
                // If we have more than 3 decimals, we limit it to three, then do magic to remove trailing zeroes.
                if let Some(position) = data_str.find('.') {
                    let decimals = &data_str[position..].len();
                    if *decimals > 4 { format!("{}", format!("{:.4}", item.data_1a(2).to_float_0a()).parse::<f32>().unwrap()) }
                    else { data_str }
                }
                else { data_str }
            },
            // Floats need to be tweaked to fix trailing zeroes and precision issues, like turning 0.5000004 into 0.5.
            FieldType::F64 => {
                let data_str = format!("{}", item.data_1a(2).to_float_0a());
                // If we have more than 3 decimals, we limit it to three, then do magic to remove trailing zeroes.
                if let Some(position) = data_str.find('.') {
                    let decimals = &data_str[position..].len();
                    if *decimals > 4 { format!("{}", format!("{:.4}", item.data_1a(2).to_double_0a()).parse::<f64>().unwrap()) }
                    else { data_str }
                }
                else { data_str }
            },
            FieldType::I16 |
            FieldType::I32 |
            FieldType::I64 => format!("{}", item.data_1a(2).to_long_long_0a()),
            FieldType::ColourRGB => format!("\"{}\"", item.text().to_std_string().escape_default().to_string()),
            // All these are Strings, so they need to escape certain chars and include commas in Lua.
            FieldType::StringU8 |
            FieldType::StringU16 |
            FieldType::OptionalStringU8 |
            FieldType::OptionalStringU16 => format!("\"{}\"", item.text().to_std_string().escape_default().to_string()),
            FieldType::SequenceU16(_) => "\"SequenceU16\"".to_owned(),
            FieldType::SequenceU32(_) => "\"SequenceU32\"".to_owned(),
        }
    }
unsafe fn escape_string_from_index ( & self , index : Ref < QModelIndex > ) -> String { let item = self . table_model . item_from_index ( index ) ; let definition = & self . get_ref_table_definition ( ) . clone ( ) ; match definition . get_fields_processed ( ) [ index . column ( ) as usize ] . get_ref_field_type ( ) { FieldType :: Boolean => if let CheckState :: Checked = item . check_state ( ) { " " . to_owned ( ) } else { " " . to_owned ( ) } , // Floats need to be tweaked to fix trailing zeroes and precision issues, like turning 0.5000004 into 0.5. FieldType :: F32 => { let data_str = format ! ( " " item data_1a ( 2 ) to_float_0a ( ) ) ; // If we have more than 3 decimals, we limit it to three, then do magic to remove trailing zeroes. if let Some ( position ) = data_str . find ( '.' ) { let decimals = & data_str [ position .. ] . len ( ) ; if * decimals > 4 { format ! ( " " format ( " " item data_1a ( 2 ) to_float_0a ( ) ) parse f32 ( ) unwrap ( ) ) } else { data_str } } else { data_str } } , // Floats need to be tweaked to fix trailing zeroes and precision issues, like turning 0.5000004 into 0.5. FieldType :: F64 => { let data_str = format ! ( " " item data_1a ( 2 ) to_float_0a ( ) ) ; // If we have more than 3 decimals, we limit it to three, then do magic to remove trailing zeroes. if let Some ( position ) = data_str . find ( '.' ) { let decimals = & data_str [ position .. ] . len ( ) ; if * decimals > 4 { format ! ( " " format ( " " item data_1a ( 2 ) to_double_0a ( ) ) parse f64 ( ) unwrap ( ) ) } else { data_str } } else { data_str } } , FieldType :: I16 | FieldType :: I32 | FieldType :: I64 => format ! ( " " item data_1a ( 2 ) to_long_long_0a ( ) ) , FieldType :: ColourRGB => format ! ( " \" \" " item text ( ) to_std_string ( ) escape_default ( ) to_string ( ) ) , // All these are Strings, so they need to escape certain chars and include commas in Lua. FieldType :: StringU8 | FieldType :: StringU16 | FieldType :: OptionalStringU8 | FieldType :: OptionalStringU16 => format ! ( " \" \" " item text ( ) to_std_string ( ) escape_default ( ) to_string ( ) ) , FieldType :: SequenceU16 ( _ ) => " \" \" " . to_owned ( ) , FieldType :: SequenceU32 ( _ ) => " \" \" " . to_owned ( ) , } }
This function escapes the value inside an index.
This function escapes the value inside an index .
&self
index
Ref<QModelIndex>
&self
index
Ref<QModelIndex>