File indexing completed on 2024-05-12 16:25:56

0001 /*
0002    SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 #include "libruqolacore_export.h"
0009 #include <QDebug>
0010 #include <QString>
0011 
0012 class LIBRUQOLACORE_EXPORT Role
0013 {
0014 public:
0015     Role();
0016 
0017     [[nodiscard]] QString userId() const;
0018     void setUserId(const QString &userId);
0019 
0020     [[nodiscard]] bool isModerator() const;
0021     void setIsModerator(bool isModerator);
0022 
0023     [[nodiscard]] bool isLeader() const;
0024     void setIsLeader(bool isLeader);
0025 
0026     [[nodiscard]] bool isOwner() const;
0027     void setIsOwner(bool isOwner);
0028 
0029     void parseRole(const QJsonObject &obj);
0030 
0031     [[nodiscard]] bool operator==(const Role &other) const;
0032 
0033     [[nodiscard]] bool isValid() const;
0034     void updateRole(const QString &str, bool b);
0035     [[nodiscard]] bool hasARole() const;
0036 
0037     [[nodiscard]] QString userName() const;
0038     void setUserName(const QString &newUserName);
0039 
0040 private:
0041     QString mUserId;
0042     QString mUserName;
0043     bool mIsModerator = false;
0044     bool mIsLeader = false;
0045     bool mIsOwner = false;
0046 };
0047 Q_DECLARE_METATYPE(Role)
0048 Q_DECLARE_TYPEINFO(Role, Q_MOVABLE_TYPE);
0049 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const Role &t);