not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / khotkeys / libkhotkeysprivate / triggers / trigger_list.cpp
blobcb17b9c16331bbddae27df9b5c2020f2e9a35bf8
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 "triggers.h"
22 #include <KDE/KConfigGroup>
24 namespace KHotKeys {
26 Trigger_list::Trigger_list( KConfigGroup& cfg_P, ActionData* data_P )
27 : QList< Trigger* >()
29 _comment = cfg_P.readEntry( "Comment" );
30 int cnt = cfg_P.readEntry( "TriggersCount", 0 );
31 for( int i = 0;
32 i < cnt;
33 ++i )
35 KConfigGroup triggerConfig( cfg_P.config(), cfg_P.name() + QString::number( i ));
36 Trigger* trigger = Trigger::create_cfg_read( triggerConfig, data_P );
37 if( trigger )
38 append( trigger );
44 Trigger_list::Trigger_list( const QString& comment_P )
45 : QList< Trigger* >(), _comment( comment_P )
50 Trigger_list::~Trigger_list()
52 while (!isEmpty())
54 delete takeFirst();
58 void Trigger_list::aboutToBeErased()
60 QListIterator<Trigger*> it(*this);
61 while (it.hasNext())
63 it.next()->aboutToBeErased();
68 void Trigger_list::cfg_write( KConfigGroup& cfg_P ) const
70 cfg_P.writeEntry( "Comment", comment());
71 int i = 0;
72 for( Trigger_list::ConstIterator it = begin();
73 it != end();
74 ++it )
76 KConfigGroup triggerConfig( cfg_P.config(), cfg_P.name() + QString::number( i++ ));
77 (*it)->cfg_write( triggerConfig );
79 cfg_P.writeEntry( "TriggersCount", i );
83 const QString Trigger_list::comment() const
85 return _comment;
89 Trigger_list* Trigger_list::copy( ActionData* data_P ) const
91 Trigger_list* ret = new Trigger_list( comment());
92 for( Trigger_list::ConstIterator it = begin();
93 it != end();
94 ++it )
96 ret->append( (*it)->copy( data_P ));
98 return ret;
101 void Trigger_list::activate( bool activate_P )
103 for( Trigger_list::Iterator it = begin();
104 it != end();
105 ++it )
107 ( *it )->activate( activate_P );
111 } // namespace KHotKeys