Добавил сортировк зон

pull/46/head
Igor Belitskiy 3 years ago
parent df0d0af3ee
commit e3c225dbf1

@ -338,7 +338,6 @@ bool MainWindow::focus_ntp(GdkEventFocus* event){
string str_ntp = txtNtpServer->get_text();
for (const auto &simvol: array_simvol){
if (str_ntp.find(simvol)!=std::string::npos){
cout << simvol << 2222 << endl;
flag_error=true;
break;
@ -450,7 +449,6 @@ void MainWindow::calendar_show(){
void MainWindow::enry_dhcp_mess(){
string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS");
cout << str_dhcp << endl;
if (str_dhcp.find("(null)")==std::string::npos){
cbxSynchronizeNtpGlob->set_active(true);
@ -843,6 +841,7 @@ void MainWindow::read_file(){
}
in1.close();
}
this->sort_zone(&zone_local, &zone);
time_reg_map.insert({key_reg, zone});
time_reg_map_local.insert({key_reg, zone_local});
}}}}
@ -852,6 +851,56 @@ void MainWindow::read_file(){
}
}
void MainWindow::sort_zone(vector<string> *time_reg_map_local,vector<string> *time_reg_map){
string str_j = "";
int j_i;
string str_j_1 = "";
int j_i_1;
int size_vec = time_reg_map_local->size();
for (int i = 0; i < size_vec; i++) {
for (int j = 0; j < size_vec-1; j++) {
str_j=(*time_reg_map_local)[j];
str_j = str_j.substr(5,str_j.find(")")-5);
if (str_j[1]=='0'){
str_j.replace(1,1,"0");
}
if (str_j.find("+") != std::string::npos){
str_j.replace(0,1,"+");
j_i = stoi(str_j);
}
else{
str_j.replace(0,1,"-");
j_i = stoi(str_j);
j_i=-j_i;
}
str_j_1=(*time_reg_map_local)[j+1];
str_j_1 = str_j_1.substr(5,str_j_1.find(")")-5);
if (str_j_1[1]=='0'){
str_j_1.replace(1,1,"0");
}
if (str_j_1.find("+") != std::string::npos){
str_j_1.replace(0,1,"+");
j_i_1 = stoi(str_j_1);
}
else{
str_j_1.replace(0,1,"-");
j_i_1 = stoi(str_j_1);
j_i_1 = -j_i_1;
}
if (j_i > j_i_1) {
string b = (*time_reg_map_local)[j];
(*time_reg_map_local)[j] = (*time_reg_map_local)[j + 1];
(*time_reg_map_local)[j + 1] = b;
b = (*time_reg_map)[j];
(*time_reg_map)[j] = (*time_reg_map)[j + 1];
(*time_reg_map)[j + 1] = b;
}
}
}
}
string MainWindow::zone_file_read(string zone){
if (zone.length()==1){
return "";

@ -72,6 +72,7 @@ class MainWindow : public Gtk::ApplicationWindow {
void wind_close_ntp();
void wrapper_update_time_date();
string zone_file_read(string zone);
void sort_zone(vector<string> *time_reg_map_local,vector<string> *time_reg_map);
array<string, 2> split_region_zone(string read_reg_zon_cfg);
string str_remove(std::string& source, const std::string to_remove);
vector<std::string> split(const std::string &s, char delim);

@ -1609,3 +1609,6 @@ msgstr "Южная Нижняя Калифорния"
msgid "Enter the name of the ntp-server or its ip-address.\nWhen entering multiple addresses, separate them with commas."
msgstr "Введите имя ntp-сервера или его ip-адрес.\nПри вводе нескольких адресов, разделяйте их запятыми."
msgid "Cape_Verde"
msgstr "Кабо-Верде"

Loading…
Cancel
Save