~nonlimited/nmmd/trunk

« back to all changes in this revision

Viewing changes to Automation/Conditions/Base/Condition.cpp

  • Committer: Karsten Krispin
  • Date: 2010-11-19 16:50:50 UTC
  • Revision ID: k@kulthauskante.de-20101119165050-lhga5zznmejt6nnx
- added setEnabled() to Conditions.
  => if a condition is not enabled, it is always false.

- This implied on LogicContainer as they can now be activated or deactivated
  and this reflects on all children-condition

- Therefore removed setState()-stuff from LogicContainer again

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
{
11
11
        _configured = false;
12
12
        _lastState = false;
 
13
 
 
14
        m_enabled = true;
13
15
}
14
16
 
15
17
void Condition::configure(const ConfigNode &config)
80
82
{
81
83
        
82
84
        bool currState = this->statement();
 
85
 
 
86
        /* if we are disabled, a condition is always false */
 
87
        if(!m_enabled)
 
88
                currState = false;
83
89
        
84
90
        /* check whether statement changed and handle changes */
85
91
        if(currState && !_lastState)
90
96
        _lastState = currState;
91
97
}
92
98
 
 
99
void Condition::setEnabled(bool enabled)
 
100
{
 
101
        m_enabled = enabled;
 
102
        QList<QObject*> childConditions = this->children();
 
103
 
 
104
        /* propagate to children */
 
105
        while(!childConditions.empty())
 
106
        {
 
107
                Condition * cond = qobject_cast<Condition*>(childConditions.takeFirst());
 
108
                if(!cond)
 
109
                        continue;
 
110
                cond->setEnabled(enabled);
 
111
        }
 
112
        this->check();
 
113
}
93
114
 
94
115
Condition::List Condition::conditions()
95
116
{
125
146
{
126
147
        return qobject_cast<Condition*>(Object::create("Condition", type, parent, config));
127
148
}
 
149
 
 
150
void Condition::reset()
 
151
{
 
152
        Object::reset();
 
153
        this->setEnabled(true);
 
154
}