unsafe fn save_unit_variants_colours_from_detailed_view(&self, index: Ref<QModelIndex>) {
        let mut data: HashMap<String, String> = serde_json::from_str(&index.data_1a(UNIT_DATA).to_string().to_std_string()).unwrap();
        let mut errors: Vec<String> = vec![];

        // Log in debug mode, for debugging.
        if cfg!(debug_assertions) {
            log::info!("{:#?}", data.iter().sorted_by_key(|x| x.0).collect::<std::collections::BTreeMap<&String, &String>>());
        }

        if let Err(error) = self.tool.save_definition_from_detailed_view_editor(&mut data, "unit_variants_colours", &UNIT_VARIANTS_COLOURS_CUSTOM_FIELDS) {
            errors.push(error.to_string());
        }

        self.tool.save_field_from_detailed_view_editor_combo(&mut data, &self.unit_variants_colours_faction_combobox, "unit_variants_colours_faction");
        self.tool.save_field_from_detailed_view_editor_combo(&mut data, &self.unit_variants_colours_subculture_combobox, "unit_variants_colours_subculture");
        self.tool.save_field_from_detailed_view_editor_combo(&mut data, &self.unit_variants_colours_soldier_type_combobox, "unit_variants_colours_soldier_type");

        self.tool.save_fields_from_detailed_view_editor_combo_color_split(&mut data, &self.unit_variants_colours_primary_colour_combobox, "unit_variants_colours_primary_colour_r", "unit_variants_colours_primary_colour_g", "unit_variants_colours_primary_colour_b");
        self.tool.save_fields_from_detailed_view_editor_combo_color_split(&mut data, &self.unit_variants_colours_secondary_colour_combobox, "unit_variants_colours_secondary_colour_r", "unit_variants_colours_secondary_colour_g", "unit_variants_colours_secondary_colour_b");
        self.tool.save_fields_from_detailed_view_editor_combo_color_split(&mut data, &self.unit_variants_colours_tertiary_colour_combobox, "unit_variants_colours_tertiary_colour_r", "unit_variants_colours_tertiary_colour_g", "unit_variants_colours_tertiary_colour_b");

        data.insert("unit_variants_colours_key".to_owned(), index.data_0a().to_string().to_std_string());

        // If we have any errors, show them here.
        if !errors.is_empty() {
            show_message_warning(&self.tool.message_widget, errors.join("\n"));
        }

        if cfg!(debug_assertions) {
            log::info!("{:#?}", data.iter().sorted_by_key(|x| x.0).collect::<std::collections::BTreeMap<&String, &String>>());
        }

        self.unit_variants_colours_list_model.item_from_index(index).set_data_2a(&QVariant::from_q_string(&QString::from_std_str(&serde_json::to_string(&data).unwrap())), UNIT_DATA);
    }
