Removed old code entry from country info.

This commit is contained in:
23rd 2021-08-29 20:08:47 +03:00 committed by John Preston
parent 963fda69a8
commit 6caddb5141
5 changed files with 237 additions and 241 deletions

View file

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

View file

@ -19,7 +19,6 @@ struct CallingCodeInfo {
struct Info { struct Info {
QString name; QString name;
QString iso2; QString iso2;
QString code;
QString alternativeName; QString alternativeName;
std::vector<CallingCodeInfo> codes; std::vector<CallingCodeInfo> codes;
bool isHidden = false; bool isHidden = false;

View file

@ -81,7 +81,6 @@ auto ProcessAlternativeName(Info &&info) {
stream stream
<< info.name << info.name
<< info.iso2 << info.iso2
<< info.code
<< info.alternativeName << info.alternativeName
<< info.isHidden << info.isHidden
<< int(info.codes.size()); << int(info.codes.size());
@ -100,7 +99,6 @@ auto ProcessAlternativeName(Info &&info) {
stream stream
>> result.name >> result.name
>> result.iso2 >> result.iso2
>> result.code
>> result.alternativeName >> result.alternativeName
>> result.isHidden >> result.isHidden
>> codesCount; >> codesCount;
@ -223,13 +221,10 @@ void Manager::request() {
if (countryData.is_hidden()) { if (countryData.is_hidden()) {
continue; continue;
} }
const auto &first = countryData.vcountry_codes().v.front()
.c_help_countryCode();
auto info = Info(ProcessAlternativeName({ auto info = Info(ProcessAlternativeName({
.name = countryData.vdefault_name().v, .name = countryData.vdefault_name().v,
.iso2 = countryData.viso2().v, .iso2 = countryData.viso2().v,
.code = first.vcountry_code().v,
.isHidden = countryData.is_hidden(), .isHidden = countryData.is_hidden(),
})); }));
for (const auto &code : countryData.vcountry_codes().v) { for (const auto &code : countryData.vcountry_codes().v) {

View file

@ -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 codeWidth = st::countryRowCodeFont->width(code);
auto name = list[i]->name; auto name = list[i]->name;

View file

@ -140,7 +140,7 @@ bool CountryInput::chooseCountry(const QString &iso) {
if (info) { if (info) {
_chosenIso = LastValidISO = info->iso2; _chosenIso = LastValidISO = info->iso2;
setText(info->name); setText(info->name);
codeChanged(info->code); codeChanged(info->codes.front().callingCode);
update(); update();
return true; return true;
} }