add more spacing
[personal-kdebase.git] / workspace / khotkeys / libkhotkeysprivate / actions / action_list.cpp
blob8addb6d33ed85c938abc94f7901d61a65ad4b7c4
1 /*
2 Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
3 Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "actions.h"
22 #include <kconfiggroup.h>
24 namespace KHotKeys {
26 ActionList::ActionList( KConfigGroup& cfg_P, ActionData* data_P )
27 : QList< Action* >()
29 int cnt = cfg_P.readEntry( "ActionsCount", 0 );
30 QString save_cfg_group = cfg_P.name();
31 for( int i = 0;
32 i < cnt;
33 ++i )
35 KConfigGroup group( cfg_P.config(), save_cfg_group + QString::number( i ) );
36 Action* action = Action::create_cfg_read( group, data_P );
37 if( action )
38 append( action );
43 ActionList::ActionList( const QString& comment_P )
44 : QList< Action* >(), _comment( comment_P )
48 void ActionList::aboutToBeErased()
50 QListIterator<Action*> it(*this);
51 while (it.hasNext())
53 it.next()->aboutToBeErased();
57 const QString& ActionList::comment() const
59 return _comment;
63 ActionList::~ActionList()
65 while (!isEmpty())
67 delete takeFirst();
72 void ActionList::cfg_write( KConfigGroup& cfg_P ) const
74 QString save_cfg_group = cfg_P.name();
75 int i = 0;
76 for( ActionList::ConstIterator it = begin();
77 it != end();
78 ++it )
80 KConfigGroup group( cfg_P.config(), save_cfg_group + QString::number( i++ ) );
81 (*it)->cfg_write( group );
83 cfg_P.writeEntry( "ActionsCount", i );
86 } // namespace KHotKeys