From 6caddb51419bf3d2571715252c82782109052751 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 29 Aug 2021 20:08:47 +0300 Subject: [PATCH] Removed old code entry from country info. --- .../countries/countries_instance.cpp | 468 +++++++++--------- .../countries/countries_instance.h | 1 - .../countries/countries_manager.cpp | 5 - .../ui/boxes/country_select_box.cpp | 2 +- Telegram/SourceFiles/ui/countryinput.cpp | 2 +- 5 files changed, 237 insertions(+), 241 deletions(-) diff --git a/Telegram/SourceFiles/countries/countries_instance.cpp b/Telegram/SourceFiles/countries/countries_instance.cpp index 218c5ba1d..eb33add01 100644 --- a/Telegram/SourceFiles/countries/countries_instance.cpp +++ b/Telegram/SourceFiles/countries/countries_instance.cpp @@ -13,237 +13,237 @@ namespace { auto SingleInstance = CountriesInstance(); const std::array FallbackList = { { - { "Afghanistan", "AF", "93" }, - { "Albania", "AL", "355" }, - { "Algeria", "DZ", "213" }, - { "American Samoa", "AS", "1684" }, - { "Andorra", "AD", "376" }, - { "Angola", "AO", "244" }, - { "Anguilla", "AI", "1264" }, - { "Antigua & Barbuda", "AG", "1268" }, - { "Argentina", "AR", "54" }, - { "Armenia", "AM", "374" }, - { "Aruba", "AW", "297" }, - { "Australia", "AU", "61" }, - { "Austria", "AT", "43" }, - { "Azerbaijan", "AZ", "994" }, - { "Bahamas", "BS", "1242" }, - { "Bahrain", "BH", "973" }, - { "Bangladesh", "BD", "880" }, - { "Barbados", "BB", "1246" }, - { "Belarus", "BY", "375" }, - { "Belgium", "BE", "32" }, - { "Belize", "BZ", "501" }, - { "Benin", "BJ", "229" }, - { "Bermuda", "BM", "1441" }, - { "Bhutan", "BT", "975" }, - { "Bolivia", "BO", "591" }, - { "Bonaire, Sint Eustatius & Saba", "BQ", "599" }, - { "Bosnia & Herzegovina", "BA", "387" }, - { "Botswana", "BW", "267" }, - { "Brazil", "BR", "55" }, - { "British Virgin Islands", "VG", "1284" }, - { "Brunei Darussalam", "BN", "673" }, - { "Bulgaria", "BG", "359" }, - { "Burkina Faso", "BF", "226" }, - { "Burundi", "BI", "257" }, - { "Cambodia", "KH", "855" }, - { "Cameroon", "CM", "237" }, - { "Canada", "CA", "1" }, - { "Cape Verde", "CV", "238" }, - { "Cayman Islands", "KY", "1345" }, - { "Central African Republic", "CF", "236" }, - { "Chad", "TD", "235" }, - { "Chile", "CL", "56" }, - { "China", "CN", "86" }, - { "Colombia", "CO", "57" }, - { "Comoros", "KM", "269" }, - { "Congo", "CG", "242" }, - { "Congo, Democratic Republic", "CD", "243" }, - { "Cook Islands", "CK", "682" }, - { "Costa Rica", "CR", "506" }, - { "Croatia", "HR", "385" }, - { "Cuba", "CU", "53" }, - { "Curaçao", "CW", "599" }, - { "Cyprus", "CY", "357" }, - { "Czech Republic", "CZ", "420" }, - { "Côte d`Ivoire", "CI", "225" }, - { "Denmark", "DK", "45" }, - { "Diego Garcia", "IO", "246" }, - { "Djibouti", "DJ", "253" }, - { "Dominica", "DM", "1767" }, - { "Dominican Republic", "DO", "1" }, - { "Ecuador", "EC", "593" }, - { "Egypt", "EG", "20" }, - { "El Salvador", "SV", "503" }, - { "Equatorial Guinea", "GQ", "240" }, - { "Eritrea", "ER", "291" }, - { "Estonia", "EE", "372" }, - { "Ethiopia", "ET", "251" }, - { "Falkland Islands", "FK", "500" }, - { "Faroe Islands", "FO", "298" }, - { "Fiji", "FJ", "679" }, - { "Finland", "FI", "358" }, - { "France", "FR", "33" }, - { "French Guiana", "GF", "594" }, - { "French Polynesia", "PF", "689" }, - { "Gabon", "GA", "241" }, - { "Gambia", "GM", "220" }, - { "Georgia", "GE", "995" }, - { "Germany", "DE", "49" }, - { "Ghana", "GH", "233" }, - { "Gibraltar", "GI", "350" }, - { "Greece", "GR", "30" }, - { "Greenland", "GL", "299" }, - { "Grenada", "GD", "1473" }, - { "Guadeloupe", "GP", "590" }, - { "Guam", "GU", "1671" }, - { "Guatemala", "GT", "502" }, - { "Guinea", "GN", "224" }, - { "Guinea-Bissau", "GW", "245" }, - { "Guyana", "GY", "592" }, - { "Haiti", "HT", "509" }, - { "Honduras", "HN", "504" }, - { "Hong Kong", "HK", "852" }, - { "Hungary", "HU", "36" }, - { "Iceland", "IS", "354" }, - { "India", "IN", "91" }, - { "Indonesia", "ID", "62" }, - { "Iran", "IR", "98" }, - { "Iraq", "IQ", "964" }, - { "Ireland", "IE", "353" }, - { "Israel", "IL", "972" }, - { "Italy", "IT", "39" }, - { "Jamaica", "JM", "1876" }, - { "Japan", "JP", "81" }, - { "Jordan", "JO", "962" }, - { "Kazakhstan", "KZ", "7" }, - { "Kenya", "KE", "254" }, - { "Kiribati", "KI", "686" }, - { "Kuwait", "KW", "965" }, - { "Kyrgyzstan", "KG", "996" }, - { "Laos", "LA", "856" }, - { "Latvia", "LV", "371" }, - { "Lebanon", "LB", "961" }, - { "Lesotho", "LS", "266" }, - { "Liberia", "LR", "231" }, - { "Libya", "LY", "218" }, - { "Liechtenstein", "LI", "423" }, - { "Lithuania", "LT", "370" }, - { "Luxembourg", "LU", "352" }, - { "Macau", "MO", "853" }, - { "Macedonia", "MK", "389" }, - { "Madagascar", "MG", "261" }, - { "Malawi", "MW", "265" }, - { "Malaysia", "MY", "60" }, - { "Maldives", "MV", "960" }, - { "Mali", "ML", "223" }, - { "Malta", "MT", "356" }, - { "Marshall Islands", "MH", "692" }, - { "Martinique", "MQ", "596" }, - { "Mauritania", "MR", "222" }, - { "Mauritius", "MU", "230" }, - { "Mexico", "MX", "52" }, - { "Micronesia", "FM", "691" }, - { "Moldova", "MD", "373" }, - { "Monaco", "MC", "377" }, - { "Mongolia", "MN", "976" }, - { "Montenegro", "ME", "382" }, - { "Montserrat", "MS", "1664" }, - { "Morocco", "MA", "212" }, - { "Mozambique", "MZ", "258" }, - { "Myanmar", "MM", "95" }, - { "Namibia", "NA", "264" }, - { "Nauru", "NR", "674" }, - { "Nepal", "NP", "977" }, - { "Netherlands", "NL", "31" }, - { "New Caledonia", "NC", "687" }, - { "New Zealand", "NZ", "64" }, - { "Nicaragua", "NI", "505" }, - { "Niger", "NE", "227" }, - { "Nigeria", "NG", "234" }, - { "Niue", "NU", "683" }, - { "Norfolk Island", "NF", "672" }, - { "North Korea", "KP", "850" }, - { "Northern Mariana Islands", "MP", "1670" }, - { "Norway", "NO", "47" }, - { "Oman", "OM", "968" }, - { "Pakistan", "PK", "92" }, - { "Palau", "PW", "680" }, - { "Palestine", "PS", "970" }, - { "Panama", "PA", "507" }, - { "Papua New Guinea", "PG", "675" }, - { "Paraguay", "PY", "595" }, - { "Peru", "PE", "51" }, - { "Philippines", "PH", "63" }, - { "Poland", "PL", "48" }, - { "Portugal", "PT", "351" }, - { "Puerto Rico", "PR", "1" }, - { "Qatar", "QA", "974" }, - { "Romania", "RO", "40" }, - { "Russian Federation", "RU", "7" }, - { "Rwanda", "RW", "250" }, - { "Réunion", "RE", "262" }, - { "Saint Helena", "SH", "247" }, - { "Saint Helena", "SH2", "290" }, - { "Saint Kitts & Nevis", "KN", "1869" }, - { "Saint Lucia", "LC", "1758" }, - { "Saint Pierre & Miquelon", "PM", "508" }, - { "Saint Vincent & the Grenadines", "VC", "1784" }, - { "Samoa", "WS", "685" }, - { "San Marino", "SM", "378" }, - { "Saudi Arabia", "SA", "966" }, - { "Senegal", "SN", "221" }, - { "Serbia", "RS", "381" }, - { "Seychelles", "SC", "248" }, - { "Sierra Leone", "SL", "232" }, - { "Singapore", "SG", "65" }, - { "Sint Maarten", "SX", "1721" }, - { "Slovakia", "SK", "421" }, - { "Slovenia", "SI", "386" }, - { "Solomon Islands", "SB", "677" }, - { "Somalia", "SO", "252" }, - { "South Africa", "ZA", "27" }, - { "South Korea", "KR", "82" }, - { "South Sudan", "SS", "211" }, - { "Spain", "ES", "34" }, - { "Sri Lanka", "LK", "94" }, - { "Sudan", "SD", "249" }, - { "Suriname", "SR", "597" }, - { "Swaziland", "SZ", "268" }, - { "Sweden", "SE", "46" }, - { "Switzerland", "CH", "41" }, - { "Syrian Arab Republic", "SY", "963" }, - { "São Tomé & Príncipe", "ST", "239" }, - { "Taiwan", "TW", "886" }, - { "Tajikistan", "TJ", "992" }, - { "Tanzania", "TZ", "255" }, - { "Thailand", "TH", "66" }, - { "Timor-Leste", "TL", "670" }, - { "Togo", "TG", "228" }, - { "Tokelau", "TK", "690" }, - { "Tonga", "TO", "676" }, - { "Trinidad & Tobago", "TT", "1868" }, - { "Tunisia", "TN", "216" }, - { "Turkey", "TR", "90" }, - { "Turkmenistan", "TM", "993" }, - { "Turks & Caicos Islands", "TC", "1649" }, - { "Tuvalu", "TV", "688" }, - { "US Virgin Islands", "VI", "1340" }, - { "USA", "US", "1", "United States of America" }, - { "Uganda", "UG", "256" }, - { "Ukraine", "UA", "380" }, - { "United Arab Emirates", "AE", "971" }, - { "United Kingdom", "GB", "44" }, - { "Uruguay", "UY", "598" }, - { "Uzbekistan", "UZ", "998" }, - { "Vanuatu", "VU", "678" }, - { "Venezuela", "VE", "58" }, - { "Vietnam", "VN", "84" }, - { "Wallis & Futuna", "WF", "681" }, - { "Yemen", "YE", "967" }, - { "Zambia", "ZM", "260" }, - { "Zimbabwe", "ZW", "263" }, + { "Afghanistan", "AF" }, + { "Albania", "AL" }, + { "Algeria", "DZ" }, + { "American Samoa", "AS" }, + { "Andorra", "AD" }, + { "Angola", "AO" }, + { "Anguilla", "AI" }, + { "Antigua & Barbuda", "AG" }, + { "Argentina", "AR" }, + { "Armenia", "AM" }, + { "Aruba", "AW" }, + { "Australia", "AU" }, + { "Austria", "AT" }, + { "Azerbaijan", "AZ" }, + { "Bahamas", "BS" }, + { "Bahrain", "BH" }, + { "Bangladesh", "BD" }, + { "Barbados", "BB" }, + { "Belarus", "BY" }, + { "Belgium", "BE" }, + { "Belize", "BZ" }, + { "Benin", "BJ" }, + { "Bermuda", "BM" }, + { "Bhutan", "BT" }, + { "Bolivia", "BO" }, + { "Bonaire, Sint Eustatius & Saba", "BQ" }, + { "Bosnia & Herzegovina", "BA" }, + { "Botswana", "BW" }, + { "Brazil", "BR" }, + { "British Virgin Islands", "VG" }, + { "Brunei Darussalam", "BN" }, + { "Bulgaria", "BG" }, + { "Burkina Faso", "BF" }, + { "Burundi", "BI" }, + { "Cambodia", "KH" }, + { "Cameroon", "CM" }, + { "Canada", "CA" }, + { "Cape Verde", "CV" }, + { "Cayman Islands", "KY" }, + { "Central African Republic", "CF" }, + { "Chad", "TD" }, + { "Chile", "CL" }, + { "China", "CN" }, + { "Colombia", "CO" }, + { "Comoros", "KM" }, + { "Congo", "CG" }, + { "Congo, Democratic Republic", "CD" }, + { "Cook Islands", "CK" }, + { "Costa Rica", "CR" }, + { "Croatia", "HR" }, + { "Cuba", "CU" }, + { "Curaçao", "CW" }, + { "Cyprus", "CY" }, + { "Czech Republic", "CZ" }, + { "Côte d`Ivoire", "CI" }, + { "Denmark", "DK" }, + { "Diego Garcia", "IO" }, + { "Djibouti", "DJ" }, + { "Dominica", "DM" }, + { "Dominican Republic", "DO" }, + { "Ecuador", "EC" }, + { "Egypt", "EG" }, + { "El Salvador", "SV" }, + { "Equatorial Guinea", "GQ" }, + { "Eritrea", "ER" }, + { "Estonia", "EE" }, + { "Ethiopia", "ET" }, + { "Falkland Islands", "FK" }, + { "Faroe Islands", "FO" }, + { "Fiji", "FJ" }, + { "Finland", "FI" }, + { "France", "FR" }, + { "French Guiana", "GF" }, + { "French Polynesia", "PF" }, + { "Gabon", "GA" }, + { "Gambia", "GM" }, + { "Georgia", "GE" }, + { "Germany", "DE" }, + { "Ghana", "GH" }, + { "Gibraltar", "GI" }, + { "Greece", "GR" }, + { "Greenland", "GL" }, + { "Grenada", "GD" }, + { "Guadeloupe", "GP" }, + { "Guam", "GU" }, + { "Guatemala", "GT" }, + { "Guinea", "GN" }, + { "Guinea-Bissau", "GW" }, + { "Guyana", "GY" }, + { "Haiti", "HT" }, + { "Honduras", "HN" }, + { "Hong Kong", "HK" }, + { "Hungary", "HU" }, + { "Iceland", "IS" }, + { "India", "IN" }, + { "Indonesia", "ID" }, + { "Iran", "IR" }, + { "Iraq", "IQ" }, + { "Ireland", "IE" }, + { "Israel", "IL" }, + { "Italy", "IT" }, + { "Jamaica", "JM" }, + { "Japan", "JP" }, + { "Jordan", "JO" }, + { "Kazakhstan", "KZ" }, + { "Kenya", "KE" }, + { "Kiribati", "KI" }, + { "Kuwait", "KW" }, + { "Kyrgyzstan", "KG" }, + { "Laos", "LA" }, + { "Latvia", "LV" }, + { "Lebanon", "LB" }, + { "Lesotho", "LS" }, + { "Liberia", "LR" }, + { "Libya", "LY" }, + { "Liechtenstein", "LI" }, + { "Lithuania", "LT" }, + { "Luxembourg", "LU" }, + { "Macau", "MO" }, + { "Macedonia", "MK" }, + { "Madagascar", "MG" }, + { "Malawi", "MW" }, + { "Malaysia", "MY" }, + { "Maldives", "MV" }, + { "Mali", "ML" }, + { "Malta", "MT" }, + { "Marshall Islands", "MH" }, + { "Martinique", "MQ" }, + { "Mauritania", "MR" }, + { "Mauritius", "MU" }, + { "Mexico", "MX" }, + { "Micronesia", "FM" }, + { "Moldova", "MD" }, + { "Monaco", "MC" }, + { "Mongolia", "MN" }, + { "Montenegro", "ME" }, + { "Montserrat", "MS" }, + { "Morocco", "MA" }, + { "Mozambique", "MZ" }, + { "Myanmar", "MM" }, + { "Namibia", "NA" }, + { "Nauru", "NR" }, + { "Nepal", "NP" }, + { "Netherlands", "NL" }, + { "New Caledonia", "NC" }, + { "New Zealand", "NZ" }, + { "Nicaragua", "NI" }, + { "Niger", "NE" }, + { "Nigeria", "NG" }, + { "Niue", "NU" }, + { "Norfolk Island", "NF" }, + { "North Korea", "KP" }, + { "Northern Mariana Islands", "MP" }, + { "Norway", "NO" }, + { "Oman", "OM" }, + { "Pakistan", "PK" }, + { "Palau", "PW" }, + { "Palestine", "PS" }, + { "Panama", "PA" }, + { "Papua New Guinea", "PG" }, + { "Paraguay", "PY" }, + { "Peru", "PE" }, + { "Philippines", "PH" }, + { "Poland", "PL" }, + { "Portugal", "PT" }, + { "Puerto Rico", "PR" }, + { "Qatar", "QA" }, + { "Romania", "RO" }, + { "Russian Federation", "RU" }, + { "Rwanda", "RW" }, + { "Réunion", "RE" }, + { "Saint Helena", "SH" }, + { "Saint Helena", "SH2" }, + { "Saint Kitts & Nevis", "KN" }, + { "Saint Lucia", "LC" }, + { "Saint Pierre & Miquelon", "PM" }, + { "Saint Vincent & the Grenadines", "VC" }, + { "Samoa", "WS" }, + { "San Marino", "SM" }, + { "Saudi Arabia", "SA" }, + { "Senegal", "SN" }, + { "Serbia", "RS" }, + { "Seychelles", "SC" }, + { "Sierra Leone", "SL" }, + { "Singapore", "SG" }, + { "Sint Maarten", "SX" }, + { "Slovakia", "SK" }, + { "Slovenia", "SI" }, + { "Solomon Islands", "SB" }, + { "Somalia", "SO" }, + { "South Africa", "ZA" }, + { "South Korea", "KR" }, + { "South Sudan", "SS" }, + { "Spain", "ES" }, + { "Sri Lanka", "LK" }, + { "Sudan", "SD" }, + { "Suriname", "SR" }, + { "Swaziland", "SZ" }, + { "Sweden", "SE" }, + { "Switzerland", "CH" }, + { "Syrian Arab Republic", "SY" }, + { "São Tomé & Príncipe", "ST" }, + { "Taiwan", "TW" }, + { "Tajikistan", "TJ" }, + { "Tanzania", "TZ" }, + { "Thailand", "TH" }, + { "Timor-Leste", "TL" }, + { "Togo", "TG" }, + { "Tokelau", "TK" }, + { "Tonga", "TO" }, + { "Trinidad & Tobago", "TT" }, + { "Tunisia", "TN" }, + { "Turkey", "TR" }, + { "Turkmenistan", "TM" }, + { "Turks & Caicos Islands", "TC" }, + { "Tuvalu", "TV" }, + { "US Virgin Islands", "VI" }, + { "USA", "US", "United States of America" }, + { "Uganda", "UG" }, + { "Ukraine", "UA" }, + { "United Arab Emirates", "AE" }, + { "United Kingdom", "GB" }, + { "Uruguay", "UY" }, + { "Uzbekistan", "UZ" }, + { "Vanuatu", "VU" }, + { "Venezuela", "VE" }, + { "Vietnam", "VN" }, + { "Wallis & Futuna", "WF" }, + { "Yemen", "YE" }, + { "Zambia", "ZM" }, + { "Zimbabwe", "ZW" }, } }; } // namespace @@ -266,7 +266,9 @@ const CountriesInstance::Map &CountriesInstance::byCode() { if (_byCode.empty()) { _byCode.reserve(list().size()); for (const auto &entry : list()) { - _byCode.insert(entry.code, &entry); + for (const auto &code : entry.codes) { + _byCode.insert(code.callingCode, &entry); + } } } return _byCode; @@ -287,7 +289,7 @@ QString CountriesInstance::validPhoneCode(QString fullCode) { while (fullCode.length()) { const auto i = listByCode.constFind(fullCode); if (i != listByCode.cend()) { - return (*i)->code; + return fullCode; } fullCode.chop(1); } diff --git a/Telegram/SourceFiles/countries/countries_instance.h b/Telegram/SourceFiles/countries/countries_instance.h index 7c7e104e2..1b9ddec8c 100644 --- a/Telegram/SourceFiles/countries/countries_instance.h +++ b/Telegram/SourceFiles/countries/countries_instance.h @@ -19,7 +19,6 @@ struct CallingCodeInfo { struct Info { QString name; QString iso2; - QString code; QString alternativeName; std::vector codes; bool isHidden = false; diff --git a/Telegram/SourceFiles/countries/countries_manager.cpp b/Telegram/SourceFiles/countries/countries_manager.cpp index 6ba1afdc3..0ed6ac66d 100644 --- a/Telegram/SourceFiles/countries/countries_manager.cpp +++ b/Telegram/SourceFiles/countries/countries_manager.cpp @@ -81,7 +81,6 @@ auto ProcessAlternativeName(Info &&info) { stream << info.name << info.iso2 - << info.code << info.alternativeName << info.isHidden << int(info.codes.size()); @@ -100,7 +99,6 @@ auto ProcessAlternativeName(Info &&info) { stream >> result.name >> result.iso2 - >> result.code >> result.alternativeName >> result.isHidden >> codesCount; @@ -223,13 +221,10 @@ void Manager::request() { if (countryData.is_hidden()) { continue; } - const auto &first = countryData.vcountry_codes().v.front() - .c_help_countryCode(); auto info = Info(ProcessAlternativeName({ .name = countryData.vdefault_name().v, .iso2 = countryData.viso2().v, - .code = first.vcountry_code().v, .isHidden = countryData.is_hidden(), })); for (const auto &code : countryData.vcountry_codes().v) { diff --git a/Telegram/SourceFiles/ui/boxes/country_select_box.cpp b/Telegram/SourceFiles/ui/boxes/country_select_box.cpp index 3498fd5e2..5f7964fb0 100644 --- a/Telegram/SourceFiles/ui/boxes/country_select_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/country_select_box.cpp @@ -256,7 +256,7 @@ void CountrySelectBox::Inner::paintEvent(QPaintEvent *e) { } } - auto code = QString("+") + list[i]->code; + auto code = QString("+") + list[i]->codes.front().callingCode; auto codeWidth = st::countryRowCodeFont->width(code); auto name = list[i]->name; diff --git a/Telegram/SourceFiles/ui/countryinput.cpp b/Telegram/SourceFiles/ui/countryinput.cpp index 47e1aaa6c..3050ecbcb 100644 --- a/Telegram/SourceFiles/ui/countryinput.cpp +++ b/Telegram/SourceFiles/ui/countryinput.cpp @@ -140,7 +140,7 @@ bool CountryInput::chooseCountry(const QString &iso) { if (info) { _chosenIso = LastValidISO = info->iso2; setText(info->name); - codeChanged(info->code); + codeChanged(info->codes.front().callingCode); update(); return true; }