mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-26 18:31:11 +00:00
Code refactoring for better maintainability
This commit is contained in:
@@ -1485,12 +1485,12 @@ std::string UnsavedChangesDialog::subreplace(std::string resource_str, std::stri
|
||||
|
||||
void UnsavedChangesDialog::update_tree(Preset::Type type, DynamicConfig * config, int from, int to)
|
||||
{
|
||||
Search::OptionsSearcher &searcher = wxGetApp().sidebar().get_searcher();
|
||||
searcher.sort_options_by_key();
|
||||
Search::SettingsIndex &index = wxGetApp().sidebar().settings_index();
|
||||
index.sort_options_by_key();
|
||||
|
||||
for (const std::string &opt_key : config->keys()) {
|
||||
int variant_index = -2;
|
||||
const Search::Option &option = searcher.get_option(opt_key, type, variant_index);
|
||||
const Search::Option &option = index.get_option(opt_key, type, variant_index);
|
||||
auto category = option.category_local;
|
||||
auto opt = dynamic_cast<ConfigOptionVectorBase*>(config->option(opt_key));
|
||||
std::string value_from = opt->vserialize()[from];
|
||||
@@ -1502,8 +1502,8 @@ void UnsavedChangesDialog::update_tree(Preset::Type type, DynamicConfig * config
|
||||
|
||||
void UnsavedChangesDialog::update_tree(Preset::Type type, PresetCollection* presets_)
|
||||
{
|
||||
Search::OptionsSearcher& searcher = wxGetApp().sidebar().get_searcher();
|
||||
searcher.sort_options_by_key();
|
||||
Search::SettingsIndex& index = wxGetApp().sidebar().settings_index();
|
||||
index.sort_options_by_key();
|
||||
|
||||
// list of the presets with unsaved changes
|
||||
std::vector<PresetCollection*> presets_list;
|
||||
@@ -1558,11 +1558,11 @@ void UnsavedChangesDialog::update_tree(Preset::Type type, PresetCollection* pres
|
||||
|
||||
for (const std::string& opt_key : dirty_options) {
|
||||
int variant_index = -2;
|
||||
const Search::Option &option = searcher.get_option(opt_key, type, variant_index);
|
||||
const Search::Option &option = index.get_option(opt_key, type, variant_index);
|
||||
if (option.opt_key() != opt_key && variant_index < -1) {
|
||||
// When founded option isn't the correct one.
|
||||
// It can be for dirty_options: "default_print_profile", "printer_model", "printer_settings_id",
|
||||
// because of they don't exist in searcher
|
||||
// because of they don't exist in the index
|
||||
continue;
|
||||
}
|
||||
auto category = option.category_local;
|
||||
@@ -1590,8 +1590,8 @@ void UnsavedChangesDialog::update_tree(Preset::Type type, PresetCollection* pres
|
||||
}
|
||||
}
|
||||
|
||||
// Revert sort of searcher back
|
||||
searcher.sort_options_by_label();
|
||||
// Revert sort of index back
|
||||
index.sort_options_by_label();
|
||||
}
|
||||
|
||||
void UnsavedChangesDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
@@ -2043,8 +2043,8 @@ void DiffPresetDialog::update_bottom_info(wxString bottom_info)
|
||||
|
||||
void DiffPresetDialog::update_tree()
|
||||
{
|
||||
Search::OptionsSearcher& searcher = wxGetApp().sidebar().get_searcher();
|
||||
searcher.sort_options_by_key();
|
||||
Search::SettingsIndex& index = wxGetApp().sidebar().settings_index();
|
||||
index.sort_options_by_key();
|
||||
|
||||
m_tree->Clear();
|
||||
wxString bottom_info = "";
|
||||
@@ -2124,14 +2124,14 @@ void DiffPresetDialog::update_tree()
|
||||
wxString right_val = get_string_value(opt_key, right_congig);
|
||||
|
||||
const std::string lookup_key = get_pure_opt_key(opt_key);
|
||||
Search::Option option = searcher.get_option(lookup_key, get_full_label(lookup_key, left_config), type);
|
||||
Search::Option option = index.get_option(lookup_key, get_full_label(lookup_key, left_config), type);
|
||||
if (get_pure_opt_key(option.opt_key()) != lookup_key)
|
||||
option = searcher.get_option(opt_key, get_full_label(opt_key, left_config), type);
|
||||
option = index.get_option(opt_key, get_full_label(opt_key, left_config), type);
|
||||
if (get_pure_opt_key(option.opt_key()) != lookup_key) {
|
||||
// When the found option is not the requested one.
|
||||
// This can happen for dirty_options such as:
|
||||
// "default_print_profile", "printer_model", "printer_settings_id",
|
||||
// because they do not exist in the searcher.
|
||||
// because they do not exist in the index.
|
||||
continue;
|
||||
}
|
||||
m_tree->Append(opt_key, type, option.category_local, option.group_local, option.label_local,
|
||||
@@ -2155,8 +2155,8 @@ void DiffPresetDialog::update_tree()
|
||||
Refresh();
|
||||
}
|
||||
|
||||
// Revert sort of searcher back
|
||||
searcher.sort_options_by_label();
|
||||
// Revert sort of index back
|
||||
index.sort_options_by_label();
|
||||
}
|
||||
|
||||
void DiffPresetDialog::on_dpi_changed(const wxRect&)
|
||||
|
||||
Reference in New Issue
Block a user