diff options
| author | 2015-04-22 10:57:20 +0200 | |
|---|---|---|
| committer | 2015-04-22 10:57:20 +0200 | |
| commit | 5938230cc183b562ab076dd46dabcaf325a21157 (patch) | |
| tree | 38d993a5d75f2403eba0cb29e17d12727e600a43 | |
| parent | 186af57e85671f0c9c4b2b1faf0d2065f4b0f222 (diff) | |
| download | OneRoll-5938230cc183b562ab076dd46dabcaf325a21157.tar.gz OneRoll-5938230cc183b562ab076dd46dabcaf325a21157.zip | |
add bool value to know if the validator should remove the highlight of some dice
| -rw-r--r-- | booleancondition.cpp | 10 | ||||
| -rw-r--r-- | booleancondition.h | 2 | ||||
| -rw-r--r-- | range.cpp | 15 | ||||
| -rw-r--r-- | range.h | 2 | ||||
| -rw-r--r-- | validator.h | 2 |
5 files changed, 17 insertions, 14 deletions
diff --git a/booleancondition.cpp b/booleancondition.cpp index 267d7e9..de619e7 100644 --- a/booleancondition.cpp +++ b/booleancondition.cpp @@ -25,7 +25,7 @@ BooleanCondition::BooleanCondition() { } -qint64 BooleanCondition::hasValid(Die* b,bool recursive) const +qint64 BooleanCondition::hasValid(Die* b,bool recursive,bool unhighlight) const { QList<qint64> listValues; if(recursive) @@ -40,7 +40,6 @@ qint64 BooleanCondition::hasValid(Die* b,bool recursive) const qint64 sum= 0; foreach(qint64 value, listValues) { - switch(m_operator) { case Equal: @@ -58,11 +57,12 @@ qint64 BooleanCondition::hasValid(Die* b,bool recursive) const case LesserOrEqual: sum+= (value<=m_value)?1:0; break; - - } } - + if((unhighlight)&&(sum==0)) + { + b->setHighlighted(false); + } return sum; } diff --git a/booleancondition.h b/booleancondition.h index 02fadf9..8de8854 100644 --- a/booleancondition.h +++ b/booleancondition.h @@ -31,7 +31,7 @@ public: enum LogicOperator { Equal, GreaterThan, LesserThan, GreaterOrEqual, LesserOrEqual}; BooleanCondition(); - virtual qint64 hasValid(Die* b,bool recursive) const; + virtual qint64 hasValid(Die* b,bool recursive, bool unhighlight = false) const; void setOperator(LogicOperator m); void setValue(qint64); @@ -32,25 +32,28 @@ void Range::setValue(qint64 s,qint64 e) m_end=e; } -qint64 Range::hasValid(Die* m,bool recursive) const +qint64 Range::hasValid(Die* m,bool recursive, bool unhighlight) const { + qint64 result = 0; if(recursive) { - qint64 i = 0; foreach(qint64 value, m->getListValue()) { if((value>=m_start)&&(value<=m_end)) { - ++i; + ++result; } } - return i; } else if((m->getLastRolledValue()>=m_start)&&(m->getLastRolledValue()<=m_end)) { - return 1; + ++result; } - return 0; + if((unhighlight)&&(result==0)) + { + m->setHighlighted(false); + } + return result; } QString Range::toString() { @@ -31,7 +31,7 @@ public: Range(); void setValue(qint64,qint64); - virtual qint64 hasValid(Die* b,bool recursive) const; + virtual qint64 hasValid(Die* b,bool recursive,bool unlight = false) const; virtual QString toString(); virtual quint8 getValidRangeSize(quint64 faces) const; diff --git a/validator.h b/validator.h index c9bb78e..d18a691 100644 --- a/validator.h +++ b/validator.h @@ -30,7 +30,7 @@ class Validator { public: Validator(); - virtual qint64 hasValid(Die* b,bool recursive) const = 0 ; + virtual qint64 hasValid(Die* b,bool recursive,bool unlight = false) const = 0 ; virtual QString toString()=0; virtual quint8 getValidRangeSize(quint64 faces) const = 0 ; |