-bool IgnoreListManager::scopeMatch(const QString &scopeRule, const QString &string) {
- foreach(QString rule, scopeRule.split(";")) {
- QRegExp ruleRx = QRegExp(rule.trimmed());
- ruleRx.setCaseSensitivity(Qt::CaseInsensitive);
- ruleRx.setPatternSyntax(QRegExp::Wildcard);
- if(ruleRx.exactMatch(string)) {
- return true;
+
+void IgnoreListManager::removeIgnoreListItem(const QString &ignoreRule)
+{
+ removeAt(indexOf(ignoreRule));
+ SYNC(ARG(ignoreRule))
+}
+
+
+void IgnoreListManager::toggleIgnoreRule(const QString &ignoreRule)
+{
+ int idx = indexOf(ignoreRule);
+ if (idx == -1)
+ return;
+ _ignoreList[idx].setIsEnabled(!_ignoreList[idx].isEnabled());
+ SYNC(ARG(ignoreRule))
+}
+
+
+bool IgnoreListManager::ctcpMatch(const QString sender, const QString &network, const QString &type)
+{
+ foreach(IgnoreListItem item, _ignoreList) {
+ if (!item.isEnabled())
+ continue;
+ if (item.scope() == GlobalScope
+ || (item.scope() == NetworkScope && item.scopeRuleMatcher().match(network))) {
+
+ // For CTCP ignore rules, use ctcpSender
+ if (item.senderCTCPMatcher().match(sender)) {
+ // Sender matches, check types
+ if (item.ctcpTypes().isEmpty()
+ || item.ctcpTypes().contains(type, Qt::CaseInsensitive)) {
+ // Either all types are blocked, or type matches
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+
+/**************************************************************************
+ * IgnoreListItem
+ *************************************************************************/
+bool IgnoreListManager::IgnoreListItem::operator!=(const IgnoreListItem &other) const
+{
+ return (_type != other._type ||
+ _contents != other._contents ||
+ _isRegEx != other._isRegEx ||
+ _strictness != other._strictness ||
+ _scope != other._scope ||
+ _scopeRule != other._scopeRule ||
+ _isEnabled != other._isEnabled);
+ // Don't compare ExpressionMatch objects as they are created as needed from the above
+}
+
+
+void IgnoreListManager::IgnoreListItem::determineExpressions() const
+{
+ // Don't update if not needed
+ if (!_cacheInvalid) {
+ return;