diff options
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/HighlightAction.cpp | 34 | ||||
-rw-r--r-- | Swift/Controllers/HighlightAction.h | 5 | ||||
-rw-r--r-- | Swift/Controllers/HighlightManager.cpp | 11 | ||||
-rw-r--r-- | Swift/Controllers/HighlightManager.h | 5 | ||||
-rw-r--r-- | Swift/Controllers/HighlightRule.cpp | 38 | ||||
-rw-r--r-- | Swift/Controllers/HighlightRule.h | 4 |
6 files changed, 92 insertions, 5 deletions
diff --git a/Swift/Controllers/HighlightAction.cpp b/Swift/Controllers/HighlightAction.cpp index 492d4d2..80d9d85 100644 --- a/Swift/Controllers/HighlightAction.cpp +++ b/Swift/Controllers/HighlightAction.cpp @@ -4,6 +4,12 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #include <Swift/Controllers/HighlightAction.h> namespace Swift { @@ -25,4 +31,32 @@ void HighlightAction::setPlaySound(bool playSound) } } +bool operator ==(HighlightAction const& a, HighlightAction const& b) { + if (a.highlightAllText() != b.highlightAllText()) { + return false; + } + + if (a.getTextColor() != b.getTextColor()) { + return false; + } + + if (a.getTextBackground() != b.getTextBackground()) { + return false; + } + + if (a.playSound() != b.playSound()) { + return false; + } + + if (a.getSoundFile() != b.getSoundFile()) { + return false; + } + + return true; +} + +bool operator !=(HighlightAction const& a, HighlightAction const& b) { + return !(a == b); +} + } diff --git a/Swift/Controllers/HighlightAction.h b/Swift/Controllers/HighlightAction.h index 8136c62..a9e0cee 100644 --- a/Swift/Controllers/HighlightAction.h +++ b/Swift/Controllers/HighlightAction.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2014 Isode Limited. + * Copyright (c) 2014-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -66,6 +66,9 @@ namespace Swift { std::string soundFile_; }; + bool operator ==(HighlightAction const& a, HighlightAction const& b); + bool operator !=(HighlightAction const& a, HighlightAction const& b); + template<class Archive> void HighlightAction::serialize(Archive& ar, const unsigned int /*version*/) { diff --git a/Swift/Controllers/HighlightManager.cpp b/Swift/Controllers/HighlightManager.cpp index ee1e9ed..383f5df 100644 --- a/Swift/Controllers/HighlightManager.cpp +++ b/Swift/Controllers/HighlightManager.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2014 Isode Limited. + * Copyright (c) 2014-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -75,6 +75,7 @@ std::vector<HighlightRule> HighlightManager::getDefaultRules() HighlightRule r; r.setMatchChat(true); r.getAction().setPlaySound(true); + r.setMatchWholeWords(true); rules.push_back(r); return rules; } @@ -136,4 +137,12 @@ Highlighter* HighlightManager::createHighlighter() return new Highlighter(this); } +bool HighlightManager::isDefaultRulesList() const { + return getDefaultRules() == rules_->list_; +} + +void HighlightManager::resetToDefaultRulesList() { + rules_->list_ = getDefaultRules(); +} + } diff --git a/Swift/Controllers/HighlightManager.h b/Swift/Controllers/HighlightManager.h index 4d94bd2..d37643d 100644 --- a/Swift/Controllers/HighlightManager.h +++ b/Swift/Controllers/HighlightManager.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2014 Isode Limited. + * Copyright (c) 2014-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -48,6 +48,9 @@ namespace Swift { boost::shared_ptr<const HighlightManager::HighlightRulesList> getRules() const { return rules_; } + bool isDefaultRulesList() const; + void resetToDefaultRulesList(); + HighlightRule getRule(int index) const; void setRule(int index, const HighlightRule& rule); void insertRule(int index, const HighlightRule& rule); diff --git a/Swift/Controllers/HighlightRule.cpp b/Swift/Controllers/HighlightRule.cpp index f1a7cef..40b7560 100644 --- a/Swift/Controllers/HighlightRule.cpp +++ b/Swift/Controllers/HighlightRule.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2014 Isode Limited. + * Copyright (c) 2014-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -149,4 +149,40 @@ bool HighlightRule::isEmpty() const return senders_.empty() && keywords_.empty() && !nickIsKeyword_ && !matchChat_ && !matchMUC_ && action_.isEmpty(); } +bool operator ==(HighlightRule const& a, HighlightRule const& b) { + if (a.getSenders() != b.getSenders()) { + return false; + } + + if (a.getKeywords() != b.getKeywords()) { + return false; + } + + if (a.getNickIsKeyword() != b.getNickIsKeyword()) { + return false; + } + + if (a.getMatchChat() != b.getMatchChat()) { + return false; + } + + if (a.getMatchMUC() != b.getMatchMUC()) { + return false; + } + + if (a.getMatchCase() != b.getMatchCase()) { + return false; + } + + if (a.getMatchWholeWords() != b.getMatchWholeWords()) { + return false; + } + + if (a.getAction() != b.getAction()) { + return false; + } + + return true; +} + } diff --git a/Swift/Controllers/HighlightRule.h b/Swift/Controllers/HighlightRule.h index fdc6109..02b4864 100644 --- a/Swift/Controllers/HighlightRule.h +++ b/Swift/Controllers/HighlightRule.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2014 Isode Limited. + * Copyright (c) 2014-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -84,6 +84,8 @@ namespace Swift { HighlightAction action_; }; + bool operator ==(HighlightRule const& a, HighlightRule const& b); + template<class Archive> void HighlightRule::serialize(Archive& ar, const unsigned int /*version*/) { |