diff --git a/Telegram/SourceFiles/countries/countries_instance.cpp b/Telegram/SourceFiles/countries/countries_instance.cpp index 411f4a7d69..c8f4bc7871 100644 --- a/Telegram/SourceFiles/countries/countries_instance.cpp +++ b/Telegram/SourceFiles/countries/countries_instance.cpp @@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Countries { namespace { -const std::array List = { { +const std::array FallbackList = { { { "Afghanistan", "AF", "93" }, { "Albania", "AL", "355" }, { "Algeria", "DZ", "213" }, @@ -244,29 +244,29 @@ const std::array List = { { { "Zimbabwe", "ZW", "263" }, } }; -QHash ByCode; -QHash ByISO2; +QHash ByCode; +QHash ByISO2; } // namespace -const std::array &Countries() { - return List; +const std::array &List() { + return FallbackList; } -const QHash &CountriesByCode() { +const QHash &InfoByCode() { if (ByCode.isEmpty()) { - ByCode.reserve(List.size()); - for (const auto &entry : List) { + ByCode.reserve(FallbackList.size()); + for (const auto &entry : FallbackList) { ByCode.insert(entry.code, &entry); } } return ByCode; } -const QHash &CountriesByISO2() { +const QHash &InfoByISO2() { if (ByISO2.isEmpty()) { - ByISO2.reserve(List.size()); - for (const auto &entry : List) { + ByISO2.reserve(FallbackList.size()); + for (const auto &entry : FallbackList) { ByISO2.insert(entry.iso2, &entry); } } @@ -274,7 +274,7 @@ const QHash &CountriesByISO2() { } QString ValidPhoneCode(QString fullCode) { - const auto &byCode = CountriesByCode(); + const auto &byCode = InfoByCode(); while (fullCode.length()) { const auto i = byCode.constFind(fullCode); if (i != byCode.cend()) { @@ -286,13 +286,13 @@ QString ValidPhoneCode(QString fullCode) { } QString CountryNameByISO2(const QString &iso) { - const auto &byISO2 = CountriesByISO2(); + const auto &byISO2 = InfoByISO2(); const auto i = byISO2.constFind(iso); return (i != byISO2.cend()) ? QString::fromUtf8((*i)->name) : QString(); } QString CountryISO2ByPhone(const QString &phone) { - const auto &byCode = CountriesByCode(); + const auto &byCode = InfoByCode(); const auto code = ValidPhoneCode(phone); const auto i = byCode.find(code); return (i != byCode.cend()) ? QString::fromUtf8((*i)->iso2) : QString(); diff --git a/Telegram/SourceFiles/countries/countries_instance.h b/Telegram/SourceFiles/countries/countries_instance.h index ca4528469d..d572cb0119 100644 --- a/Telegram/SourceFiles/countries/countries_instance.h +++ b/Telegram/SourceFiles/countries/countries_instance.h @@ -10,17 +10,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Countries { -struct CountryInfo { +struct Info { const char *name = nullptr; const char *iso2 = nullptr; const char *code = nullptr; const char *alternativeName = nullptr; }; -[[nodiscard]] const std::array &Countries(); +[[nodiscard]] const std::array &List(); -[[nodiscard]] const QHash &CountriesByCode(); -[[nodiscard]] const QHash &CountriesByISO2(); +[[nodiscard]] const QHash &InfoByCode(); +[[nodiscard]] const QHash &InfoByISO2(); [[nodiscard]] QString ValidPhoneCode(QString fullCode); [[nodiscard]] QString CountryNameByISO2(const QString &iso); diff --git a/Telegram/SourceFiles/ui/boxes/country_select_box.cpp b/Telegram/SourceFiles/ui/boxes/country_select_box.cpp index 7306ba245c..de57eea156 100644 --- a/Telegram/SourceFiles/ui/boxes/country_select_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/country_select_box.cpp @@ -64,7 +64,7 @@ private: void updateSelectedRow(); void updateRow(int index); void setPressed(int pressed); - const std::vector> ¤t() const; + const std::vector> ¤t() const; Type _type = Type::Phones; int _rowHeight = 0; @@ -76,8 +76,8 @@ private: std::vector> _ripples; - std::vector> _list; - std::vector> _filtered; + std::vector> _list; + std::vector> _filtered; base::flat_map> _byLetter; std::vector> _namesList; @@ -174,7 +174,7 @@ CountrySelectBox::Inner::Inner( , _rowHeight(st::countryRowHeight) { setAttribute(Qt::WA_OpaquePaintEvent); - const auto &byISO2 = Countries::CountriesByISO2(); + const auto &byISO2 = Countries::InfoByISO2(); if (byISO2.contains(iso)) { LastValidISO = iso; @@ -188,7 +188,7 @@ CountrySelectBox::Inner::Inner( if (lastValid) { _list.emplace_back(lastValid); } - for (const auto &entry : Countries::Countries()) { + for (const auto &entry : Countries::List()) { if (&entry != lastValid) { _list.emplace_back(&entry); } @@ -424,7 +424,7 @@ void CountrySelectBox::Inner::updateSelected(QPoint localPos) { } auto CountrySelectBox::Inner::current() const --> const std::vector> & { +-> const std::vector> & { return _filter.isEmpty() ? _list : _filtered; } diff --git a/Telegram/SourceFiles/ui/boxes/country_select_box.h b/Telegram/SourceFiles/ui/boxes/country_select_box.h index 8d0fef1d4b..feafada741 100644 --- a/Telegram/SourceFiles/ui/boxes/country_select_box.h +++ b/Telegram/SourceFiles/ui/boxes/country_select_box.h @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_widgets.h" namespace Countries { -struct CountryInfo; +struct Info; } // namespace Countries namespace Ui { diff --git a/Telegram/SourceFiles/ui/countryinput.cpp b/Telegram/SourceFiles/ui/countryinput.cpp index 86ab064cce..0affb62d79 100644 --- a/Telegram/SourceFiles/ui/countryinput.cpp +++ b/Telegram/SourceFiles/ui/countryinput.cpp @@ -114,7 +114,7 @@ void CountryInput::onChooseCode(const QString &code) { Ui::hideLayer(); _chosenIso = QString(); if (code.length()) { - const auto &byCode = Countries::CountriesByCode(); + const auto &byCode = Countries::InfoByCode(); const auto i = byCode.constFind(code); if (i != byCode.cend()) { const auto info = *i; @@ -132,7 +132,7 @@ void CountryInput::onChooseCode(const QString &code) { bool CountryInput::chooseCountry(const QString &iso) { Ui::hideLayer(); - const auto &byISO2 = Countries::CountriesByISO2(); + const auto &byISO2 = Countries::InfoByISO2(); const auto i = byISO2.constFind(iso); const auto info = (i != byISO2.cend()) ? (*i) : nullptr; diff --git a/Telegram/SourceFiles/ui/countryinput.h b/Telegram/SourceFiles/ui/countryinput.h index 7b0050bc03..7214a5d981 100644 --- a/Telegram/SourceFiles/ui/countryinput.h +++ b/Telegram/SourceFiles/ui/countryinput.h @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_widgets.h" namespace Data { -struct CountryInfo; +struct Info; } // namespace Data namespace Ui {