fix: filtering in regex search in resource packs
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
3ab17a97a8
commit
6a93688b2e
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user