diff options
author | flow <flowlnlnln@gmail.com> | 2022-08-28 22:58:43 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-09-03 13:37:21 -0300 |
commit | 6a93688b2e46f051ff80268783c6a8e1a2d7245f (patch) | |
tree | 02d12ab7602b9d6f1a228bbb59e60f97db1a56de /launcher/minecraft/mod | |
parent | 3ab17a97a8df6c7dd21ccbb1ea349cf3985fafaf (diff) | |
download | PrismLauncher-6a93688b2e46f051ff80268783c6a8e1a2d7245f.tar.gz PrismLauncher-6a93688b2e46f051ff80268783c6a8e1a2d7245f.tar.bz2 PrismLauncher-6a93688b2e46f051ff80268783c6a8e1a2d7245f.zip |
fix: filtering in regex search in resource packs
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/minecraft/mod')
-rw-r--r-- | launcher/minecraft/mod/ResourcePack.cpp | 17 | ||||
-rw-r--r-- | launcher/minecraft/mod/ResourcePack.h | 1 |
2 files changed, 18 insertions, 0 deletions
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 <QDebug> #include <QMap> +#include <QRegularExpression> #include "Version.h" @@ -69,3 +70,19 @@ std::pair<int, bool> 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<int, bool> override; + [[nodiscard]] bool applyFilter(QRegularExpression filter) const override; protected: mutable QMutex m_data_lock; |