Исправил баг с treeView

pull/27/head
Igor Belitskiy 3 years ago
parent 6c798d1eb6
commit 2ede5e0e5f

@ -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<Gtk::ListStore> &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<string> 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 + " ";
}
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);
}
if (row[m_columns.check_button] == false && cmds.find(param) != string::npos) {
Utils::str_remove(cmds, param);
}
}
}
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<Gtk::ListStore> &list_store
flag_blocked_tree_view = true;
vector<string> 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<string, string> &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 {

Loading…
Cancel
Save