Add new search predicate to enable searching for messages matching a regex (#3282)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
LosFarmosCTL
2021-10-17 14:36:44 +02:00
committed by GitHub
parent c1a3814b7c
commit 06245f3713
6 changed files with 109 additions and 39 deletions
+22
View File
@@ -0,0 +1,22 @@
#include "RegexPredicate.hpp"
namespace chatterino {
RegexPredicate::RegexPredicate(const QString &regex)
: regex_(regex, QRegularExpression::CaseInsensitiveOption)
{
}
bool RegexPredicate::appliesTo(const Message &message)
{
if (!regex_.isValid())
{
return false;
}
QRegularExpressionMatch match = regex_.match(message.messageText);
return match.hasMatch();
}
} // namespace chatterino