pub unsafe fn save_unit_variants_colours(&self, data: &mut HashMap<String, String>) {

        // Save the currently selected colour variant.
        self.unit_variants_colours_list_view.selection_model().select_q_item_selection_q_flags_selection_flag(&self.unit_variants_colours_list_view.selection_model().selection(), SelectionFlag::Toggle.into());

        // Remove all old entries here, before we pull them from the UI.
        data.retain(|key, _| !key.starts_with("unit_variants_colours_"));

        // Get the new entries from the ListView.
        let mut new_entries = HashMap::new();
        for index in 0..self.unit_variants_colours_list_model.row_count_0a() {
            let index = self.unit_variants_colours_list_model.index_2a(index, 0);
            let mut entry_data: HashMap<String, String> = serde_json::from_str(&index.data_1a(UNIT_DATA).to_string().to_std_string()).unwrap();
            let item_name = index.data_0a().to_string().to_std_string();
            let mapped_entry = entry_data.iter_mut().map(|(key, value)| {
                if key.ends_with("_definition") {
                    (key.to_owned(), value.to_owned())
                } else {
                    (format!("{}|{}", key, item_name), value.to_owned())
                }
            }).collect::<HashMap<String, String>>();
            new_entries.extend(mapped_entry);
        }

        data.extend(new_entries);

        // Clear the color variant list.
        self.unit_variants_colours_list_model.clear();
    }
/// This function saves the unit_variants_colours entries from a listview into our faction entries.
This function saves the unit_variants_colours entries from a listview into our faction entries.
This function saves the unit_variants_colours entries from a listview into our faction entries .
pub unsafe fn save_unit_variants_colours(&self, data: &mut HashMap<String, String>) {
        // Save the currently selected colour variant.
        self.unit_variants_colours_list_view.selection_model().select_q_item_selection_q_flags_selection_flag(&self.unit_variants_colours_list_view.selection_model().selection(), SelectionFlag::Toggle.into());
        // Remove all old entries here, before we pull them from the UI.
        data.retain(|key, _| !key.starts_with("unit_variants_colours_"));
        // Get the new entries from the ListView.
        let mut new_entries = HashMap::new();
        for index in 0..self.unit_variants_colours_list_model.row_count_0a() {
            let index = self.unit_variants_colours_list_model.index_2a(index, 0);
            let mut entry_data: HashMap<String, String> = serde_json::from_str(&index.data_1a(UNIT_DATA).to_string().to_std_string()).unwrap();
            let item_name = index.data_0a().to_string().to_std_string();
            let mapped_entry = entry_data.iter_mut().map(|(key, value)| {
                if key.ends_with("_definition") {
                    (key.to_owned(), value.to_owned())
                } else {
                    (format!("{}|{}", key, item_name), value.to_owned())
                }
            }).collect::<HashMap<String, String>>();
            new_entries.extend(mapped_entry);
        }
        data.extend(new_entries);
        // Clear the color variant list.
        self.unit_variants_colours_list_model.clear();
    }
pub unsafe fn save_unit_variants_colours ( & self , data : & mut HashMap < String , String > ) { // Save the currently selected colour variant. self . unit_variants_colours_list_view . selection_model ( ) . select_q_item_selection_q_flags_selection_flag ( & self . unit_variants_colours_list_view . selection_model ( ) . selection ( ) , SelectionFlag :: Toggle . into ( ) ) ; // Remove all old entries here, before we pull them from the UI. data . retain ( | key , _ | ! key . starts_with ( " " ) ) ; // Get the new entries from the ListView. let mut new_entries = HashMap :: new ( ) ; for index in 0 .. self . unit_variants_colours_list_model . row_count_0a ( ) { let index = self . unit_variants_colours_list_model . index_2a ( index , 0 ) ; let mut entry_data : HashMap < String , String > = serde_json :: from_str ( & index . data_1a ( UNIT_DATA ) . to_string ( ) . to_std_string ( ) ) . unwrap ( ) ; let item_name = index . data_0a ( ) . to_string ( ) . to_std_string ( ) ; let mapped_entry = entry_data . iter_mut ( ) . map ( | ( key , value ) | { if key . ends_with ( " " ) { ( key . to_owned ( ) , value . to_owned ( ) ) } else { ( format ! ( " " key item_name ) , value . to_owned ( ) ) } } ) . collect :: < HashMap < String , String > > ( ) ; new_entries . extend ( mapped_entry ) ; } data . extend ( new_entries ) ; // Clear the color variant list. self . unit_variants_colours_list_model . clear ( ) ; }
This function saves the unit_variants_colours entries from a listview into our faction entries.
This function saves the unit_variants_colours entries from a listview into our faction entries .
&self
data
&mut HashMap<String, String>
&self
data
&mut HashMap<String, String>