File indexing completed on 2024-12-08 13:18:53

0001 #ifndef SETTINGS_WRITER_H
0002 #define SETTINGS_WRITER_H
0003 /**
0004  * SPDX-FileCopyrightText: 1999-2001 Lubos Lunak <l.lunak@kde.org>
0005  * SPDX-FileCopyrightText: 2009 Michael Jansen <kde@michael-jansen.biz>
0006  *
0007  * SPDX-License-Identifier: LGPL-2.0-or-later
0008  **/
0009 
0010 #include "action_data/action_data_visitor.h"
0011 
0012 #include <QStack>
0013 
0014 #include "settings.h"
0015 
0016 class KConfigBase;
0017 class KConfigGroup;
0018 
0019 namespace KHotKeys
0020 {
0021 /**
0022  * @author Michael Jansen <kde@michael-jansen.biz>
0023  */
0024 class SettingsWriter : public ActionDataConstVisitor
0025 {
0026 public:
0027     SettingsWriter(const Settings *settings, ActionState state, const QString &id = QString(), bool allowMerging = false);
0028 
0029     void exportTo(const ActionDataBase *element, KConfigBase &config);
0030 
0031     void writeTo(KConfigBase &cfg);
0032 
0033     void visitActionDataBase(const ActionDataBase *base) override;
0034 
0035     void visitActionData(const ActionData *group) override;
0036 
0037     void visitActionDataGroup(const ActionDataGroup *group) override;
0038 
0039     void visitGenericActionData(const Generic_action_data *data) override;
0040 
0041     void visitMenuentryShortcutActionData(const MenuEntryShortcutActionData *data) override;
0042 
0043     void visitSimpleActionData(const SimpleActionData *data) override;
0044 
0045 private:
0046     const Settings *_settings;
0047 
0048     QStack<KConfigGroup *> _stack;
0049 
0050     ActionState _state;
0051 
0052     QString _importId;
0053 
0054     bool _allowMerging;
0055 
0056     bool _export;
0057 
0058     // Disable copying
0059     SettingsWriter(const SettingsWriter &);
0060     SettingsWriter &operator=(const SettingsWriter &);
0061 
0062 }; // SettingsWriter
0063 
0064 } // namespace KHotKeys
0065 
0066 #endif /* SETTINGS_WRITER_H */