2018-03-19 01:36:12 +00:00
|
|
|
#include "Filter.h"
|
|
|
|
|
|
|
|
Filter::~Filter(){}
|
|
|
|
|
|
|
|
ContainsFilter::ContainsFilter(const QString& pattern) : pattern(pattern){}
|
|
|
|
ContainsFilter::~ContainsFilter(){}
|
|
|
|
bool ContainsFilter::accepts(const QString& value)
|
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
return value.contains(pattern);
|
2018-03-19 01:36:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ExactFilter::ExactFilter(const QString& pattern) : pattern(pattern){}
|
|
|
|
ExactFilter::~ExactFilter(){}
|
|
|
|
bool ExactFilter::accepts(const QString& value)
|
|
|
|
{
|
2018-10-31 23:34:31 +00:00
|
|
|
return value == pattern;
|
2018-03-19 01:36:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RegexpFilter::RegexpFilter(const QString& regexp, bool invert)
|
2018-07-15 12:51:05 +00:00
|
|
|
:invert(invert)
|
2018-03-19 01:36:12 +00:00
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
pattern.setPattern(regexp);
|
|
|
|
pattern.optimize();
|
2018-03-19 01:36:12 +00:00
|
|
|
}
|
|
|
|
RegexpFilter::~RegexpFilter(){}
|
|
|
|
bool RegexpFilter::accepts(const QString& value)
|
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
auto match = pattern.match(value);
|
|
|
|
bool matched = match.hasMatch();
|
|
|
|
return invert ? (!matched) : (matched);
|
2018-03-19 01:36:12 +00:00
|
|
|
}
|