File indexing completed on 2024-11-03 11:09:06

0001 /*
0002    SPDX-FileCopyrightText: 1999-2001 Lubos Lunak <l.lunak@kde.org>
0003    SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
0004 
0005    SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #include "actions.h"
0009 
0010 #include <kconfiggroup.h>
0011 #include <ksharedconfig.h>
0012 
0013 namespace KHotKeys
0014 {
0015 ActionList::ActionList(const QString &comment_P)
0016     : QList<Action *>()
0017     , _comment(comment_P)
0018 {
0019 }
0020 
0021 void ActionList::aboutToBeErased()
0022 {
0023     QListIterator<Action *> it(*this);
0024     while (it.hasNext()) {
0025         it.next()->aboutToBeErased();
0026     }
0027 }
0028 
0029 const QString &ActionList::comment() const
0030 {
0031     return _comment;
0032 }
0033 
0034 ActionList::~ActionList()
0035 {
0036     while (!isEmpty()) {
0037         delete takeFirst();
0038     }
0039 }
0040 
0041 void ActionList::cfg_write(KConfigGroup &cfg_P) const
0042 {
0043     QString save_cfg_group = cfg_P.name();
0044     int i = 0;
0045     for (ActionList::ConstIterator it = begin(); it != end(); ++it) {
0046         KConfigGroup group(cfg_P.config(), save_cfg_group + QString::number(i++));
0047         (*it)->cfg_write(group);
0048     }
0049     cfg_P.writeEntry("ActionsCount", i);
0050 }
0051 
0052 } // namespace KHotKeys