pub unsafe fn save_data(&self) -> Result<HashMap<String, String>> {

        // First, save whatever is currently open in the detailed view.
        self.faction_list_view.selection_model().select_q_item_selection_q_flags_selection_flag(&self.faction_list_view.selection_model().selection(), SelectionFlag::Toggle.into());

        // Get each faction's data as a HashMap of data/value.
        let data_to_save = (0..self.faction_list_model.row_count_0a())
            .map(|row| {
                let index = self.faction_list_model.index_2a(row, 0);
                let data = self.faction_list_model.data_2a(&index, UNIT_DATA);
                let data: HashMap<String, String> = serde_json::from_str(&data.to_string().to_std_string()).unwrap();

                let faction_key = self.faction_list_model.data_1a(&index).to_string().to_std_string();
                let data = data.iter().map(|(key, value)| {
                    let key = if !key.ends_with("_definition") { format!("{}|{}", key, &faction_key) } else { key.to_owned() };
                    (key, value.to_owned())
                }).collect::<HashMap<String, String>>();

                data
            })
            .flatten()
            .collect::<HashMap<String, String>>();

       Ok(data_to_save)
    }
/// This function takes care of saving the data of this Tool into the currently open PackFile, creating a new one if there wasn't one open.
This function takes care of saving the data of this Tool into the currently open PackFile, creating a new one if there wasn't one open.
This function takes care of saving the data of this Tool into the currently open PackFile creating a new one if there wasn ' t one open .
pub unsafe fn save_data(&self) -> Result<HashMap<String, String>> {
        // First, save whatever is currently open in the detailed view.
        self.faction_list_view.selection_model().select_q_item_selection_q_flags_selection_flag(&self.faction_list_view.selection_model().selection(), SelectionFlag::Toggle.into());
        // Get each faction's data as a HashMap of data/value.
        let data_to_save = (0..self.faction_list_model.row_count_0a())
            .map(|row| {
                let index = self.faction_list_model.index_2a(row, 0);
                let data = self.faction_list_model.data_2a(&index, UNIT_DATA);
                let data: HashMap<String, String> = serde_json::from_str(&data.to_string().to_std_string()).unwrap();
                let faction_key = self.faction_list_model.data_1a(&index).to_string().to_std_string();
                let data = data.iter().map(|(key, value)| {
                    let key = if !key.ends_with("_definition") { format!("{}|{}", key, &faction_key) } else { key.to_owned() };
                    (key, value.to_owned())
                }).collect::<HashMap<String, String>>();
                data
            })
            .flatten()
            .collect::<HashMap<String, String>>();
       Ok(data_to_save)
    }
pub unsafe fn save_data ( & self ) -> Result < HashMap < String , String > > { // First, save whatever is currently open in the detailed view. self . faction_list_view . selection_model ( ) . select_q_item_selection_q_flags_selection_flag ( & self . faction_list_view . selection_model ( ) . selection ( ) , SelectionFlag :: Toggle . into ( ) ) ; // Get each faction's data as a HashMap of data/value. let data_to_save = ( 0 .. self . faction_list_model . row_count_0a ( ) ) . map ( | row | { let index = self . faction_list_model . index_2a ( row , 0 ) ; let data = self . faction_list_model . data_2a ( & index , UNIT_DATA ) ; let data : HashMap < String , String > = serde_json :: from_str ( & data . to_string ( ) . to_std_string ( ) ) . unwrap ( ) ; let faction_key = self . faction_list_model . data_1a ( & index ) . to_string ( ) . to_std_string ( ) ; let data = data . iter ( ) . map ( | ( key , value ) | { let key = if ! key . ends_with ( " " ) { format ! ( " " key faction_key ) } else { key . to_owned ( ) } ; ( key , value . to_owned ( ) ) } ) . collect :: < HashMap < String , String > > ( ) ; data } ) . flatten ( ) . collect :: < HashMap < String , String > > ( ) ; Ok ( data_to_save ) }
This function takes care of saving the data of this Tool into the currently open PackFile, creating a new one if there wasn't one open.
This function takes care of saving the data of this Tool into the currently open PackFile creating a new one if there wasn ' t one open .
&self
&self