File indexing completed on 2024-02-18 15:43:49

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.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 "roominfo/roomsinfo.h"
0012 
0013 class LIBRUQOLACORE_EXPORT AdminRoomsModel : public CustomBaseModel
0014 {
0015     Q_OBJECT
0016 public:
0017     enum AdminRoomsRoles {
0018         Name,
0019         Topic,
0020         ChannelType,
0021         ChannelTypeStr,
0022         MessagesCount,
0023         UsersCount,
0024         ReadOnly,
0025         DefaultRoom,
0026         Featured,
0027         Identifier,
0028         IsTeam,
0029         LastColumn = IsTeam,
0030     };
0031     Q_ENUM(AdminRoomsRoles)
0032 
0033     explicit AdminRoomsModel(QObject *parent = nullptr);
0034     ~AdminRoomsModel() override;
0035 
0036     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0037     [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
0038     [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0039     [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0040 
0041     [[nodiscard]] RoomsInfo adminRooms() const;
0042 
0043     void setAdminRooms(const RoomsInfo &adminrooms);
0044 
0045     [[nodiscard]] int total() const override;
0046     void parseElements(const QJsonObject &obj) override;
0047     void addMoreElements(const QJsonObject &obj) override;
0048     [[nodiscard]] QList<int> hideColumns() const override;
0049 
0050     void removeElement(const QString &identifier) override;
0051 
0052     void updateElement(const QJsonObject &obj) override;
0053 
0054 private:
0055     LIBRUQOLACORE_NO_EXPORT void checkFullList() override;
0056     RoomsInfo mAdminRooms;
0057 };