File indexing completed on 2024-05-26 05:33:04
0001 /* 0002 SPDX-FileCopyrightText: 2020 Ismael Asensio <isma.af@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include "rulebooksettings.h" 0010 #include "rulesettings.h" 0011 0012 #include <QAbstractListModel> 0013 0014 namespace KWin 0015 { 0016 0017 class RuleBookModel : public QAbstractListModel 0018 { 0019 Q_OBJECT 0020 0021 public: 0022 enum { 0023 DescriptionRole = Qt::DisplayRole, 0024 }; 0025 0026 explicit RuleBookModel(QObject *parent = nullptr); 0027 ~RuleBookModel(); 0028 0029 QHash<int, QByteArray> roleNames() const override; 0030 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0031 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0032 bool setData(const QModelIndex &index, const QVariant &value, int role) override; 0033 0034 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; 0035 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; 0036 bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, 0037 const QModelIndex &destinationParent, int destinationChild) override; 0038 0039 QString descriptionAt(int row) const; 0040 void setDescriptionAt(int row, const QString &description); 0041 0042 RuleSettings *ruleSettingsAt(int row) const; 0043 void setRuleSettingsAt(int row, const RuleSettings &settings); 0044 0045 void load(); 0046 void save(); 0047 bool isSaveNeeded(); 0048 0049 // Helper function to copy RuleSettings properties 0050 static void copySettingsTo(RuleSettings *dest, const RuleSettings &source); 0051 0052 private: 0053 RuleBookSettings *m_ruleBook; 0054 }; 0055 0056 } // namespace