File indexing completed on 2024-09-29 10:14:49
0001 // SPDX-FileCopyrightText: 2023 Rishi Kumar <rsi.dev17@gmail.com> 0002 // SPDX-License-Identifier: GPL-3.0-or-later 0003 0004 #pragma once 0005 0006 #include "admin/federationinfo.h" 0007 0008 #include <QAbstractListModel> 0009 #include <QUrl> 0010 0011 class FederationToolModel : public QAbstractListModel 0012 { 0013 Q_OBJECT 0014 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) 0015 Q_PROPERTY(FederationAction federationAction READ federationAction WRITE setFederationAction NOTIFY federationActionChanged) 0016 0017 public: 0018 enum CustomRoles { 0019 IdRole, 0020 DomainRole, 0021 CreatedAtRole, 0022 SeverityRole, 0023 RejectMediaRole, 0024 RejectReportsRole, 0025 PrivateCommentRole, 0026 PublicCommentRole, 0027 ObfuscateRole 0028 }; 0029 0030 enum FederationAction { 0031 AllowedDomains, 0032 BlockedDomains, 0033 }; 0034 0035 Q_ENUM(FederationAction) 0036 0037 explicit FederationToolModel(QObject *parent = nullptr); 0038 0039 void clear(); 0040 0041 QVariant data(const QModelIndex &index, int role) const override; 0042 int rowCount(const QModelIndex &parent) const override; 0043 QHash<int, QByteArray> roleNames() const override; 0044 0045 bool loading() const; 0046 void setLoading(bool loading); 0047 FederationToolModel::FederationAction federationAction() const; 0048 void setFederationAction(const FederationToolModel::FederationAction &federationAction); 0049 void filltimeline(FederationAction action = FederationAction::BlockedDomains); 0050 0051 Q_INVOKABLE void removeDomainBlock(const int &row); 0052 Q_INVOKABLE void removeAllowedDomain(const int &row); 0053 Q_INVOKABLE void updateDomainBlock(const int &row, 0054 const QString &severity, 0055 const QString &publicComment, 0056 const QString &privateComment, 0057 const bool &rejectMedia, 0058 const bool &rejectReports, 0059 const bool &obfuscateReport); 0060 Q_INVOKABLE void newDomainBlock(const QString &domain, 0061 const QString &severity, 0062 const QString &publicComment, 0063 const QString &privateComment, 0064 const bool &rejectMedia, 0065 const bool &rejectReports, 0066 const bool &obfuscateReport); 0067 Q_INVOKABLE void newDomainAllow(const QString &domain); 0068 0069 Q_SIGNALS: 0070 void loadingChanged(); 0071 void federationActionChanged(); 0072 0073 private: 0074 QList<FederationInfo> m_federations; 0075 bool m_loading = false; 0076 FederationToolModel::FederationAction m_federationAction = FederationAction::BlockedDomains; 0077 QUrl m_next; 0078 };