File indexing completed on 2024-02-25 16:44:38

0001 /*
0002    SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "custombasemodel.h"
0010 #include "libruqolacore_export.h"
0011 #include "moderation/moderationinfos.h"
0012 
0013 class LIBRUQOLACORE_EXPORT ModerationModel : public CustomBaseModel
0014 {
0015     Q_OBJECT
0016 public:
0017     enum ModerationInfoRoles {
0018         Name,
0019         UserName,
0020         Message,
0021         RoomName,
0022         ReportDate,
0023         Reports,
0024         UserDeleted,
0025         UserId,
0026         MessageId,
0027         LastColumn = MessageId,
0028     };
0029     Q_ENUM(ModerationInfoRoles)
0030 
0031     explicit ModerationModel(QObject *parent = nullptr);
0032     ~ModerationModel() override;
0033 
0034     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0035     [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
0036     [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0037     [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0038 
0039     [[nodiscard]] int total() const override;
0040     void parseElements(const QJsonObject &obj) override;
0041     void addMoreElements(const QJsonObject &obj) override;
0042     [[nodiscard]] QList<int> hideColumns() const override;
0043 
0044     void removeElement(const QString &identifier) override;
0045 
0046     [[nodiscard]] const ModerationInfos &moderationInfos() const;
0047     void setModerationInfos(const ModerationInfos &newDeviceInfos);
0048 
0049 private:
0050     LIBRUQOLACORE_NO_EXPORT void checkFullList() override;
0051     LIBRUQOLACORE_NO_EXPORT void clear();
0052     ModerationInfos mModerationInfos;
0053 };