not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / khotkeys / libkhotkeysprivate / action_data / action_data_base.h
blobea57d14803f4fe107ac3f0e61f689aeb86743b91
1 /****************************************************************************
3 KHotKeys
5 Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
7 Distributed under the terms of the GNU General Public License version 2.
9 ****************************************************************************/
11 #ifndef ACTION_DATA_BASE_H
12 #define ACTION_DATA_BASE_H
14 #include "kdemacros.h"
16 #include <QtCore/QString>
19 class KConfigGroup;
22 namespace KHotKeys {
24 class ActionDataGroup;
25 class Condition_list;
27 /**
28 * Base class for all actions.
30 class KDE_EXPORT ActionDataBase
32 Q_DISABLE_COPY( ActionDataBase )
34 public:
36 /**
37 * Create a action data base object.
39 * \param parent_P A ActionDataGroup or 0. If provided this action is
40 * registered with the group.
41 * \param name_P Name for the object.
42 * \param comment_P Comment for the object.
43 * \param condition_P Conditions for the object or 0
44 * \param enabled_P Is the action enabled?
46 ActionDataBase(
47 ActionDataGroup* parent_P,
48 const QString& name_P,
49 const QString& comment_P,
50 Condition_list* condition_P,
51 bool enabled_P );
53 /**
54 * Read the setting for the \c ActionDataBase object from the \a
55 * cfg_P configuration object.
57 * \param cfg_P KConfigGroup to read from
58 * \param parent_P A ActionDataGroup or 0. If provided the object is
59 * registered with the group.
61 ActionDataBase( KConfigGroup& cfg_P, ActionDataGroup* parent_P );
63 /**
64 * Destructor
66 virtual ~ActionDataBase();
68 /**
69 * Write the this action to the \a cfg_P configuration
70 * object.
72 virtual void cfg_write( KConfigGroup& cfg_P ) const = 0;
74 /**
75 * Get the conditions for this action or 0 if the action has no
76 * conditions.
78 const Condition_list* conditions() const;
80 /**
81 * Prepare this action for complete removal.
83 virtual void aboutToBeErased() = 0;
85 /**
86 * Get the \c ActionDataGroup this object belongs to or 0 if it
87 * does not belong to a group.
89 ActionDataGroup* parent() const;
91 /**
92 * Put this action into the group \a new_parent_P. If the action
93 * currently belongs to a group, remove it first. If \a new_parent_P
94 * is 0 the action will be removed from its group.
96 * \param new_parent_P New group or 0.
98 void reparent( ActionDataGroup* new_parent_P );
101 * \todo document this method
103 virtual void update_triggers() = 0;
106 * Check if the conditions match.
108 bool conditions_match() const;
110 //@{
112 * Name for the action
114 QString name() const;
115 void set_name( const QString& name_P );
116 //@}
119 //@{
121 * A comment for this action.
123 QString comment() const;
124 void set_comment( const QString &comment );
125 //@}
127 //@{
129 * Is that action enabled
131 bool enabled( bool ignore_group_P = false ) const;
132 void set_enabled( bool enabled );
133 //@}
136 * Factory method.
138 static ActionDataBase* create_cfg_read( KConfigGroup& cfg_P, ActionDataGroup* parent_P );
141 * See if it the config group is enabled.
143 static bool cfg_is_enabled( KConfigGroup& cfg_P );
145 protected:
147 //! Set the list of condition for this element
148 void set_conditions(Condition_list* conditions_P);
150 private:
152 //! The parent or NULL
153 ActionDataGroup* _parent;
155 //! List of conditions for this element
156 Condition_list* _conditions;
158 //! Name for element
159 QString _name;
161 //! The comment for this element
162 QString _comment;
164 //! If this element is enabled
165 bool _enabled; // is not really important, only used in conf. module and when reading cfg. file
169 } // namespace KHotKeys
171 #endif // ACTION_DATA_BASE_H