/// This function saves the unit_variants_colours entries from the UI to a listview.
This function saves the unit_variants_colours entries from the UI to a listview.
This function saves the unit_variants_colours entries from the UI to a listview .
unsafe fn save_unit_variants_colours_from_detailed_view(&self, index: Ref<QModelIndex>) {
        let mut data: HashMap<String, String> = serde_json::from_str(&index.data_1a(UNIT_DATA).to_string().to_std_string()).unwrap();
        let mut errors: Vec<String> = vec![];
        // Log in debug mode, for debugging.
        if cfg!(debug_assertions) {
            log::info!("{:#?}", data.iter().sorted_by_key(|x| x.0).collect::<std::collections::BTreeMap<&String, &String>>());
        }
        if let Err(error) = self.tool.save_definition_from_detailed_view_editor(&mut data, "unit_variants_colours", &UNIT_VARIANTS_COLOURS_CUSTOM_FIELDS) {
            errors.push(error.to_string());
        }
        self.tool.save_field_from_detailed_view_editor_combo(&mut data, &self.unit_variants_colours_faction_combobox, "unit_variants_colours_faction");
        self.tool.save_field_from_detailed_view_editor_combo(&mut data, &self.unit_variants_colours_subculture_combobox, "unit_variants_colours_subculture");
        self.tool.save_field_from_detailed_view_editor_combo(&mut data, &self.unit_variants_colours_soldier_type_combobox, "unit_variants_colours_soldier_type");
        self.tool.save_fields_from_detailed_view_editor_combo_color_split(&mut data, &self.unit_variants_colours_primary_colour_combobox, "unit_variants_colours_primary_colour_r", "unit_variants_colours_primary_colour_g", "unit_variants_colours_primary_colour_b");
        self.tool.save_fields_from_detailed_view_editor_combo_color_split(&mut data, &self.unit_variants_colours_secondary_colour_combobox, "unit_variants_colours_secondary_colour_r", "unit_variants_colours_secondary_colour_g", "unit_variants_colours_secondary_colour_b");
        self.tool.save_fields_from_detailed_view_editor_combo_color_split(&mut data, &self.unit_variants_colours_tertiary_colour_combobox, "unit_variants_colours_tertiary_colour_r", "unit_variants_colours_tertiary_colour_g", "unit_variants_colours_tertiary_colour_b");
        data.insert("unit_variants_colours_key".to_owned(), index.data_0a().to_string().to_std_string());
        // If we have any errors, show them here.
        if !errors.is_empty() {
            show_message_warning(&self.tool.message_widget, errors.join("\n"));
        }
        if cfg!(debug_assertions) {
            log::info!("{:#?}", data.iter().sorted_by_key(|x| x.0).collect::<std::collections::BTreeMap<&String, &String>>());
        }
        self.unit_variants_colours_list_model.item_from_index(index).set_data_2a(&QVariant::from_q_string(&QString::from_std_str(&serde_json::to_string(&data).unwrap())), UNIT_DATA);
    }
unsafe fn save_unit_variants_colours_from_detailed_view ( & self , index : Ref < QModelIndex > ) { let mut data : HashMap < String , String > = serde_json :: from_str ( & index . data_1a ( UNIT_DATA ) . to_string ( ) . to_std_string ( ) ) . unwrap ( ) ; let mut errors : Vec < String > = vec ! [ ] ; // Log in debug mode, for debugging. if cfg ! ( debug_assertions ) { log :: info ! ( " " data iter ( ) sorted_by_key ( x x 0 ) collect std collections BTreeMap String String ( ) ) ; } if let Err ( error ) = self . tool . save_definition_from_detailed_view_editor ( & mut data , " " , & UNIT_VARIANTS_COLOURS_CUSTOM_FIELDS ) { errors . push ( error . to_string ( ) ) ; } self . tool . save_field_from_detailed_view_editor_combo ( & mut data , & self . unit_variants_colours_faction_combobox , " " ) ; self . tool . save_field_from_detailed_view_editor_combo ( & mut data , & self . unit_variants_colours_subculture_combobox , " " ) ; self . tool . save_field_from_detailed_view_editor_combo ( & mut data , & self . unit_variants_colours_soldier_type_combobox , " " ) ; self . tool . save_fields_from_detailed_view_editor_combo_color_split ( & mut data , & self . unit_variants_colours_primary_colour_combobox , " " , " " , " " ) ; self . tool . save_fields_from_detailed_view_editor_combo_color_split ( & mut data , & self . unit_variants_colours_secondary_colour_combobox , " " , " " , " " ) ; self . tool . save_fields_from_detailed_view_editor_combo_color_split ( & mut data , & self . unit_variants_colours_tertiary_colour_combobox , " " , " " , " " ) ; data . insert ( " " . to_owned ( ) , index . data_0a ( ) . to_string ( ) . to_std_string ( ) ) ; // If we have any errors, show them here. if ! errors . is_empty ( ) { show_message_warning ( & self . tool . message_widget , errors . join ( " \n " ) ) ; } if cfg ! ( debug_assertions ) { log :: info ! ( " " data iter ( ) sorted_by_key ( x x 0 ) collect std collections BTreeMap String String ( ) ) ; } self . unit_variants_colours_list_model . item_from_index ( index ) . set_data_2a ( & QVariant :: from_q_string ( & QString :: from_std_str ( & serde_json :: to_string ( & data ) . unwrap ( ) ) ) , UNIT_DATA ) ; }
This function saves the unit_variants_colours entries from the UI to a listview.
This function saves the unit_variants_colours entries from the UI to a listview .
&self
index
Ref<QModelIndex>
&self
index
Ref<QModelIndex>