mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-04-17 04:39:47 +00:00
Moved countries from Data to Countries namespace.
This commit is contained in:
parent
1b3075ac2e
commit
df02bbb0a3
@ -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<CountryInfo, 231> 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
|
@ -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
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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<Ui::BoxContent> 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(
|
||||
|
@ -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<Input>::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()
|
||||
|
@ -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() {
|
||||
|
@ -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()) {
|
||||
|
@ -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<VerticalLayout*> 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(
|
||||
|
@ -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<not_null<const Data::CountryInfo*>> ¤t() const;
|
||||
const std::vector<not_null<const Countries::CountryInfo*>> ¤t() const;
|
||||
|
||||
Type _type = Type::Phones;
|
||||
int _rowHeight = 0;
|
||||
@ -76,8 +76,8 @@ private:
|
||||
|
||||
std::vector<std::unique_ptr<RippleAnimation>> _ripples;
|
||||
|
||||
std::vector<not_null<const Data::CountryInfo*>> _list;
|
||||
std::vector<not_null<const Data::CountryInfo*>> _filtered;
|
||||
std::vector<not_null<const Countries::CountryInfo*>> _list;
|
||||
std::vector<not_null<const Countries::CountryInfo*>> _filtered;
|
||||
base::flat_map<QChar, std::vector<int>> _byLetter;
|
||||
std::vector<std::vector<QString>> _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<not_null<const Data::CountryInfo*>> & {
|
||||
-> const std::vector<not_null<const Countries::CountryInfo*>> & {
|
||||
return _filter.isEmpty() ? _list : _filtered;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 <QtCore/QRegularExpression>
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user