File indexing completed on 2024-02-25 16:44:37

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 
0009 #include "libruqolacore_export.h"
0010 #include "messagesmodel.h"
0011 
0012 class LIBRUQOLACORE_EXPORT ListMessagesModel : public MessagesModel
0013 {
0014     Q_OBJECT
0015 public:
0016     enum ListMessageType {
0017         Unknown = 0,
0018         StarredMessages,
0019         PinnedMessages,
0020         MentionsMessages,
0021         ThreadsMessages,
0022         UnreadThreadsMessages,
0023     };
0024     Q_ENUM(ListMessageType)
0025 
0026     explicit ListMessagesModel(const QString &roomID = QStringLiteral("no_room"),
0027                                RocketChatAccount *account = nullptr,
0028                                Room *room = nullptr,
0029                                QObject *parent = nullptr);
0030     ~ListMessagesModel() override;
0031 
0032     void parseListMessages(const QJsonObject &obj);
0033     void loadMoreListMessages(const QJsonObject &obj);
0034 
0035     [[nodiscard]] int total() const;
0036     void setTotal(int total);
0037 
0038     [[nodiscard]] bool loadMoreListMessagesInProgress() const;
0039     void setLoadMoreListMessagesInProgress(bool inProgress);
0040 
0041     void setHasFullList(bool state);
0042     [[nodiscard]] bool hasFullList() const;
0043 
0044     [[nodiscard]] ListMessageType listMessageType() const;
0045     void setListMessageType(ListMessagesModel::ListMessageType listMessageType);
0046 
0047 Q_SIGNALS:
0048     void hasFullListChanged();
0049     void listMessageTypeChanged();
0050     void totalChanged();
0051     void loadingInProgressChanged();
0052 
0053 private:
0054     LIBRUQOLACORE_NO_EXPORT void parse(const QJsonObject &obj);
0055     int mTotal = -1;
0056     bool mLoadingInProgress = false;
0057     bool mHasFullList = false;
0058     ListMessageType mListMessageType = Unknown;
0059 };