File indexing completed on 2024-04-28 16:11:03

0001 /*
0002    SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libruqolacore_export.h"
0010 #include "utils.h"
0011 #include <QDebug>
0012 #include <QIcon>
0013 
0014 class LIBRUQOLACORE_EXPORT ChannelUserCompleter
0015 {
0016     Q_GADGET
0017 public:
0018     ChannelUserCompleter();
0019     ~ChannelUserCompleter();
0020 
0021     enum ChannelUserCompleterType {
0022         Unknown,
0023         Room,
0024         DirectChannel,
0025         Notification,
0026     };
0027     Q_ENUM(ChannelUserCompleterType)
0028 
0029     void parseChannel(const QJsonObject &object, ChannelUserCompleter::ChannelUserCompleterType);
0030 
0031     [[nodiscard]] bool operator==(const ChannelUserCompleter &other) const;
0032 
0033     [[nodiscard]] QString description() const;
0034     void setDescription(const QString &newDescription);
0035 
0036     [[nodiscard]] QString name() const;
0037     void setName(const QString &newName);
0038 
0039     [[nodiscard]] ChannelUserCompleterType type() const;
0040     void setType(ChannelUserCompleterType newType);
0041 
0042     [[nodiscard]] QIcon statusIcon() const;
0043 
0044     [[nodiscard]] QString userName() const;
0045     void setUserName(const QString &newUserName);
0046 
0047     [[nodiscard]] QString avatarTag() const;
0048     void setAvatarTag(const QString &newAvatarTag);
0049 
0050     [[nodiscard]] bool outsideRoom() const;
0051     void setOutsideRoom(bool newOutsideRoom);
0052 
0053     [[nodiscard]] QString completerName() const;
0054 
0055     [[nodiscard]] QString identifier() const;
0056     void setIdentifier(const QString &newIdentifier);
0057 
0058     [[nodiscard]] Utils::AvatarInfo avatarInfo() const;
0059 
0060     void setChannelIcon();
0061 
0062     void setAvatarInfo(const Utils::AvatarInfo &newAvatarInfo);
0063 
0064 private:
0065     LIBRUQOLACORE_NO_EXPORT void createAvatarInfo();
0066     Utils::AvatarInfo mAvatarInfo;
0067     QIcon mStatusIcon;
0068     QString mDescription;
0069     QString mName;
0070     QString mUserName;
0071     QString mAvatarTag;
0072     QString mIdentifier;
0073 
0074     ChannelUserCompleterType mType = ChannelUserCompleterType::Unknown;
0075     bool mOutsideRoom = false;
0076 };
0077 Q_DECLARE_TYPEINFO(ChannelUserCompleter, Q_MOVABLE_TYPE);
0078 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const ChannelUserCompleter &t);