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

0001 /*
0002    SPDX-FileCopyrightText: 2021-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 class LIBRUQOLACORE_EXPORT DirectoryRoomsModel : public CustomBaseModel
0013 {
0014     Q_OBJECT
0015 public:
0016     enum DirectoryRoomsRoles {
0017         Name,
0018         Topic,
0019         UsersCount,
0020         ReadOnly,
0021         DefaultRoom,
0022         Identifier,
0023         ChannelType,
0024         ChannelTypeStr,
0025         LastMessageDateTime,
0026         CreatedDateTime,
0027         LastMessageStr,
0028         BelongsTo,
0029         CreatedStr,
0030         LastColumn = CreatedStr,
0031     };
0032     Q_ENUM(DirectoryRoomsRoles)
0033 
0034     explicit DirectoryRoomsModel(QObject *parent = nullptr);
0035     ~DirectoryRoomsModel() override;
0036 
0037     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0038     [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
0039     [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0040     [[nodiscard]] int columnCount(const QModelIndex &parent = {}) const override;
0041     [[nodiscard]] int total() const override;
0042 
0043     void parseElements(const QJsonObject &roomsObj) override;
0044 
0045     void addMoreElements(const QJsonObject &discussionsObj) override;
0046     [[nodiscard]] QList<int> excludeResizeToContentColumns() const override;
0047 
0048 protected:
0049     [[nodiscard]] QList<int> hideColumns() const override;
0050 
0051 private:
0052     LIBRUQOLACORE_NO_EXPORT void checkFullList() override;
0053     RoomsInfo mRoomsInfo;
0054 };