pub unsafe fn save_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![];

        //-----------------------------------------------------------------------//
        // unit_variants_colours_tables
        //
        // This one may contain multiple entries for each faction, so we have to
        // parse them before anything else, and map them to `key|faction` (* for
        // empty faction).
        //-----------------------------------------------------------------------//
        self.save_unit_variants_colours(&mut data);

        //-----------------------------------------------------------------------//
        // variants_tables
        //-----------------------------------------------------------------------//
        if let Err(error) = self.tool.save_definition_from_detailed_view_editor(&mut data, "variants", &VARIANTS_CUSTOM_FIELDS) {
            errors.push(error.to_string());
        }

        //-----------------------------------------------------------------------//
        // unit_variants_tables
        //-----------------------------------------------------------------------//
        if let Err(error) = self.tool.save_definition_from_detailed_view_editor(&mut data, "unit_variants", &UNIT_VARIANTS_CUSTOM_FIELDS) {
            errors.push(error.to_string());
        }

        self.tool.save_field_from_detailed_view_editor_combo(&mut data, &self.unit_variants_unit_card_combobox, "unit_variants_unit_card");
        self.tool.save_field_from_detailed_view_editor_combo(&mut data, &self.variants_variant_filename_combobox, "variants_variant_filename");

        // Save the variantmesh data, in case we edited.
        self.save_variant_mesh(&mut data);

        // Update all the referenced keys in our data.
        self.update_keys(&mut data);

        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.faction_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 data of the detailed view to its item in the faction list.
This function saves the data of the detailed view to its item in the faction list.
This function saves the data of the detailed view to its item in the faction list .
pub unsafe fn save_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![];
        //-----------------------------------------------------------------------//
        // unit_variants_colours_tables
        //
        // This one may contain multiple entries for each faction, so we have to
        // parse them before anything else, and map them to `key|faction` (* for
        // empty faction).
        //-----------------------------------------------------------------------//
        self.save_unit_variants_colours(&mut data);
        //-----------------------------------------------------------------------//
        // variants_tables
        //-----------------------------------------------------------------------//
        if let Err(error) = self.tool.save_definition_from_detailed_view_editor(&mut data, "variants", &VARIANTS_CUSTOM_FIELDS) {
            errors.push(error.to_string());
        }
        //-----------------------------------------------------------------------//
        // unit_variants_tables
        //-----------------------------------------------------------------------//
        if let Err(error) = self.tool.save_definition_from_detailed_view_editor(&mut data, "unit_variants", &UNIT_VARIANTS_CUSTOM_FIELDS) {
            errors.push(error.to_string());
        }
        self.tool.save_field_from_detailed_view_editor_combo(&mut data, &self.unit_variants_unit_card_combobox, "unit_variants_unit_card");
        self.tool.save_field_from_detailed_view_editor_combo(&mut data, &self.variants_variant_filename_combobox, "variants_variant_filename");
        // Save the variantmesh data, in case we edited.
        self.save_variant_mesh(&mut data);
        // Update all the referenced keys in our data.
        self.update_keys(&mut data);
        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.faction_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);
    }
pub unsafe fn save_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 ! [ ] ; //-----------------------------------------------------------------------// // unit_variants_colours_tables // // This one may contain multiple entries for each faction, so we have to // parse them before anything else, and map them to `key|faction` (* for // empty faction). //-----------------------------------------------------------------------// self . save_unit_variants_colours ( & mut data ) ; //-----------------------------------------------------------------------// // variants_tables //-----------------------------------------------------------------------// if let Err ( error ) = self . tool . save_definition_from_detailed_view_editor ( & mut data , " " , & VARIANTS_CUSTOM_FIELDS ) { errors . push ( error . to_string ( ) ) ; } //-----------------------------------------------------------------------// // unit_variants_tables //-----------------------------------------------------------------------// if let Err ( error ) = self . tool . save_definition_from_detailed_view_editor ( & mut data , " " , & UNIT_VARIANTS_CUSTOM_FIELDS ) { errors . push ( error . to_string ( ) ) ; } self . tool . save_field_from_detailed_view_editor_combo ( & mut data , & self . unit_variants_unit_card_combobox , " " ) ; self . tool . save_field_from_detailed_view_editor_combo ( & mut data , & self . variants_variant_filename_combobox , " " ) ; // Save the variantmesh data, in case we edited. self . save_variant_mesh ( & mut data ) ; // Update all the referenced keys in our data. self . update_keys ( & mut data ) ; 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 . faction_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 data of the detailed view to its item in the faction list.
This function saves the data of the detailed view to its item in the faction list .
&self
index
Ref<QModelIndex>
&self
index
Ref<QModelIndex>