1 /****************************************************************************
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>
24 class ActionDataGroup
;
28 * Base class for all actions.
30 class KDE_EXPORT ActionDataBase
32 Q_DISABLE_COPY( ActionDataBase
)
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?
47 ActionDataGroup
* parent_P
,
48 const QString
& name_P
,
49 const QString
& comment_P
,
50 Condition_list
* condition_P
,
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
);
66 virtual ~ActionDataBase();
69 * Write the this action to the \a cfg_P configuration
72 virtual void cfg_write( KConfigGroup
& cfg_P
) const = 0;
75 * Get the conditions for this action or 0 if the action has no
78 const Condition_list
* conditions() const;
81 * Prepare this action for complete removal.
83 virtual void aboutToBeErased() = 0;
86 * Get the \c ActionDataGroup this object belongs to or 0 if it
87 * does not belong to a group.
89 ActionDataGroup
* parent() const;
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;
112 * Name for the action
114 QString
name() const;
115 void set_name( const QString
& name_P
);
121 * A comment for this action.
123 QString
comment() const;
124 void set_comment( const QString
&comment
);
129 * Is that action enabled
131 bool enabled( bool ignore_group_P
= false ) const;
132 void set_enabled( bool enabled
);
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
);
147 //! Set the list of condition for this element
148 void set_conditions(Condition_list
* conditions_P
);
152 //! The parent or NULL
153 ActionDataGroup
* _parent
;
155 //! List of conditions for this element
156 Condition_list
* _conditions
;
161 //! The comment for this element
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