Get rid of deprecated ranges::view usage

This commit is contained in:
Ilya Fedin 2021-03-13 17:12:40 +04:00 committed by John Preston
parent 03f8ab361f
commit c74cf04cc6
5 changed files with 15 additions and 15 deletions

View file

@ -323,12 +323,12 @@ std::vector<QImage> LoadSprites(int id) {
? internal::SetDataPath(id) + '/' ? internal::SetDataPath(id) + '/'
: QStringLiteral(":/gui/emoji/"); : QStringLiteral(":/gui/emoji/");
const auto base = folder + "emoji_"; const auto base = folder + "emoji_";
return ranges::view::ints( return ranges::views::ints(
0, 0,
SpritesCount SpritesCount
) | ranges::view::transform([&](int index) { ) | ranges::views::transform([&](int index) {
return base + QString::number(index + 1) + ".webp"; return base + QString::number(index + 1) + ".webp";
}) | ranges::view::transform([](const QString &path) { }) | ranges::views::transform([](const QString &path) {
return QImage(path, "WEBP").convertToFormat( return QImage(path, "WEBP").convertToFormat(
QImage::Format_ARGB32_Premultiplied); QImage::Format_ARGB32_Premultiplied);
}) | ranges::to_vector; }) | ranges::to_vector;
@ -343,15 +343,15 @@ std::vector<QImage> LoadAndValidateSprites(int id) {
return {}; return {};
} }
auto result = LoadSprites(id); auto result = LoadSprites(id);
const auto sizes = ranges::view::ints( const auto sizes = ranges::views::ints(
0, 0,
SpritesCount SpritesCount
) | ranges::view::transform([](int index) { ) | ranges::views::transform([](int index) {
return QSize( return QSize(
kImagesPerRow * kUniversalSize, kImagesPerRow * kUniversalSize,
RowsCount(index) * kUniversalSize); RowsCount(index) * kUniversalSize);
}); });
const auto good = ranges::view::zip_with( const auto good = ranges::views::zip_with(
[](const QImage &data, QSize size) { return data.size() == size; }, [](const QImage &data, QSize size) { return data.size() == size; },
result, result,
sizes); sizes);
@ -588,10 +588,10 @@ bool SetIsReady(int id) {
return true; return true;
} }
const auto folder = internal::SetDataPath(id) + '/'; const auto folder = internal::SetDataPath(id) + '/';
auto names = ranges::view::ints( auto names = ranges::views::ints(
0, 0,
SpritesCount + 1 SpritesCount + 1
) | ranges::view::transform([](int index) { ) | ranges::views::transform([](int index) {
return index return index
? "emoji_" + QString::number(index) + ".webp" ? "emoji_" + QString::number(index) + ".webp"
: QString("config.json"); : QString("config.json");

View file

@ -274,8 +274,8 @@ QImage BlurLargeImage(QImage image, int radius) {
const auto rgb = take(widthxheight * 3).data(); const auto rgb = take(widthxheight * 3).data();
const auto dvs = take(dvcount); const auto dvs = take(dvcount);
auto &&ints = ranges::view::ints; auto &&ints = ranges::views::ints;
for (auto &&[value, index] : ranges::view::zip(dvs, ints(0, ranges::unreachable))) { for (auto &&[value, index] : ranges::views::zip(dvs, ints(0, ranges::unreachable))) {
value = (index / divsum); value = (index / divsum);
} }
const auto dv = dvs.data(); const auto dv = dvs.data();

View file

@ -147,7 +147,7 @@ float ArcsAnimation::width() const {
if (_arcs.empty()) { if (_arcs.empty()) {
return 0; return 0;
} }
for (const auto &arc : ranges::view::reverse(_arcs)) { for (const auto &arc : ranges::views::reverse(_arcs)) {
if ((arc.progress != 1.)) { if ((arc.progress != 1.)) {
return arc.rect.x() + arc.rect.width(); return arc.rect.x() + arc.rect.width();
} }
@ -159,7 +159,7 @@ float ArcsAnimation::finishedWidth() const {
if (_arcs.empty()) { if (_arcs.empty()) {
return 0; return 0;
} }
for (const auto &arc : ranges::view::reverse(_arcs)) { for (const auto &arc : ranges::views::reverse(_arcs)) {
if (arc.threshold <= _currentValue) { if (arc.threshold <= _currentValue) {
return arc.rect.x() + arc.rect.width(); return arc.rect.x() + arc.rect.width();
} }

View file

@ -233,7 +233,7 @@ void TitleControls::updateControlsPositionBySide(
const std::vector<Control> &controls, const std::vector<Control> &controls,
bool right) { bool right) {
auto preparedControls = right auto preparedControls = right
? (ranges::view::reverse(controls) | ranges::to_vector) ? (ranges::views::reverse(controls) | ranges::to_vector)
: controls; : controls;
RemoveDuplicates(preparedControls); RemoveDuplicates(preparedControls);

View file

@ -1146,7 +1146,7 @@ const QRegularExpression &RegExpWordSplit() {
auto &&urls = ranges::make_subrange( auto &&urls = ranges::make_subrange(
entities.begin(), entities.begin(),
entities.end() entities.end()
) | ranges::view::filter([](const EntityInText &entity) { ) | ranges::views::filter([](const EntityInText &entity) {
return entity.type() == EntityType::CustomUrl; return entity.type() == EntityType::CustomUrl;
}); });
const auto &original = text.text; const auto &original = text.text;
@ -2146,7 +2146,7 @@ int EntityInText::FirstMonospaceOffset(
auto &&monospace = ranges::make_subrange( auto &&monospace = ranges::make_subrange(
entities.begin(), entities.begin(),
entities.end() entities.end()
) | ranges::view::filter([](const EntityInText & entity) { ) | ranges::views::filter([](const EntityInText & entity) {
return (entity.type() == EntityType::Pre) return (entity.type() == EntityType::Pre)
|| (entity.type() == EntityType::Code); || (entity.type() == EntityType::Code);
}); });