fix: filtering in regex search in resource packs

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-08-28 22:58:43 -03:00
parent 3ab17a97a8
commit 6a93688b2e
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
2 changed files with 18 additions and 0 deletions

View File

@ -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);
}

View File

@ -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;