File indexing completed on 2024-12-01 07:41:12

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 "libruqolacore_export.h"
0010 #include "teams/teaminfo.h"
0011 #include <QDebug>
0012 #include <QJsonObject>
0013 #include <QString>
0014 
0015 class LIBRUQOLACORE_EXPORT RoomInfo
0016 {
0017 public:
0018     RoomInfo();
0019     ~RoomInfo();
0020     [[nodiscard]] bool operator==(const RoomInfo &other) const;
0021     void parseRoomInfo(const QJsonObject &object);
0022 
0023     [[nodiscard]] bool defaultRoom() const;
0024     void setDefaultRoom(bool defaultRoom);
0025 
0026     [[nodiscard]] int usersCount() const;
0027     void setUsersCount(int usersCount);
0028 
0029     [[nodiscard]] int messageCount() const;
0030     void setMessageCount(int messageCount);
0031 
0032     [[nodiscard]] QString channelType() const;
0033     void setChannelType(const QString &channelType);
0034 
0035     [[nodiscard]] QString identifier() const;
0036     void setIdentifier(const QString &identifier);
0037 
0038     [[nodiscard]] QString topic() const;
0039     void setTopic(const QString &topic);
0040 
0041     [[nodiscard]] bool readOnly() const;
0042     void setReadOnly(bool readOnly);
0043 
0044     [[nodiscard]] QString name() const;
0045     void setName(const QString &name);
0046 
0047     [[nodiscard]] QStringList userNames() const;
0048     void setUserNames(const QStringList &userNames);
0049 
0050     [[nodiscard]] QStringList users() const;
0051     void setUsers(const QStringList &users);
0052 
0053     [[nodiscard]] QString channelTypeStr() const;
0054 
0055     [[nodiscard]] QString roomName() const;
0056 
0057     [[nodiscard]] const TeamInfo &teamInfo() const;
0058     void setTeamInfo(const TeamInfo &newTeamInfo);
0059 
0060     [[nodiscard]] qint64 lastMessage() const;
0061     void setLastMessage(qint64 newLastMessage);
0062 
0063     [[nodiscard]] QString lastMessageDisplayDateTimeStr() const;
0064 
0065     [[nodiscard]] qint64 createdRoom() const;
0066     void setCreatedRoom(qint64 newCreatedRoom);
0067 
0068     [[nodiscard]] QString createdRoomDisplayDateTimeStr() const;
0069 
0070     [[nodiscard]] bool featured() const;
0071     void setFeatured(bool newFeatured);
0072 
0073     [[nodiscard]] const QString &description() const;
0074     void setDescription(const QString &newDescription);
0075 
0076     [[nodiscard]] const QString &announcement() const;
0077     void setAnnouncement(const QString &newAnnouncement);
0078 
0079     [[nodiscard]] const QString &ownerName() const;
0080     void setOwnerName(const QString &newOwnerName);
0081 
0082     [[nodiscard]] bool isTeam() const;
0083 
0084     [[nodiscard]] QString belongsTo() const;
0085     void setBelongsTo(const QString &newBelongsTo);
0086 
0087 private:
0088     LIBRUQOLACORE_NO_EXPORT void generateDisplayChannelType();
0089     TeamInfo mTeamInfo;
0090     QStringList mUserNames;
0091     QStringList mUsers;
0092     QString mTopic;
0093     QString mIdentifier;
0094     QString mChannelType;
0095     QString mChannelTypeStr;
0096     QString mName;
0097     QString mLastMessageDisplayTime;
0098     QString mCreatedRoomDisplayTime;
0099     QString mDescription;
0100     QString mAnnouncement;
0101     QString mOwnerName;
0102     QString mBelongsTo;
0103     qint64 mLastMessage = -1;
0104     qint64 mCreatedRoom = -1;
0105     int mMessageCount = -1;
0106     int mUsersCount = -1;
0107     bool mDefaultRoom = false;
0108     bool mReadOnly = false;
0109     bool mFeatured = false;
0110 };
0111 Q_DECLARE_METATYPE(RoomInfo)
0112 Q_DECLARE_TYPEINFO(RoomInfo, Q_RELOCATABLE_TYPE);
0113 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const RoomInfo &t);