Baloo
9#include "regexpcache.h"
10#include "baloodebug.h"
14RegExpCache::RegExpCache()
18RegExpCache::~RegExpCache()
22bool RegExpCache::exactMatch(
const QString& s)
const
24 if (m_exactMatches.contains(s)) {
27 for (
const QRegularExpression& filter : std::as_const(m_regexpCache)) {
28 if (
filter.match(s).hasMatch()) {
35void RegExpCache::rebuildCacheFromFilterList(
const QStringList& filters)
37 m_regexpCache.clear();
38 m_exactMatches.clear();
41 QRegularExpression suffixOnlyRe(QStringLiteral(
"^\\*\\.([^.\\*\\?]+)$"));
44 for (
const QString& filter : filters) {
50 auto m = suffixOnlyRe.match(f);
53 suffixes += m.captured(1);
56 f.
replace(QLatin1Char(
'.'), QStringLiteral(
"\\."));
57 f.
replace(QLatin1Char(
'?'), QLatin1Char(
'.'));
58 f.
replace(QStringLiteral(
"*"), QStringLiteral(
".*"));
59 f = QLatin1String(
"^") + f + QLatin1String(
"$");
61 m_regexpCache.append(QRegularExpression(f));
65 QString suffixMatch = QStringLiteral(
"^.*\\.(")
66 + suffixes.
join(QLatin1Char(
'|'))
67 + QStringLiteral(
")$");
69 m_regexpCache.prepend(QRegularExpression(suffixMatch));
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QString join(QChar separator) const const
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:50:57 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.