File indexing completed on 2024-04-14 08:34:07

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 "libruqolacore_export.h"
0010 #include "user.h"
0011 #include <QDebug>
0012 #include <QVector>
0013 class LIBRUQOLACORE_EXPORT Users
0014 {
0015 public:
0016     enum ParseType {
0017         UserInRoles,
0018         Administrator,
0019         Directory,
0020     };
0021     Users();
0022 
0023     [[nodiscard]] bool isEmpty() const;
0024     void clear();
0025     [[nodiscard]] int count() const;
0026     [[nodiscard]] User at(int index) const;
0027 
0028     [[nodiscard]] User &operator[](int i);
0029 
0030     [[nodiscard]] int offset() const;
0031     void setOffset(int offset);
0032 
0033     [[nodiscard]] int total() const;
0034     void setTotal(int total);
0035 
0036     User takeAt(int index);
0037 
0038     void parseUsers(const QJsonObject &obj, ParseType type, const QVector<RoleInfo> &roleInfo);
0039     void parseMoreUsers(const QJsonObject &obj, ParseType type, const QVector<RoleInfo> &roleInfo);
0040 
0041     [[nodiscard]] QVector<User> users() const;
0042     void setUsers(const QVector<User> &rooms);
0043 
0044     [[nodiscard]] int usersCount() const;
0045     void setUsersCount(int adminroomsCount);
0046 
0047     void insertUser(int index, const User &user);
0048     void appendUser(const User &user);
0049 
0050 private:
0051     LIBRUQOLACORE_NO_EXPORT void parseListUsers(const QJsonObject &obj, ParseType type, const QVector<RoleInfo> &roleInfo);
0052     QVector<User> mUsers;
0053     int mUsersCount = 0;
0054     int mOffset = 0;
0055     int mTotal = 0;
0056 };
0057 
0058 Q_DECLARE_METATYPE(Users)
0059 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const Users &t);