X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fignorelistmanager.h;h=ef86d5edf88fa5791fd04bac8ebdbfc39bab5d8c;hp=efa007fc8237c1bdbba1b6b5855a6e947ebd2327;hb=cd4f987d0d8ace10272bf1d87c788b741a9e85e8;hpb=76db8cdfbeffaaba359c8e80cf2146da9e9e7f8a diff --git a/src/common/ignorelistmanager.h b/src/common/ignorelistmanager.h index efa007fc..ef86d5ed 100644 --- a/src/common/ignorelistmanager.h +++ b/src/common/ignorelistmanager.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2013 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -22,6 +22,7 @@ #define IGNORELISTMANAGER_H #include +#include #include "message.h" #include "syncableobject.h" @@ -60,10 +61,16 @@ public: ScopeType scope; QString scopeRule; bool isActive; + QRegExp regEx; IgnoreListItem() {} IgnoreListItem(IgnoreType type_, const QString &ignoreRule_, bool isRegEx_, StrictnessType strictness_, ScopeType scope_, const QString &scopeRule_, bool isActive_) - : type(type_), ignoreRule(ignoreRule_), isRegEx(isRegEx_), strictness(strictness_), scope(scope_), scopeRule(scopeRule_), isActive(isActive_) {} + : type(type_), ignoreRule(ignoreRule_), isRegEx(isRegEx_), strictness(strictness_), scope(scope_), scopeRule(scopeRule_), isActive(isActive_), regEx(ignoreRule_) { + regEx.setCaseSensitivity(Qt::CaseInsensitive); + if (!isRegEx_) { + regEx.setPatternSyntax(QRegExp::Wildcard); + } + } bool operator!=(const IgnoreListItem &other) { return (type != other.type || @@ -140,7 +147,19 @@ public slots: protected: void setIgnoreList(const QList &ignoreList) { _ignoreList = ignoreList; } - bool scopeMatch(const QString &scopeRule, const QString &string) const; // scopeRule is a ';'-separated list, string is a network/channel-name + + //! Check if a scope rule matches a string + /** Checks that the string does NOT match ANY inverted rules (prefixed by '!'), then checks that + * it matches AT LEAST one normal (non-inverted) rule. + * + * If only inverted rules are specified, it'll match so long as the string does not match any + * inverted rules (implicit wildcard). + * + * \param scopeRule A ';'-separated list of wildcard expressions, prefix of '!' inverts subrule + * \param string String to test, e.g. network/channel name + * \return True if matches, otherwise false + */ + bool scopeMatch(const QString &scopeRule, const QString &string) const; StrictnessType _match(const QString &msgContents, const QString &msgSender, Message::Type msgType, const QString &network, const QString &bufferName);