summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/HighlightAction.cpp8
-rw-r--r--Swift/Controllers/HighlightAction.h14
-rw-r--r--Swift/Controllers/HighlightManager.cpp12
3 files changed, 18 insertions, 16 deletions
diff --git a/Swift/Controllers/HighlightAction.cpp b/Swift/Controllers/HighlightAction.cpp
index 80d9d85..4603408 100644
--- a/Swift/Controllers/HighlightAction.cpp
+++ b/Swift/Controllers/HighlightAction.cpp
@@ -12,14 +12,14 @@
12 12
13#include <Swift/Controllers/HighlightAction.h> 13#include <Swift/Controllers/HighlightAction.h>
14 14
15namespace Swift { 15namespace Swift {
16 16
17void HighlightAction::setHighlightAllText(bool highlightText) 17void HighlightAction::setHighlightWholeMessage(bool highlightText)
18{ 18{
19 highlightText_ = highlightText; 19 highlightWholeMessage_ = highlightText;
20 if (!highlightText_) { 20 if (!highlightWholeMessage_) {
21 textColor_.clear(); 21 textColor_.clear();
22 textBackground_.clear(); 22 textBackground_.clear();
23 } 23 }
24} 24}
25 25
@@ -30,11 +30,11 @@ void HighlightAction::setPlaySound(bool playSound)
30 soundFile_.clear(); 30 soundFile_.clear();
31 } 31 }
32} 32}
33 33
34bool operator ==(HighlightAction const& a, HighlightAction const& b) { 34bool operator ==(HighlightAction const& a, HighlightAction const& b) {
35 if (a.highlightAllText() != b.highlightAllText()) { 35 if (a.highlightWholeMessage() != b.highlightWholeMessage()) {
36 return false; 36 return false;
37 } 37 }
38 38
39 if (a.getTextColor() != b.getTextColor()) { 39 if (a.getTextColor() != b.getTextColor()) {
40 return false; 40 return false;
diff --git a/Swift/Controllers/HighlightAction.h b/Swift/Controllers/HighlightAction.h
index a9e0cee..3930eee 100644
--- a/Swift/Controllers/HighlightAction.h
+++ b/Swift/Controllers/HighlightAction.h
@@ -12,26 +12,26 @@
12 12
13#pragma once 13#pragma once
14 14
15#include <string> 15#include <string>
16 16
17#include <boost/archive/text_oarchive.hpp>
18#include <boost/archive/text_iarchive.hpp> 17#include <boost/archive/text_iarchive.hpp>
18#include <boost/archive/text_oarchive.hpp>
19 19
20namespace Swift { 20namespace Swift {
21 21
22 class HighlightRule; 22 class HighlightRule;
23 23
24 class HighlightAction { 24 class HighlightAction {
25 public: 25 public:
26 HighlightAction() : highlightText_(false), playSound_(false) {} 26 HighlightAction() : highlightWholeMessage_(false), playSound_(false) {}
27 27
28 /** 28 /**
29 * Gets the flag that indicates the entire message should be highlighted. 29 * Gets the flag that indicates the entire message should be highlighted.
30 */ 30 */
31 bool highlightAllText() const { return highlightText_; } 31 bool highlightWholeMessage() const { return highlightWholeMessage_; }
32 void setHighlightAllText(bool highlightText); 32 void setHighlightWholeMessage(bool highlightText);
33 33
34 /** 34 /**
35 * Gets the foreground highlight color. 35 * Gets the foreground highlight color.
36 */ 36 */
37 const std::string& getTextColor() const { return textColor_; } 37 const std::string& getTextColor() const { return textColor_; }
@@ -50,17 +50,17 @@ namespace Swift {
50 * Gets the sound filename. If the string is empty, assume a default sound file. 50 * Gets the sound filename. If the string is empty, assume a default sound file.
51 */ 51 */
52 const std::string& getSoundFile() const { return soundFile_; } 52 const std::string& getSoundFile() const { return soundFile_; }
53 void setSoundFile(const std::string& soundFile) { soundFile_ = soundFile; } 53 void setSoundFile(const std::string& soundFile) { soundFile_ = soundFile; }
54 54
55 bool isEmpty() const { return !highlightText_ && !playSound_; } 55 bool isEmpty() const { return !highlightWholeMessage_ && !playSound_; }
56 56
57 private: 57 private:
58 friend class boost::serialization::access; 58 friend class boost::serialization::access;
59 template<class Archive> void serialize(Archive & ar, const unsigned int version); 59 template<class Archive> void serialize(Archive & ar, const unsigned int version);
60 60
61 bool highlightText_; 61 bool highlightWholeMessage_;
62 std::string textColor_; 62 std::string textColor_;
63 std::string textBackground_; 63 std::string textBackground_;
64 64
65 bool playSound_; 65 bool playSound_;
66 std::string soundFile_; 66 std::string soundFile_;
@@ -70,11 +70,11 @@ namespace Swift {
70 bool operator !=(HighlightAction const& a, HighlightAction const& b); 70 bool operator !=(HighlightAction const& a, HighlightAction const& b);
71 71
72 template<class Archive> 72 template<class Archive>
73 void HighlightAction::serialize(Archive& ar, const unsigned int /*version*/) 73 void HighlightAction::serialize(Archive& ar, const unsigned int /*version*/)
74 { 74 {
75 ar & highlightText_; 75 ar & highlightWholeMessage_;
76 ar & textColor_; 76 ar & textColor_;
77 ar & textBackground_; 77 ar & textBackground_;
78 ar & playSound_; 78 ar & playSound_;
79 ar & soundFile_; 79 ar & soundFile_;
80 } 80 }
diff --git a/Swift/Controllers/HighlightManager.cpp b/Swift/Controllers/HighlightManager.cpp
index ed49e72..e5c8cef 100644
--- a/Swift/Controllers/HighlightManager.cpp
+++ b/Swift/Controllers/HighlightManager.cpp
@@ -8,25 +8,27 @@
8 * Copyright (c) 2014-2015 Isode Limited. 8 * Copyright (c) 2014-2015 Isode Limited.
9 * All rights reserved. 9 * All rights reserved.
10 * See the COPYING file for more information. 10 * See the COPYING file for more information.
11 */ 11 */
12 12
13#include <Swift/Controllers/HighlightManager.h>
14
13#include <cassert> 15#include <cassert>
14 16
15#include <boost/algorithm/string.hpp> 17#include <boost/algorithm/string.hpp>
16#include <boost/regex.hpp> 18#include <boost/archive/text_iarchive.hpp>
19#include <boost/archive/text_oarchive.hpp>
17#include <boost/bind.hpp> 20#include <boost/bind.hpp>
18#include <boost/numeric/conversion/cast.hpp> 21#include <boost/numeric/conversion/cast.hpp>
22#include <boost/regex.hpp>
19#include <boost/serialization/vector.hpp> 23#include <boost/serialization/vector.hpp>
20#include <boost/archive/text_oarchive.hpp>
21#include <boost/archive/text_iarchive.hpp>
22 24
23#include <Swiften/Base/foreach.h> 25#include <Swiften/Base/foreach.h>
24#include <Swift/Controllers/HighlightManager.h> 26
25#include <Swift/Controllers/Highlighter.h> 27#include <Swift/Controllers/Highlighter.h>
26#include <Swift/Controllers/Settings/SettingsProvider.h>
27#include <Swift/Controllers/SettingConstants.h> 28#include <Swift/Controllers/SettingConstants.h>
29#include <Swift/Controllers/Settings/SettingsProvider.h>
28 30
29/* How does highlighting work? 31/* How does highlighting work?
30 * 32 *
31 * HighlightManager manages a list of if-then rules used to highlight messages. 33 * HighlightManager manages a list of if-then rules used to highlight messages.
32 * Rule is represented by HighlightRule. Action ("then" part) is HighlightAction. 34 * Rule is represented by HighlightRule. Action ("then" part) is HighlightAction.