From 2ede5e0e5f6edb228c9054950df807025dbdbbfd Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Fri, 12 May 2023 16:17:14 +0600 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B1=D0=B0=D0=B3=20=D1=81=20treeView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-bootloader.cc | 59 +++++++++++++++---------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index 9a911d3..b7b8ee4 100755 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -230,10 +230,8 @@ void MainWindow::item_selected_kernel(const Gtk::TreeModel::Path&, const Gtk::Tr treeViewMelody->get_selection()->unselect_all(); if (flag_blocked_tree_view == false) { string str_flags = template_item_selected(size_kernel, list_store_kernel, "GRUB_CMDLINE_LINUX"); - Utils::str_replace_all(str_flags, " \"", "\""); - Utils::str_replace_all(str_flags, "\"", ""); map_cmd_selection["GRUB_CMDLINE_LINUX"] = str_flags; - Utils::str_replace_all(str_flags, " ", ", "); + // Utils::str_replace_all(str_flags, " ", ", "); entryKernel->set_text(str_flags); } } @@ -245,10 +243,8 @@ void MainWindow::item_selected_OTT(const Gtk::TreeModel::Path&, const Gtk::TreeM treeViewMelody->get_selection()->unselect_all(); if (flag_blocked_tree_view == false) { string str_flags = template_item_selected(size_OTT, list_store_OTT, "GRUB_TERMINAL_OUTPUT"); - Utils::str_replace_all(str_flags, " \"", "\""); - Utils::str_replace_all(str_flags, "\"", ""); map_cmd_selection["GRUB_TERMINAL_OUTPUT"] = str_flags; - Utils::str_replace_all(str_flags, " ", ", "); + // Utils::str_replace_all(str_flags, " ", ", "); entryOTT->set_text(str_flags); } } @@ -260,10 +256,8 @@ void MainWindow::item_selected_IPT(const Gtk::TreeModel::Path&, const Gtk::TreeM treeViewMelody->get_selection()->unselect_all(); if (flag_blocked_tree_view == false) { string str_flags = template_item_selected(size_IPT, list_store_IPT, "GRUB_TERMINAL_INPUT"); - Utils::str_replace_all(str_flags, " \"", "\""); - Utils::str_replace_all(str_flags, "\"", ""); map_cmd_selection["GRUB_TERMINAL_INPUT"] = str_flags; - Utils::str_replace_all(str_flags, " ", ", "); + // Utils::str_replace_all(str_flags, " ", ", "); entryIPT->set_text(str_flags); } } @@ -322,27 +316,33 @@ void MainWindow::set_download_mode() { } string MainWindow::template_item_selected(int size, Glib::RefPtr &list_store, string key) { - string cmds = map_cmd_selection[key]; - Utils::str_replace_all(cmds, "\"", ""); + string cmds_old = map_cmd_selection[key]; + string cmds = ""; + string param = ""; + vector vec_param = Utils::split(cmds_old, ' '); for (int index = 0; index < size; index++) { Gtk::TreeModel::Row row = list_store->children()[index]; if(row) { - string param = row[m_columns.name] + ""; - if (row[m_columns.check_button] == true && cmds.find(param) == string::npos) { - cmds += " " + param + " "; + param = row[m_columns.name] + ""; + if (row[m_columns.check_button] == true) { + cmds += param + " "; } - if (row[m_columns.check_button] == false && cmds.find(param) != string::npos) { - Utils::str_remove(cmds, param); + for (size_t i = 0; i < vec_param.size(); i++) { + // cout << (param == vec_param[i]) << " " << param << " " << vec_param[i] << endl; + if (param == vec_param[i]) { + vec_param.erase(vec_param.begin() + i); + } } } } - Utils::str_replace_all(cmds, " ", " "); - if (cmds.length() > 0) { - if (cmds[0] == ' ') { - cmds = cmds.substr(1, cmds.length() - 1); + for (size_t i = 0; i < vec_param.size(); i++) { + cmds += vec_param[i] + " "; + } + if (cmds.length() > 1) { + if (cmds[cmds.length()-1] == ' ') { + cmds = cmds.substr(0, cmds.length() - 1); } } - cmds = "\"" + cmds + "\""; return cmds; } @@ -540,23 +540,20 @@ void MainWindow::set_entry_to_tree_view(Glib::RefPtr &list_store flag_blocked_tree_view = true; vector vec_params; std::string text = entry.get_text(); - Utils::str_replace_all(text, " ", ""); - vec_params = Utils::split(text, ','); + // Utils::str_replace_all(text, " ", ""); + vec_params = Utils::split(text, ' '); for (auto &name: vec_Option) { this->set_row(list_store, size, name, false); } for (auto &name: vec_params) { this->set_row(list_store, size, name, true); } - Utils::str_replace_all(text, ",", " "); + // Utils::str_replace_all(text, ",", " "); if (text.length() > 0) { if (text[0] == ' ') { text = text.substr(1, text.length() - 1); } } - if (text.find("\"") == string::npos && text.length() != 0) { - text = "\"" + text + "\""; - } map_cmd_selection[key] = text; } @@ -1011,15 +1008,15 @@ void MainWindow::wrapper_save_local_cfg() { void MainWindow::set_data_cfg() { string str_flags = entryKernel->get_text(); - Utils::str_remove(str_flags, ","); + // Utils::str_remove(str_flags, ","); Utils::str_replace_all(str_flags, " \"", "\""); map_cmd_selection["GRUB_CMDLINE_LINUX"] = str_flags; str_flags = entryIPT->get_text(); - Utils::str_remove(str_flags, ","); + // Utils::str_remove(str_flags, ","); Utils::str_replace_all(str_flags, " \"", "\""); map_cmd_selection["GRUB_TERMINAL_INPUT"] = str_flags; str_flags = entryOTT->get_text(); - Utils::str_remove(str_flags, ","); + // Utils::str_remove(str_flags, ","); Utils::str_replace_all(str_flags, " \"", "\""); map_cmd_selection["GRUB_TERMINAL_OUTPUT"] = str_flags; if (chbLoadVariantSelectionTimer->get_active()) { @@ -1095,7 +1092,7 @@ void MainWindow::set_entry(Gtk::Entry* entry, std::map &map_temp if (map_temp.find(key) != map_temp.end()) { string value = map_temp[key]; Utils::str_replace_all(value, "\"", ""); - Utils::str_replace_all(value, " ", ", "); + // Utils::str_replace_all(value, " ", ", "); entry->set_text(value); } else {