diff options
Diffstat (limited to 'src/GreetingSetting.hpp')
| -rw-r--r-- | src/GreetingSetting.hpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/GreetingSetting.hpp b/src/GreetingSetting.hpp index 933d4c5..20fce0b 100644 --- a/src/GreetingSetting.hpp +++ b/src/GreetingSetting.hpp @@ -7,14 +7,14 @@ class GreetingSetting { public: + enum Mode {Normal, Notice, Disabled, Unset} mode = Normal; ClientInterface interface; - bool negative = false; QString target = ""; GreetingSetting() { } inline bool operator==(const GreetingSetting& other) { - return other.interface == interface && other.negative == negative && other.target == target; + return other.interface == interface && other.mode == mode && other.target == target; } inline bool operator!=(const GreetingSetting& other) { @@ -23,7 +23,7 @@ public: inline GreetingSetting& invert() { - negative = !negative; + mode = (mode == Disabled) ? Normal : Disabled; return *this; } @@ -52,8 +52,8 @@ public: void setValue(const QString& value) { QString val = value; - bool negative = (value.at(0) == '!'); - if(negative) + GreetingSetting::Mode mode = (value.at(0) == '!') ? GreetingSetting::Disabled : (value.at(0) == '-') ? GreetingSetting::Notice : GreetingSetting::Normal; + if(mode != GreetingSetting::Normal) { val.remove(0, 1); } @@ -62,6 +62,7 @@ public: if(parts.first() == "Clonk" && parts.length() == 1) { conf.interface = Clonk; + conf.mode = mode == GreetingSetting::Disabled ? GreetingSetting::Disabled : GreetingSetting::Normal; conf.target.clear(); } else if(parts.first() == "IRC" && parts.length() <= 2) @@ -75,22 +76,29 @@ public: { conf.target.clear(); } + conf.mode = mode; } else { throw ConfigException("Can not parse corrupt GreetingSetting"); } - - conf.negative = negative; } QString value() { QString ret; - if(conf.negative) + switch(conf.mode) { - ret = "!"; + case GreetingSetting::Disabled: + ret = "!"; + break; + case GreetingSetting::Notice: + ret = "-"; + break; + case GreetingSetting::Normal: case GreetingSetting::Unset: + break; } + QStringList parts = {(conf.interface == Clonk ? "Clonk" : "IRC")}; if(!conf.target.isEmpty()) { |
