File indexing completed on 2024-12-08 04:33:17
0001 /* 0002 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QAbstractListModel> 0010 0011 #include "libruqolacore_export.h" 0012 #include "notificationinfo.h" 0013 #include <QVector> 0014 0015 class LIBRUQOLACORE_EXPORT NotificationHistoryModel : public QAbstractListModel 0016 { 0017 Q_OBJECT 0018 public: 0019 enum NotificationHistoryRoles { 0020 AccountName = Qt::UserRole + 1, 0021 DateTime, 0022 MessageStr, 0023 RoomId, 0024 RoomName, 0025 ChannelType, 0026 Pixmap, 0027 SenderName, 0028 SenderUserName, 0029 MessageId, 0030 }; 0031 Q_ENUM(NotificationHistoryRoles) 0032 0033 explicit NotificationHistoryModel(QObject *parent = nullptr); 0034 ~NotificationHistoryModel() override; 0035 0036 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0037 [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override; 0038 0039 void clear(); 0040 0041 void insertNotifications(const QVector<NotificationInfo> &infos); 0042 0043 void addNotification(const NotificationInfo &info); 0044 0045 private: 0046 [[nodiscard]] LIBRUQOLACORE_NO_EXPORT QString generateMessage(const NotificationInfo &info) const; 0047 QVector<NotificationInfo> mNotificationInfo; 0048 };