1 /*
2    SPDX-FileCopyrightText: 1999-2001 Lubos Lunak <l.lunak@kde.org>
3    SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
4 
5    SPDX-License-Identifier: LGPL-2.0-only
6 */
7 
8 #include "conditions.h"
9 
10 #include <KConfigGroup>
11 
12 namespace KHotKeys
13 {
Or_condition(KConfigGroup & cfg_P,Condition_list_base * parent_P)14 Or_condition::Or_condition(KConfigGroup &cfg_P, Condition_list_base *parent_P)
15     : Condition_list_base(cfg_P, parent_P)
16 {
17 }
18 
Or_condition(Condition_list_base * parent_P)19 Or_condition::Or_condition(Condition_list_base *parent_P)
20     : Condition_list_base(parent_P)
21 {
22 }
23 
match() const24 bool Or_condition::match() const
25 {
26     if (count() == 0) // empty => ok
27         return true;
28     for (ConstIterator it(begin()); it != end(); ++it)
29         if ((*it)->match()) // OR
30             return true;
31     return false;
32 }
33 
cfg_write(KConfigGroup & cfg_P) const34 void Or_condition::cfg_write(KConfigGroup &cfg_P) const
35 {
36     base::cfg_write(cfg_P);
37     cfg_P.writeEntry("Type", "OR"); // overwrites value set in base::cfg_write()
38 }
39 
copy() const40 Or_condition *Or_condition::copy() const
41 {
42     Or_condition *ret = new Or_condition();
43     for (ConstIterator it(begin()); it != end(); ++it)
44         ret->append((*it)->copy());
45     return ret;
46 }
47 
description() const48 const QString Or_condition::description() const
49 {
50     return i18nc("Or_condition", "Or");
51 }
52 
53 } // namespace KHotKeys
54