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 #include "action_data_group.h"
12 #include "actions/actions.h"
14 #include <kconfiggroup.h>
21 ActionDataGroup::ActionDataGroup(
23 ActionDataGroup
* parent_P
)
24 : ActionDataBase( cfg_P
, parent_P
)
29 unsigned int system_group_tmp
= cfg_P
.readEntry( "SystemGroup", 0 );
31 // Correct wrong values
32 if(system_group_tmp
>= SYSTEM_MAX
)
37 _system_group
= static_cast< system_group_t
>( system_group_tmp
);
41 ActionDataGroup::ActionDataGroup(
42 ActionDataGroup
* parent_P
,
43 const QString
& name_P
,
44 const QString
& comment_P
,
45 Condition_list
* conditions_P
,
46 system_group_t system_group_P
,
48 : ActionDataBase(parent_P
, name_P
, comment_P
, conditions_P
, enabled_P
)
50 ,_system_group(system_group_P
)
54 ActionDataGroup::~ActionDataGroup()
62 Action::ActionTypes
ActionDataGroup::allowedActionTypes() const
64 switch (_system_group
)
66 case SYSTEM_MENUENTRIES
:
67 return Action::MenuEntryActionType
;
70 return Action::AllTypes
;
75 Trigger::TriggerTypes
ActionDataGroup::allowedTriggerTypes() const
77 switch (_system_group
)
79 case SYSTEM_MENUENTRIES
:
80 return Trigger::ShortcutTriggerType
;
83 return Trigger::AllTypes
;
89 bool ActionDataGroup::is_system_group() const
91 return _system_group
!= SYSTEM_NONE
;
95 ActionDataGroup::system_group_t
ActionDataGroup::system_group() const
101 void ActionDataGroup::add_child(ActionDataBase
* child_P
)
103 // Just make sure we don't get the same child twice
104 Q_ASSERT(!_list
.contains(child_P
));
105 _list
.append( child_P
);
109 void ActionDataGroup::aboutToBeErased()
111 Q_FOREACH( ActionDataBase
*child
, _list
)
113 child
->aboutToBeErased();
118 const QList
<ActionDataBase
*> ActionDataGroup::children() const
124 void ActionDataGroup::remove_child( ActionDataBase
* child_P
)
126 _list
.removeAll( child_P
); // is not auto-delete
130 int ActionDataGroup::size() const
136 void ActionDataGroup::cfg_write( KConfigGroup
& cfg_P
) const
138 kDebug() << "Writing group " << cfg_P
.name();
139 ActionDataBase::cfg_write( cfg_P
);
140 cfg_P
.writeEntry( "SystemGroup", int(system_group()));
141 cfg_P
.writeEntry( "Type", "ACTION_DATA_GROUP" );
145 void ActionDataGroup::update_triggers()
147 Q_FOREACH(ActionDataBase
*child
, children())
149 child
->update_triggers();
154 } // namespace KHotKeys