File indexing completed on 2024-11-10 12:55:28

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 <QDateTime>
0011 #include <QDebug>
0012 #include <QJsonObject>
0013 class LIBRUQOLACORE_EXPORT ChannelCounterInfo
0014 {
0015 public:
0016     ChannelCounterInfo();
0017     ~ChannelCounterInfo();
0018     void parseCounterInfo(const QJsonObject &replyObject);
0019 
0020     [[nodiscard]] bool operator==(const ChannelCounterInfo &other) const;
0021     [[nodiscard]] bool operator!=(const ChannelCounterInfo &other) const;
0022     [[nodiscard]] quint64 unreadMessages() const;
0023     void setUnreadMessages(quint64 unreadMessages);
0024 
0025     [[nodiscard]] QDateTime unreadFrom() const;
0026     void setUnreadFrom(const QDateTime &unreadFrom);
0027 
0028     [[nodiscard]] quint64 messageCount() const;
0029     void setMessageCount(quint64 messageCount);
0030 
0031     [[nodiscard]] bool joined() const;
0032     void setJoined(bool joined);
0033 
0034     [[nodiscard]] bool isValid() const;
0035 
0036     [[nodiscard]] qint64 unreadMessageTimeStep() const;
0037     void setUnreadMessageTimeStep(qint64 unreadMessageTimeStep);
0038 
0039 private:
0040     QDateTime mUnreadFrom;
0041     quint64 mUnreadMessages = 0;
0042     quint64 mMessageCount = 0;
0043     qint64 mUnreadMessageTimeStep = 0;
0044     bool mJoined = false;
0045 };
0046 Q_DECLARE_METATYPE(ChannelCounterInfo)
0047 Q_DECLARE_TYPEINFO(ChannelCounterInfo, Q_MOVABLE_TYPE);
0048 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const ChannelCounterInfo &t);