MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / fillNames

Method fillNames

Telegram/SourceFiles/data/data_peer.cpp:1091–1145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1089}
1090
1091void PeerData::fillNames() {
1092 _nameWords.clear();
1093 _nameFirstLetters.clear();
1094 auto toIndexList = QStringList();
1095 auto appendToIndex = [&](const QString &value) {
1096 if (!value.isEmpty()) {
1097 toIndexList.push_back(TextUtilities::RemoveAccents(value));
1098 }
1099 };
1100
1101 appendToIndex(name());
1102 const auto appendTranslit = !toIndexList.isEmpty()
1103 && cRussianLetters().match(toIndexList.front()).hasMatch();
1104 if (appendTranslit) {
1105 appendToIndex(translitRusEng(toIndexList.front()));
1106 }
1107 if (const auto user = asUser()) {
1108 if (user->nameOrPhone != name()) {
1109 appendToIndex(user->nameOrPhone);
1110 }
1111 appendToIndex(user->username());
1112 if (isSelf()) {
1113 const auto english = u"Saved messages"_q;
1114 const auto localized = tr::lng_saved_messages(tr::now);
1115 appendToIndex(english);
1116 if (localized != english) {
1117 appendToIndex(localized);
1118 }
1119 } else if (isRepliesChat()) {
1120 const auto english = u"Replies"_q;
1121 const auto localized = tr::lng_replies_messages(tr::now);
1122 appendToIndex(english);
1123 if (localized != english) {
1124 appendToIndex(localized);
1125 }
1126 } else if (isVerifyCodes()) {
1127 const auto english = u"Verification Codes"_q;
1128 const auto localized = tr::lng_verification_codes(tr::now);
1129 appendToIndex(english);
1130 if (localized != english) {
1131 appendToIndex(localized);
1132 }
1133 }
1134 } else if (const auto channel = asChannel()) {
1135 appendToIndex(channel->username());
1136 }
1137 auto toIndex = toIndexList.join(' ');
1138 toIndex += ' ' + rusKeyboardLayoutSwitch(toIndex);
1139
1140 const auto namesList = TextUtilities::PrepareSearchWords(toIndex);
1141 for (const auto &name : namesList) {
1142 _nameWords.insert(name);
1143 _nameFirstLetters.insert(name[0]);
1144 }
1145}
1146
1147PeerData::~PeerData() = default;
1148

Callers

nothing calls this directly

Calls 9

nameFunction · 0.85
translitRusEngFunction · 0.85
rusKeyboardLayoutSwitchFunction · 0.85
frontMethod · 0.80
joinMethod · 0.80
clearMethod · 0.45
isEmptyMethod · 0.45
usernameMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected