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:
@@ -0,0 +1,22 @@
|
||||
#include "RegexPredicate.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
RegexPredicate::RegexPredicate(const QString ®ex)
|
||||
: 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
|
||||
Reference in New Issue
Block a user