diff --git a/Telegram/SourceFiles/data/data_countries.cpp b/Telegram/SourceFiles/countries/countries_instance.cpp similarity index 98% rename from Telegram/SourceFiles/data/data_countries.cpp rename to Telegram/SourceFiles/countries/countries_instance.cpp index ea03bfe20..411f4a7d6 100644 --- a/Telegram/SourceFiles/data/data_countries.cpp +++ b/Telegram/SourceFiles/countries/countries_instance.cpp @@ -5,9 +5,9 @@ the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ -#include "data/data_countries.h" +#include "countries/countries_instance.h" -namespace Data { +namespace Countries { namespace { const std::array List = { { @@ -292,10 +292,10 @@ QString CountryNameByISO2(const QString &iso) { } QString CountryISO2ByPhone(const QString &phone) { - const auto &byCode = Data::CountriesByCode(); - const auto code = Data::ValidPhoneCode(phone); + const auto &byCode = CountriesByCode(); + const auto code = ValidPhoneCode(phone); const auto i = byCode.find(code); return (i != byCode.cend()) ? QString::fromUtf8((*i)->iso2) : QString(); } -} // namespace Data +} // namespace Countries diff --git a/Telegram/SourceFiles/data/data_countries.h b/Telegram/SourceFiles/countries/countries_instance.h similarity index 94% rename from Telegram/SourceFiles/data/data_countries.h rename to Telegram/SourceFiles/countries/countries_instance.h index ac50ce8bb..ca4528469 100644 --- a/Telegram/SourceFiles/data/data_countries.h +++ b/Telegram/SourceFiles/countries/countries_instance.h @@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once -namespace Data { +namespace Countries { struct CountryInfo { const char *name = nullptr; @@ -26,4 +26,4 @@ struct CountryInfo { [[nodiscard]] QString CountryNameByISO2(const QString &iso); [[nodiscard]] QString CountryISO2ByPhone(const QString &phone); -} // namespace Data +} // namespace Countries diff --git a/Telegram/SourceFiles/intro/intro_widget.cpp b/Telegram/SourceFiles/intro/intro_widget.cpp index 2a79eea24..cafd43e92 100644 --- a/Telegram/SourceFiles/intro/intro_widget.cpp +++ b/Telegram/SourceFiles/intro/intro_widget.cpp @@ -24,7 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/history_item.h" #include "data/data_user.h" -#include "data/data_countries.h" +#include "countries/countries_instance.h" #include "boxes/confirm_box.h" #include "ui/text/format_values.h" // Ui::FormatPhone #include "ui/text/text_utilities.h" @@ -54,7 +54,7 @@ using namespace ::Intro::details; if (const auto parent = Core::App().domain().maybeLastOrSomeAuthedAccount()) { if (const auto session = parent->maybeSession()) { - const auto iso = ::Data::CountryISO2ByPhone( + const auto iso = Countries::CountryISO2ByPhone( session->user()->phone()); if (!iso.isEmpty()) { return iso; diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.cpp b/Telegram/SourceFiles/passport/passport_panel_controller.cpp index 2c099cb21..bf320e6ab 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_controller.cpp @@ -23,7 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/countryinput.h" #include "ui/text/format_values.h" #include "core/update_checker.h" -#include "data/data_countries.h" +#include "countries/countries_instance.h" #include "styles/style_layers.h" namespace Passport { @@ -123,7 +123,7 @@ EditDocumentScheme GetDocumentScheme( using ValueClass = Scheme::ValueClass; const auto DontFormat = nullptr; const auto CountryFormat = [](const QString &value) { - const auto result = Data::CountryNameByISO2(value); + const auto result = Countries::CountryNameByISO2(value); return result.isEmpty() ? value : result; }; const auto GenderFormat = [](const QString &value) { @@ -322,7 +322,7 @@ EditDocumentScheme GetDocumentScheme( if (!language.isEmpty()) { return tr::lng_passport_native_name_language_about(tr::now); } - const auto name = Data::CountryNameByISO2(countryCode); + const auto name = Countries::CountryNameByISO2(countryCode); Assert(!name.isEmpty()); return tr::lng_passport_native_name_about( tr::now, diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp index a93469046..cbc7ed861 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp @@ -19,7 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/vertical_layout.h" #include "ui/wrap/fade_wrap.h" #include "ui/wrap/slide_wrap.h" -#include "data/data_countries.h" +#include "countries/countries_instance.h" #include "data/data_user.h" // ->bot()->session() #include "main/main_session.h" // ->session().user() #include "ui/text/text_utilities.h" // Ui::Text::ToUpper @@ -520,7 +520,7 @@ void PanelEditDocument::createDetailsRow( object_ptr box) { controller->show(std::move(box)); }; - const auto isoByPhone = Data::CountryISO2ByPhone( + const auto isoByPhone = Countries::CountryISO2ByPhone( _controller->bot()->session().user()->phone()); const auto [it, ok] = _details.emplace( diff --git a/Telegram/SourceFiles/passport/ui/passport_details_row.cpp b/Telegram/SourceFiles/passport/ui/passport_details_row.cpp index 85337e8b9..f6cbc5568 100644 --- a/Telegram/SourceFiles/passport/ui/passport_details_row.cpp +++ b/Telegram/SourceFiles/passport/ui/passport_details_row.cpp @@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/slide_wrap.h" #include "ui/layers/box_content.h" #include "ui/boxes/country_select_box.h" -#include "data/data_countries.h" +#include "countries/countries_instance.h" #include "styles/style_layers.h" #include "styles/style_passport.h" @@ -304,7 +304,7 @@ void AbstractTextRow::finishInnerAnimating() { } QString CountryString(const QString &code) { - const auto name = Data::CountryNameByISO2(code); + const auto name = Countries::CountryNameByISO2(code); return name.isEmpty() ? tr::lng_passport_country_choose(tr::now) : name; } @@ -383,7 +383,7 @@ void CountryRow::errorAnimationCallback() { void CountryRow::chooseCountry() { const auto top = _value.current(); - const auto name = Data::CountryNameByISO2(top); + const auto name = Countries::CountryNameByISO2(top); const auto country = !name.isEmpty() ? top : !_defaultCountry.isEmpty() diff --git a/Telegram/SourceFiles/payments/payments_form.cpp b/Telegram/SourceFiles/payments/payments_form.cpp index 4e7b407ba..1e47dac46 100644 --- a/Telegram/SourceFiles/payments/payments_form.cpp +++ b/Telegram/SourceFiles/payments/payments_form.cpp @@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_photo.h" #include "data/data_photo_media.h" #include "data/data_file_origin.h" -#include "data/data_countries.h" +#include "countries/countries_instance.h" #include "history/history_item.h" #include "history/history_service.h" // HistoryServicePayment. #include "stripe/stripe_api_client.h" @@ -465,7 +465,7 @@ QString Form::defaultPhone() const { } QString Form::defaultCountry() const { - return Data::CountryISO2ByPhone(defaultPhone()); + return Countries::CountryISO2ByPhone(defaultPhone()); } void Form::fillPaymentMethodInformation() { diff --git a/Telegram/SourceFiles/payments/ui/payments_field.cpp b/Telegram/SourceFiles/payments/ui/payments_field.cpp index a41946ca1..172904436 100644 --- a/Telegram/SourceFiles/payments/ui/payments_field.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_field.cpp @@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text/format_values.h" #include "ui/ui_utility.h" #include "ui/special_fields.h" -#include "data/data_countries.h" +#include "countries/countries_instance.h" #include "base/platform/base_platform_info.h" #include "base/event_filter.h" #include "styles/style_payments.h" @@ -189,7 +189,7 @@ struct SimpleFieldState { [[nodiscard]] QString Parse(const FieldConfig &config) { if (config.type == FieldType::Country) { - return Data::CountryNameByISO2(config.value); + return Countries::CountryNameByISO2(config.value); } else if (config.type == FieldType::Money) { const auto amount = config.value.toLongLong(); if (!amount) { @@ -490,7 +490,7 @@ void Field::setupCountry() { QObject::connect(_masked, &MaskedInputField::focused, [=] { setFocus(); - const auto name = Data::CountryNameByISO2(_countryIso2); + const auto name = Countries::CountryNameByISO2(_countryIso2); const auto country = !name.isEmpty() ? _countryIso2 : !_config.defaultCountry.isEmpty() @@ -503,7 +503,7 @@ void Field::setupCountry() { raw->countryChosen( ) | rpl::start_with_next([=](QString iso2) { _countryIso2 = iso2; - _masked->setText(Data::CountryNameByISO2(iso2)); + _masked->setText(Countries::CountryNameByISO2(iso2)); _masked->hideError(); raw->closeBox(); if (!iso2.isEmpty()) { diff --git a/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp b/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp index 4aeae7d25..270e50970 100644 --- a/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp @@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/fade_wrap.h" #include "ui/text/format_values.h" #include "ui/text/text_utilities.h" -#include "data/data_countries.h" +#include "countries/countries_instance.h" #include "lang/lang_keys.h" #include "base/unixtime.h" #include "styles/style_payments.h" @@ -508,7 +508,7 @@ void FormSummary::setupSections(not_null layout) { push(_information.shippingAddress.address2); push(_information.shippingAddress.city); push(_information.shippingAddress.state); - push(Data::CountryNameByISO2( + push(Countries::CountryNameByISO2( _information.shippingAddress.countryIso2)); push(_information.shippingAddress.postcode); add( diff --git a/Telegram/SourceFiles/ui/boxes/country_select_box.cpp b/Telegram/SourceFiles/ui/boxes/country_select_box.cpp index dcfed20b3..7306ba245 100644 --- a/Telegram/SourceFiles/ui/boxes/country_select_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/country_select_box.cpp @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/scroll_area.h" #include "ui/widgets/multi_select.h" #include "ui/effects/ripple_animation.h" -#include "data/data_countries.h" +#include "countries/countries_instance.h" #include "base/qt_adapters.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" @@ -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 = Data::CountriesByISO2(); + const auto &byISO2 = Countries::CountriesByISO2(); if (byISO2.contains(iso)) { LastValidISO = iso; @@ -188,7 +188,7 @@ CountrySelectBox::Inner::Inner( if (lastValid) { _list.emplace_back(lastValid); } - for (const auto &entry : Data::Countries()) { + for (const auto &entry : Countries::Countries()) { 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 810d871fe..8d0fef1d4 100644 --- a/Telegram/SourceFiles/ui/boxes/country_select_box.h +++ b/Telegram/SourceFiles/ui/boxes/country_select_box.h @@ -10,9 +10,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/abstract_box.h" #include "styles/style_widgets.h" -namespace Data { +namespace Countries { struct CountryInfo; -} // namespace Data +} // namespace Countries namespace Ui { diff --git a/Telegram/SourceFiles/ui/countryinput.cpp b/Telegram/SourceFiles/ui/countryinput.cpp index 913fcd3c2..86ab064cc 100644 --- a/Telegram/SourceFiles/ui/countryinput.cpp +++ b/Telegram/SourceFiles/ui/countryinput.cpp @@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/multi_select.h" #include "ui/effects/ripple_animation.h" #include "ui/boxes/country_select_box.h" -#include "data/data_countries.h" +#include "countries/countries_instance.h" #include "base/qt_adapters.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" @@ -114,7 +114,7 @@ void CountryInput::onChooseCode(const QString &code) { Ui::hideLayer(); _chosenIso = QString(); if (code.length()) { - const auto &byCode = Data::CountriesByCode(); + const auto &byCode = Countries::CountriesByCode(); 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 = Data::CountriesByISO2(); + const auto &byISO2 = Countries::CountriesByISO2(); const auto i = byISO2.constFind(iso); const auto info = (i != byISO2.cend()) ? (*i) : nullptr; diff --git a/Telegram/SourceFiles/ui/special_fields.cpp b/Telegram/SourceFiles/ui/special_fields.cpp index 238bb6f06..a127d8252 100644 --- a/Telegram/SourceFiles/ui/special_fields.cpp +++ b/Telegram/SourceFiles/ui/special_fields.cpp @@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/special_fields.h" #include "lang/lang_keys.h" -#include "data/data_countries.h" // Data::ValidPhoneCode +#include "countries/countries_instance.h" // Countries::ValidPhoneCode #include "numbers.h" #include @@ -83,7 +83,7 @@ void CountryCodeInput::correctValue( } } if (!addToNumber.isEmpty()) { - auto validCode = Data::ValidPhoneCode(newText.mid(1)); + auto validCode = Countries::ValidPhoneCode(newText.mid(1)); addToNumber = newText.mid(1 + validCode.length()) + addToNumber; newText = '+' + validCode; } diff --git a/Telegram/cmake/td_ui.cmake b/Telegram/cmake/td_ui.cmake index c955d53f4..304b309d9 100644 --- a/Telegram/cmake/td_ui.cmake +++ b/Telegram/cmake/td_ui.cmake @@ -58,8 +58,8 @@ PRIVATE core/mime_type.cpp core/mime_type.h - data/data_countries.cpp - data/data_countries.h + countries/countries_instance.cpp + countries/countries_instance.h layout/abstract_layout_item.cpp layout/abstract_layout_item.h