pub unsafe fn load_add_faction_dialog(&self) -> Result<()> {
        self.new_faction_button_box.button(q_dialog_button_box::StandardButton::Ok).set_enabled(false);
        self.new_faction_name_combobox.set_model(&self.unit_variants_colours_faction_combobox.model());

        let dialog: QPtr<QDialog> = self.new_faction_widget.static_downcast();
        if dialog.exec() == 1 {

            // Save whatever is selected. Do it through selection to avoid double saving breaking things.
            self.faction_list_view.selection_model().select_q_item_selection_q_flags_selection_flag(&self.faction_list_view.selection_model().selection(), SelectionFlag::Toggle.into());

            // Clone the source faction, updating its relevant keys in the process.
            let new_faction_name = self.new_faction_name_combobox.current_text();
            let new_item = QStandardItem::from_q_string(&new_faction_name).into_ptr();

            // Perform the needed edits to the data, so it uses the new faction key.
            let mut data: HashMap<String, String> = HashMap::new();

            let unit_variants_colours_definition = Tool::get_table_definition("unit_variants_colours_tables")?;
            let unit_variants_definition = Tool::get_table_definition("unit_variants_tables")?;
            let variants_definition = Tool::get_table_definition("variants_tables")?;

            data.insert("unit_variants_colours_definition".to_owned(), serde_json::to_string(&unit_variants_colours_definition).unwrap());
            data.insert("unit_variants_definition".to_owned(), serde_json::to_string(&unit_variants_definition).unwrap());
            data.insert("variants_definition".to_owned(), serde_json::to_string(&variants_definition).unwrap());

            new_item.set_data_2a(&QVariant::from_q_string(&QString::from_std_str(&serde_json::to_string(&data).unwrap())), UNIT_DATA);

            // Append the new item.
            self.faction_list_model.append_row_q_standard_item(new_item);
            let new_index = self.faction_list_model.index_from_item(new_item);

            // Clear the filters (just in case) and open the new faction.
            self.get_ref_faction_list_filter_line_edit().clear();
            self.get_ref_faction_list_filter().sort_2a(0, SortOrder::AscendingOrder);
            self.get_ref_faction_list_view().set_current_index(&self.get_ref_faction_list_filter().map_from_source(&new_index));
        }

        Ok(())
    }
/// Function to load the `Add Faction` dialog.
Function to load the `Add Faction` dialog.
Function to load the ` Add Faction ` dialog .
pub unsafe fn load_add_faction_dialog(&self) -> Result<()> {
        self.new_faction_button_box.button(q_dialog_button_box::StandardButton::Ok).set_enabled(false);
        self.new_faction_name_combobox.set_model(&self.unit_variants_colours_faction_combobox.model());
        let dialog: QPtr<QDialog> = self.new_faction_widget.static_downcast();
        if dialog.exec() == 1 {
            // Save whatever is selected. Do it through selection to avoid double saving breaking things.
            self.faction_list_view.selection_model().select_q_item_selection_q_flags_selection_flag(&self.faction_list_view.selection_model().selection(), SelectionFlag::Toggle.into());
            // Clone the source faction, updating its relevant keys in the process.
            let new_faction_name = self.new_faction_name_combobox.current_text();
            let new_item = QStandardItem::from_q_string(&new_faction_name).into_ptr();
            // Perform the needed edits to the data, so it uses the new faction key.
            let mut data: HashMap<String, String> = HashMap::new();
            let unit_variants_colours_definition = Tool::get_table_definition("unit_variants_colours_tables")?;
            let unit_variants_definition = Tool::get_table_definition("unit_variants_tables")?;
            let variants_definition = Tool::get_table_definition("variants_tables")?;
            data.insert("unit_variants_colours_definition".to_owned(), serde_json::to_string(&unit_variants_colours_definition).unwrap());
            data.insert("unit_variants_definition".to_owned(), serde_json::to_string(&unit_variants_definition).unwrap());
            data.insert("variants_definition".to_owned(), serde_json::to_string(&variants_definition).unwrap());
            new_item.set_data_2a(&QVariant::from_q_string(&QString::from_std_str(&serde_json::to_string(&data).unwrap())), UNIT_DATA);
            // Append the new item.
            self.faction_list_model.append_row_q_standard_item(new_item);
            let new_index = self.faction_list_model.index_from_item(new_item);
            // Clear the filters (just in case) and open the new faction.
            self.get_ref_faction_list_filter_line_edit().clear();
            self.get_ref_faction_list_filter().sort_2a(0, SortOrder::AscendingOrder);
            self.get_ref_faction_list_view().set_current_index(&self.get_ref_faction_list_filter().map_from_source(&new_index));
        }
        Ok(())
    }
pub unsafe fn load_add_faction_dialog ( & self ) -> Result < ( ) > { self . new_faction_button_box . button ( q_dialog_button_box :: StandardButton :: Ok ) . set_enabled ( false ) ; self . new_faction_name_combobox . set_model ( & self . unit_variants_colours_faction_combobox . model ( ) ) ; let dialog : QPtr < QDialog > = self . new_faction_widget . static_downcast ( ) ; if dialog . exec ( ) == 1 { // Save whatever is selected. Do it through selection to avoid double saving breaking things. self . faction_list_view . selection_model ( ) . select_q_item_selection_q_flags_selection_flag ( & self . faction_list_view . selection_model ( ) . selection ( ) , SelectionFlag :: Toggle . into ( ) ) ; // Clone the source faction, updating its relevant keys in the process. let new_faction_name = self . new_faction_name_combobox . current_text ( ) ; let new_item = QStandardItem :: from_q_string ( & new_faction_name ) . into_ptr ( ) ; // Perform the needed edits to the data, so it uses the new faction key. let mut data : HashMap < String , String > = HashMap :: new ( ) ; let unit_variants_colours_definition = Tool :: get_table_definition ( " " ) ? ; let unit_variants_definition = Tool :: get_table_definition ( " " ) ? ; let variants_definition = Tool :: get_table_definition ( " " ) ? ; data . insert ( " " . to_owned ( ) , serde_json :: to_string ( & unit_variants_colours_definition ) . unwrap ( ) ) ; data . insert ( " " . to_owned ( ) , serde_json :: to_string ( & unit_variants_definition ) . unwrap ( ) ) ; data . insert ( " " . to_owned ( ) , serde_json :: to_string ( & variants_definition ) . unwrap ( ) ) ; new_item . set_data_2a ( & QVariant :: from_q_string ( & QString :: from_std_str ( & serde_json :: to_string ( & data ) . unwrap ( ) ) ) , UNIT_DATA ) ; // Append the new item. self . faction_list_model . append_row_q_standard_item ( new_item ) ; let new_index = self . faction_list_model . index_from_item ( new_item ) ; // Clear the filters (just in case) and open the new faction. self . get_ref_faction_list_filter_line_edit ( ) . clear ( ) ; self . get_ref_faction_list_filter ( ) . sort_2a ( 0 , SortOrder :: AscendingOrder ) ; self . get_ref_faction_list_view ( ) . set_current_index ( & self . get_ref_faction_list_filter ( ) . map_from_source ( & new_index ) ) ; } Ok ( ( ) ) }
Function to load the `Add Faction` dialog.
Function to load the ` Add Faction ` dialog .
&self
&self