From 6a93688b2e46f051ff80268783c6a8e1a2d7245f Mon Sep 17 00:00:00 2001 From: flow Date: Sun, 28 Aug 2022 22:58:43 -0300 Subject: [PATCH] fix: filtering in regex search in resource packs Signed-off-by: flow --- launcher/minecraft/mod/ResourcePack.cpp | 17 +++++++++++++++++ launcher/minecraft/mod/ResourcePack.h | 1 + 2 files changed, 18 insertions(+) diff --git a/launcher/minecraft/mod/ResourcePack.cpp b/launcher/minecraft/mod/ResourcePack.cpp index cab20b50..5f45254d 100644 --- a/launcher/minecraft/mod/ResourcePack.cpp +++ b/launcher/minecraft/mod/ResourcePack.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "Version.h" @@ -69,3 +70,19 @@ std::pair ResourcePack::compare(const Resource& other, SortType type) } return { 0, false }; } + +bool ResourcePack::applyFilter(QRegularExpression filter) const +{ + if (filter.match(description()).hasMatch()) + return true; + + if (filter.match(QString::number(packFormat())).hasMatch()) + return true; + + if (filter.match(compatibleVersions().first.toString()).hasMatch()) + return true; + if (filter.match(compatibleVersions().second.toString()).hasMatch()) + return true; + + return Resource::applyFilter(filter); +} diff --git a/launcher/minecraft/mod/ResourcePack.h b/launcher/minecraft/mod/ResourcePack.h index 0bd9ebbd..17de86a7 100644 --- a/launcher/minecraft/mod/ResourcePack.h +++ b/launcher/minecraft/mod/ResourcePack.h @@ -35,6 +35,7 @@ class ResourcePack : public Resource { void setDescription(QString new_description); [[nodiscard]] auto compare(Resource const& other, SortType type) const -> std::pair override; + [[nodiscard]] bool applyFilter(QRegularExpression filter) const override; protected: mutable QMutex m_data_lock;