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

0001 #ifndef CONDITION_H
0002 #define CONDITION_H
0003 /* SPDX-FileCopyrightText: 2009 Michael Jansen <kde@michael-jansen.biz>
0004    SPDX-FileCopyrightText: 1999-2001 Lubos Lunak <l.lunak@kde.org>
0005 
0006    SPDX-License-Identifier: LGPL-2.0-only
0007 */
0008 
0009 #include <QObject>
0010 #include <QString>
0011 
0012 class KConfigGroup;
0013 
0014 namespace KHotKeys
0015 {
0016 class ConditionsVisitor;
0017 class Condition_list_base;
0018 
0019 /**
0020  * @author Michael Jansen <kde@michael-jansen.biz>
0021  */
0022 class Q_DECL_EXPORT Condition
0023 {
0024     Q_DISABLE_COPY(Condition)
0025 
0026 public:
0027     Condition(Condition_list_base *parent_P = nullptr);
0028     Condition(KConfigGroup &cfg_P, Condition_list_base *parent_P);
0029     virtual ~Condition();
0030     virtual bool match() const = 0;
0031     virtual void updated() const; // called when the condition changes
0032     virtual void cfg_write(KConfigGroup &cfg_P) const = 0;
0033     virtual const QString description() const = 0;
0034     virtual Condition *copy() const = 0;
0035     const Condition_list_base *parent() const;
0036     Condition_list_base *parent();
0037     static Condition *create_cfg_read(KConfigGroup &cfg_P, Condition_list_base *parent_P);
0038 
0039     // Reparent the condition to another list.
0040     void reparent(Condition_list_base *parent);
0041 
0042     virtual void visit(ConditionsVisitor *visitor);
0043 
0044 protected:
0045     Condition_list_base *_parent;
0046 };
0047 
0048 } // namespace KHotKeys
0049 
0050 #endif /* #ifndef CONDITION_H */