File indexing completed on 2024-11-03 11:09:06

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-only
0003     SPDX-FileCopyrightText: 1999-2001 Lubos Lunak <l.lunak@kde.org>
0004  */
0005 
0006 #ifndef ACTION_DATA_H
0007 #define ACTION_DATA_H
0008 
0009 #include "action_data_base.h"
0010 
0011 namespace KHotKeys
0012 {
0013 class Action;
0014 class ActionDataGroup;
0015 class ActionList;
0016 class Trigger_list;
0017 class Trigger;
0018 
0019 // TODO : code documentation
0020 class Q_DECL_EXPORT ActionData : public ActionDataBase
0021 {
0022     typedef ActionDataBase base;
0023 
0024 public:
0025     ActionData(ActionDataGroup *parent_P,
0026                const QString &name_P,
0027                const QString &comment_P,
0028                Trigger_list *triggers_P,
0029                Condition_list *conditions_P,
0030                ActionList *actions_P);
0031 
0032     ~ActionData() override;
0033 
0034     /**
0035      * Visitor pattern
0036      * @reimp
0037      */
0038     void accept(ActionDataVisitor *visitor) override;
0039     void accept(ActionDataConstVisitor *visitor) const override;
0040 
0041     void update_triggers() override;
0042 
0043     virtual void execute();
0044 
0045     /**
0046      * @reimp
0047      */
0048     void aboutToBeErased() override;
0049 
0050     const Trigger_list *triggers() const;
0051     Trigger_list *triggers();
0052 
0053     const ActionList *actions() const;
0054     ActionList *actions();
0055 
0056     virtual void add_trigger(Trigger *trigger_P);
0057 
0058     virtual void add_triggers(Trigger_list *triggers_P); // Trigger_list instance will be deleted
0059 
0060     virtual void set_triggers(Trigger_list *triggers_P);
0061 
0062     virtual void add_action(Action *action_P, Action *after_P = nullptr);
0063 
0064     virtual void add_actions(ActionList *actions_P,
0065                              Action *after_P = nullptr); // ActionList will be deleted
0066 
0067     virtual void set_actions(ActionList *actions_P);
0068 
0069 private:
0070     Trigger_list *_triggers;
0071     ActionList *_actions;
0072 
0073     void doEnable() override;
0074     void doDisable() override;
0075 };
0076 
0077 } // namespace KHotKeys
0078 
0079 #endif