pub unsafe fn open_variant_editor(&self) -> Result<()> {
        let selection = self.unit_list_view.selection_model().selection();
        let filter_index = selection.take_at(0).indexes().take_at(0);
        let index = self.get_ref_unit_list_filter().map_to_source(filter_index.as_ref());

        let mut data: HashMap<String, String> = serde_json::from_str(&index.data_1a(UNIT_DATA).to_string().to_std_string()).unwrap();
        let variant_data: HashMap<String, String> = data.iter().filter_map(|(key, val)|
            if key.starts_with("unit_variants_colours") ||
                key.starts_with("unit_variants") ||
                key.starts_with("variants") {
                Some((key.to_owned(), val.to_owned()))
            } else { None }
        ).collect();

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

        let new_data = SubToolVariantUnitEditor::new(self.tool.get_ref_main_widget().as_ref().unwrap(), &variant_data)?;
        if let Some(new_data) = new_data {
            if cfg!(debug_assertions) {
                log::info!("{:#?}", new_data.iter().sorted_by_key(|x| x.0).collect::<std::collections::BTreeMap<&String, &String>>());
            }

            // Delete old variant entries before re-adding them.
            data = data.iter().filter_map(|(key, val)|
                if !key.starts_with("unit_variants_colours") &&
                    !key.starts_with("unit_variants") &&
                    !key.starts_with("variants") {
                    Some((key.to_owned(), val.to_owned()))
                } else { None }
            ).collect();

            data.extend(new_data);
            self.unit_list_model.item_from_index(index.as_ref()).set_data_2a(&QVariant::from_q_string(&QString::from_std_str(&serde_json::to_string(&data).unwrap())), UNIT_DATA);
        }

        Ok(())
    }
/// Function to load the `Variant Editor` dialog.
Function to load the `Variant Editor` dialog.
Function to load the ` Variant Editor ` dialog .
pub unsafe fn open_variant_editor(&self) -> Result<()> {
        let selection = self.unit_list_view.selection_model().selection();
        let filter_index = selection.take_at(0).indexes().take_at(0);
        let index = self.get_ref_unit_list_filter().map_to_source(filter_index.as_ref());
        let mut data: HashMap<String, String> = serde_json::from_str(&index.data_1a(UNIT_DATA).to_string().to_std_string()).unwrap();
        let variant_data: HashMap<String, String> = data.iter().filter_map(|(key, val)|
            if key.starts_with("unit_variants_colours") ||
                key.starts_with("unit_variants") ||
                key.starts_with("variants") {
                Some((key.to_owned(), val.to_owned()))
            } else { None }
        ).collect();
        // Log in debug mode, for debugging.
        if cfg!(debug_assertions) {
            log::info!("{:#?}", variant_data.iter().sorted_by_key(|x| x.0).collect::<std::collections::BTreeMap<&String, &String>>());
        }
        let new_data = SubToolVariantUnitEditor::new(self.tool.get_ref_main_widget().as_ref().unwrap(), &variant_data)?;
        if let Some(new_data) = new_data {
            if cfg!(debug_assertions) {
                log::info!("{:#?}", new_data.iter().sorted_by_key(|x| x.0).collect::<std::collections::BTreeMap<&String, &String>>());
            }
            // Delete old variant entries before re-adding them.
            data = data.iter().filter_map(|(key, val)|
                if !key.starts_with("unit_variants_colours") &&
                    !key.starts_with("unit_variants") &&
                    !key.starts_with("variants") {
                    Some((key.to_owned(), val.to_owned()))
                } else { None }
            ).collect();
            data.extend(new_data);
            self.unit_list_model.item_from_index(index.as_ref()).set_data_2a(&QVariant::from_q_string(&QString::from_std_str(&serde_json::to_string(&data).unwrap())), UNIT_DATA);
        }
        Ok(())
    }
pub unsafe fn open_variant_editor ( & self ) -> Result < ( ) > { let selection = self . unit_list_view . selection_model ( ) . selection ( ) ; let filter_index = selection . take_at ( 0 ) . indexes ( ) . take_at ( 0 ) ; let index = self . get_ref_unit_list_filter ( ) . map_to_source ( filter_index . as_ref ( ) ) ; let mut data : HashMap < String , String > = serde_json :: from_str ( & index . data_1a ( UNIT_DATA ) . to_string ( ) . to_std_string ( ) ) . unwrap ( ) ; let variant_data : HashMap < String , String > = data . iter ( ) . filter_map ( | ( key , val ) | if key . starts_with ( " " ) || key . starts_with ( " " ) || key . starts_with ( " " ) { Some ( ( key . to_owned ( ) , val . to_owned ( ) ) ) } else { None } ) . collect ( ) ; // Log in debug mode, for debugging. if cfg ! ( debug_assertions ) { log :: info ! ( " " variant_data iter ( ) sorted_by_key ( x x 0 ) collect std collections BTreeMap String String ( ) ) ; } let new_data = SubToolVariantUnitEditor :: new ( self . tool . get_ref_main_widget ( ) . as_ref ( ) . unwrap ( ) , & variant_data ) ? ; if let Some ( new_data ) = new_data { if cfg ! ( debug_assertions ) { log :: info ! ( " " new_data iter ( ) sorted_by_key ( x x 0 ) collect std collections BTreeMap String String ( ) ) ; } // Delete old variant entries before re-adding them. data = data . iter ( ) . filter_map ( | ( key , val ) | if ! key . starts_with ( " " ) && ! key . starts_with ( " " ) && ! key . starts_with ( " " ) { Some ( ( key . to_owned ( ) , val . to_owned ( ) ) ) } else { None } ) . collect ( ) ; data . extend ( new_data ) ; self . unit_list_model . item_from_index ( index . as_ref ( ) ) . set_data_2a ( & QVariant :: from_q_string ( & QString :: from_std_str ( & serde_json :: to_string ( & data ) . unwrap ( ) ) ) , UNIT_DATA ) ; } Ok ( ( ) ) }
Function to load the `Variant Editor` dialog.
Function to load the ` Variant Editor ` dialog .
&self
&self