File indexing completed on 2024-12-08 10:25:49

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 "libruqola_private_export.h"
0009 #include "messages/message.h"
0010 #include <QDebug>
0011 class LIBRUQOLACORE_TESTS_EXPORT ListMessages
0012 {
0013 public:
0014     ListMessages();
0015     virtual ~ListMessages();
0016     void parseMessages(const QJsonObject &messagesObj, const QString &arrayName = QStringLiteral("messages"));
0017 
0018     [[nodiscard]] int offset() const;
0019     void setOffset(int offset);
0020 
0021     [[nodiscard]] int total() const;
0022     void setTotal(int total);
0023 
0024     [[nodiscard]] int messagesCount() const;
0025     void setMessagesCount(int listMessagesCount);
0026 
0027     [[nodiscard]] bool isEmpty() const;
0028     void clear();
0029     [[nodiscard]] int count() const;
0030     [[nodiscard]] Message at(int index) const;
0031     [[nodiscard]] QVector<Message> listMessages() const;
0032 
0033 protected:
0034     virtual void parseMessagesList(const QJsonObject &messagesObj, const QString &arrayName);
0035     QVector<Message> mListMessages;
0036 
0037 private:
0038     void parseListInfo(const QJsonObject &messagesObj);
0039     int mMessagesCount = 0;
0040     int mOffset = 0;
0041     int mTotal = 0;
0042 };
0043 Q_DECLARE_METATYPE(ListMessages)
0044 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const ListMessages &t);