mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Simplified ranges::find_if with ranges::any_of and ranges::none_of.
This commit is contained in:
@@ -145,8 +145,8 @@ void ChatData::refreshBotStatus() {
|
||||
if (participants.empty()) {
|
||||
botStatus = 0;
|
||||
} else {
|
||||
const auto bot = ranges::find_if(participants, &UserData::isBot);
|
||||
botStatus = (bot == end(participants)) ? -1 : 2;
|
||||
const auto bot = ranges::none_of(participants, &UserData::isBot);
|
||||
botStatus = bot ? -1 : 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1482,7 +1482,7 @@ bool DocumentData::isAudioFile() const {
|
||||
}
|
||||
const auto left = _mimeString.midRef(prefix.size()).toString();
|
||||
const auto types = { qstr("x-wav"), qstr("wav"), qstr("mp4") };
|
||||
return ranges::find(types, left) != end(types);
|
||||
return ranges::contains(types, left);
|
||||
}
|
||||
|
||||
bool DocumentData::isSharedMediaMusic() const {
|
||||
|
@@ -548,10 +548,9 @@ bool Histories::postponeHistoryRequest(const State &state) const {
|
||||
}
|
||||
|
||||
bool Histories::postponeEntryRequest(const State &state) const {
|
||||
const auto i = ranges::find_if(state.sent, [](const auto &pair) {
|
||||
return ranges::any_of(state.sent, [](const auto &pair) {
|
||||
return pair.second.type != RequestType::History;
|
||||
});
|
||||
return (i != end(state.sent));
|
||||
}
|
||||
|
||||
void Histories::deleteMessages(
|
||||
|
@@ -416,7 +416,7 @@ QString PeerData::computeUnavailableReason() const {
|
||||
auto &&filtered = ranges::view::all(
|
||||
list
|
||||
) | ranges::view::filter([&](const Data::UnavailableReason &reason) {
|
||||
return ranges::find(skip, reason.reason) == end(skip);
|
||||
return !ranges::contains(skip, reason.reason);
|
||||
});
|
||||
const auto first = filtered.begin();
|
||||
return (first != filtered.end()) ? first->text : QString();
|
||||
|
@@ -236,7 +236,7 @@ PollData::Flags PollData::flags() const {
|
||||
}
|
||||
|
||||
bool PollData::voted() const {
|
||||
return ranges::find(answers, true, &PollAnswer::chosen) != end(answers);
|
||||
return ranges::contains(answers, true, &PollAnswer::chosen);
|
||||
}
|
||||
|
||||
bool PollData::closed() const {
|
||||
|
@@ -3822,10 +3822,7 @@ void Session::setWallpapers(const QVector<MTPWallPaper> &data, int32 hash) {
|
||||
_wallpapers.push_back(*parsed);
|
||||
}
|
||||
}
|
||||
const auto defaultFound = ranges::find_if(
|
||||
_wallpapers,
|
||||
Data::IsDefaultWallPaper);
|
||||
if (defaultFound == end(_wallpapers)) {
|
||||
if (ranges::none_of(_wallpapers, Data::IsDefaultWallPaper)) {
|
||||
_wallpapers.push_back(Data::DefaultWallPaper());
|
||||
_wallpapers.back().setLocalImageAsThumbnail(std::make_shared<Image>(
|
||||
u":/gui/arg/bg.jpg"_q));
|
||||
|
@@ -51,11 +51,11 @@ std::optional<QColor> MaybeColorFromSerialized(quint32 serialized) {
|
||||
std::optional<QColor> ColorFromString(const QString &string) {
|
||||
if (string.size() != 6) {
|
||||
return {};
|
||||
} else if (ranges::find_if(string, [](QChar ch) {
|
||||
} else if (ranges::any_of(string, [](QChar ch) {
|
||||
return (ch < 'a' || ch > 'f')
|
||||
&& (ch < 'A' || ch > 'F')
|
||||
&& (ch < '0' || ch > '9');
|
||||
}) != string.end()) {
|
||||
})) {
|
||||
return {};
|
||||
}
|
||||
const auto component = [](const QString &text, int index) {
|
||||
|
Reference in New Issue
Block a user