File indexing completed on 2024-04-28 05:30:28

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2020 Henri Chain <henri.chain@enioka.com>
0006     SPDX-FileCopyrightText: 2021 Ismael Asensio <isma.af@gmail.com>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #pragma once
0012 
0013 #include "rulebooksettingsbase.h"
0014 #include <KSharedConfig>
0015 
0016 namespace KWin
0017 {
0018 class Rules;
0019 class RuleSettings;
0020 
0021 class RuleBookSettings : public RuleBookSettingsBase
0022 {
0023 public:
0024     RuleBookSettings(KSharedConfig::Ptr config, QObject *parent = nullptr);
0025     RuleBookSettings(const QString &configname, KConfig::OpenFlags, QObject *parent = nullptr);
0026     RuleBookSettings(KConfig::OpenFlags, QObject *parent = nullptr);
0027     RuleBookSettings(QObject *parent = nullptr);
0028     ~RuleBookSettings();
0029 
0030     void setRules(const QList<Rules *> &);
0031     QList<Rules *> rules();
0032 
0033     bool usrSave() override;
0034     void usrRead() override;
0035     bool usrIsSaveNeeded() const;
0036 
0037     int ruleCount() const;
0038     RuleSettings *ruleSettingsAt(int row) const;
0039     RuleSettings *insertRuleSettingsAt(int row);
0040     void removeRuleSettingsAt(int row);
0041     void moveRuleSettings(int srcRow, int destRow);
0042 
0043 private:
0044     static QString generateGroupName();
0045 
0046 private:
0047     QList<RuleSettings *> m_list;
0048     QStringList m_storedGroups;
0049 };
0050 
0051 }