File indexing completed on 2024-12-01 13:34:29

0001 /*
0002    SPDX-FileCopyrightText: 1999-2001 Lubos Lunak <l.lunak@kde.org>
0003    SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
0004 
0005    SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #include "conditions.h"
0009 
0010 #include <KConfigGroup>
0011 
0012 namespace KHotKeys
0013 {
0014 Not_condition::Not_condition(KConfigGroup &cfg_P, Condition_list_base *parent_P)
0015     : Condition_list_base(cfg_P, parent_P)
0016 {
0017 }
0018 
0019 Not_condition::Not_condition(Condition_list_base *parent_P)
0020     : Condition_list_base(parent_P)
0021 {
0022 }
0023 
0024 void Not_condition::cfg_write(KConfigGroup &cfg_P) const
0025 {
0026     base::cfg_write(cfg_P);
0027     cfg_P.writeEntry("Type", "NOT"); // overwrites value set in base::cfg_write()
0028 }
0029 
0030 const Condition *Not_condition::condition() const
0031 {
0032     return first();
0033 }
0034 
0035 Not_condition *Not_condition::copy() const
0036 {
0037     Not_condition *ret = new Not_condition();
0038     if (!isEmpty()) {
0039         ret->append(condition()->copy());
0040     }
0041 
0042     return ret;
0043 }
0044 
0045 const QString Not_condition::description() const
0046 {
0047     return i18nc("Not_condition", "Not");
0048 }
0049 
0050 bool Not_condition::accepts_children() const
0051 {
0052     return count() == 0;
0053 }
0054 
0055 bool Not_condition::match() const
0056 {
0057     return condition() ? !condition()->match() : false;
0058 }
0059 
0060 } // namespace KHotKeys