mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-02 15:45:12 +00:00
Moved App::formatPhone to td_ui.
This commit is contained in:
@@ -38,7 +38,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "mainwindow.h"
|
||||
#include "mainwidget.h"
|
||||
#include "apiwrap.h"
|
||||
#include "numbers.h"
|
||||
#include "main/main_session.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_overview.h"
|
||||
@@ -70,32 +69,6 @@ HistoryView::Element *hoveredItem = nullptr,
|
||||
|
||||
namespace App {
|
||||
|
||||
QString formatPhone(QString phone) {
|
||||
if (phone.isEmpty()) return QString();
|
||||
if (phone.at(0) == '0') return phone;
|
||||
|
||||
QString number = phone;
|
||||
for (const QChar *ch = phone.constData(), *e = ch + phone.size(); ch != e; ++ch) {
|
||||
if (ch->unicode() < '0' || ch->unicode() > '9') {
|
||||
number = phone.replace(QRegularExpression(qsl("[^\\d]")), QString());
|
||||
}
|
||||
}
|
||||
QVector<int> groups = phoneNumberParse(number);
|
||||
if (groups.isEmpty()) return '+' + number;
|
||||
|
||||
QString result;
|
||||
result.reserve(number.size() + groups.size() + 1);
|
||||
result.append('+');
|
||||
int32 sum = 0;
|
||||
for (int32 i = 0, l = groups.size(); i < l; ++i) {
|
||||
result.append(number.midRef(sum, groups.at(i)));
|
||||
sum += groups.at(i);
|
||||
if (sum < number.size()) result.append(' ');
|
||||
}
|
||||
if (sum < number.size()) result.append(number.midRef(sum));
|
||||
return result;
|
||||
}
|
||||
|
||||
void initMedia() {
|
||||
Ui::StartCachedCorners();
|
||||
}
|
||||
|
Reference in New Issue
Block a user