not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / khotkeys / libkhotkeysprivate / action_data / action_data_group.cpp
blob3befba71ca72e48b28bb819d68b52f2940b4659b
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 #include "action_data_group.h"
12 #include "actions/actions.h"
14 #include <kconfiggroup.h>
15 #include <kdebug.h>
18 namespace KHotKeys
21 ActionDataGroup::ActionDataGroup(
22 KConfigGroup& cfg_P,
23 ActionDataGroup* parent_P)
24 : ActionDataBase( cfg_P, parent_P )
25 ,_list()
26 ,_system_group()
29 unsigned int system_group_tmp = cfg_P.readEntry( "SystemGroup", 0 );
31 // Correct wrong values
32 if(system_group_tmp >= SYSTEM_MAX)
34 system_group_tmp = 0;
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,
47 bool enabled_P)
48 : ActionDataBase(parent_P, name_P, comment_P, conditions_P, enabled_P)
49 ,_list()
50 ,_system_group(system_group_P)
54 ActionDataGroup::~ActionDataGroup()
56 qDeleteAll(_list);
57 _list.clear();
62 Action::ActionTypes ActionDataGroup::allowedActionTypes() const
64 switch (_system_group)
66 case SYSTEM_MENUENTRIES:
67 return Action::MenuEntryActionType;
69 default:
70 return Action::AllTypes;
75 Trigger::TriggerTypes ActionDataGroup::allowedTriggerTypes() const
77 switch (_system_group)
79 case SYSTEM_MENUENTRIES:
80 return Trigger::ShortcutTriggerType;
82 default:
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
97 return _system_group;
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
120 return _list;
124 void ActionDataGroup::remove_child( ActionDataBase* child_P )
126 _list.removeAll( child_P ); // is not auto-delete
130 int ActionDataGroup::size() const
132 return _list.size();
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