X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fignorelistmanager.cpp;h=dfd9ae2db03b1b747db4a53cb67ca5036b801ddd;hp=a9fb4c68e7fd656d7efa8d1b2df3e99d20f6bf5c;hb=f19fea582ace1d8f3dfe29c1096c48758079e56e;hpb=27302bba72a29977e81b9a0b2d8cde3a62ebc818 diff --git a/src/common/ignorelistmanager.cpp b/src/common/ignorelistmanager.cpp index a9fb4c68..dfd9ae2d 100644 --- a/src/common/ignorelistmanager.cpp +++ b/src/common/ignorelistmanager.cpp @@ -26,6 +26,8 @@ #include "message.h" +INIT_SYNCABLE_OBJECT(IgnoreListManager) + IgnoreListManager &IgnoreListManager::operator=(const IgnoreListManager &other) { if(this == &other) return *this; @@ -97,19 +99,22 @@ void IgnoreListManager::initSetIgnoreList(const QVariantMap &ignoreList) { } } +/* since overloaded methods aren't syncable (yet?) we can't use that anymore void IgnoreListManager::addIgnoreListItem(const IgnoreListItem &item) { addIgnoreListItem(item.type, item.ignoreRule, item.isRegEx, item.strictness, item.scope, item.scopeRule, item.isActive); } - -void IgnoreListManager::addIgnoreListItem(IgnoreType type, const QString &ignoreRule, bool isRegEx, StrictnessType strictness, - ScopeType scope, const QString &scopeRule, bool isActive) { +*/ +void IgnoreListManager::addIgnoreListItem(int type, const QString &ignoreRule, bool isRegEx, int strictness, + int scope, const QString &scopeRule, bool isActive) { if(contains(ignoreRule)) { return; } - _ignoreList << IgnoreListItem(type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive); + IgnoreListItem newItem = IgnoreListItem(static_cast(type), ignoreRule, isRegEx, static_cast(strictness), + static_cast(scope), scopeRule, isActive); + _ignoreList << newItem; - emit ignoreAdded(type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive); + SYNC(ARG(type), ARG(ignoreRule), ARG(isRegEx), ARG(strictness), ARG(scope), ARG(scopeRule), ARG(isActive)) } IgnoreListManager::StrictnessType IgnoreListManager::match(const Message &msg, const QString &network) { @@ -149,7 +154,7 @@ IgnoreListManager::StrictnessType IgnoreListManager::match(const Message &msg, c return UnmatchedStrictness; } -bool IgnoreListManager::scopeMatch(const QString &scopeRule, const QString &string) { +bool IgnoreListManager::scopeMatch(const QString &scopeRule, const QString &string) const { foreach(QString rule, scopeRule.split(";")) { QRegExp ruleRx = QRegExp(rule.trimmed()); ruleRx.setCaseSensitivity(Qt::CaseInsensitive); @@ -160,3 +165,16 @@ bool IgnoreListManager::scopeMatch(const QString &scopeRule, const QString &stri } return false; } + +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].isActive = !_ignoreList[idx].isActive; + SYNC(ARG(ignoreRule)) +}