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 "roles/roleinfo.h"
0012 #include "users.h"
0013 
0014 class LIBRUQOLACORE_EXPORT DirectoryUsersModel : public CustomBaseModel
0015 {
0016     Q_OBJECT
0017 public:
0018     enum DirectoryUsersRoles {
0019         Name,
0020         Email,
0021         JoinAt,
0022         UserId,
0023         JoinAtDateTime,
0024         UserName,
0025         LastColumn = UserName,
0026     };
0027     Q_ENUM(DirectoryUsersRoles)
0028     explicit DirectoryUsersModel(QObject *parent = nullptr);
0029     ~DirectoryUsersModel() override;
0030 
0031     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0032     [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
0033     [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0034     [[nodiscard]] int total() const override;
0035 
0036     void parseElements(const QJsonObject &obj) override;
0037     void addMoreElements(const QJsonObject &obj) override;
0038 
0039     [[nodiscard]] int columnCount(const QModelIndex &parent = {}) const override;
0040 
0041     void setRoles(const QVector<RoleInfo> &newRoles);
0042 
0043 protected:
0044     [[nodiscard]] QList<int> hideColumns() const override;
0045     [[nodiscard]] virtual Users::ParseType parseType() const;
0046     Users mUsers;
0047     QVector<RoleInfo> mRoleInfo;
0048     void checkFullList() override;
0049 };