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

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 "invite/inviteinfo.h"
0010 #include "libruqolacore_export.h"
0011 #include <QAbstractListModel>
0012 
0013 class LIBRUQOLACORE_EXPORT AdminInviteModel : public QAbstractListModel
0014 {
0015     Q_OBJECT
0016 public:
0017     enum AdminInviteRoles {
0018         UserIdentifier,
0019         Identifier,
0020         RoomId,
0021         CreateAt,
0022         CreateAtStr,
0023         Expire,
0024         Uses,
0025         MaxUses,
0026         LastColumn = MaxUses,
0027     };
0028     Q_ENUM(AdminInviteRoles)
0029 
0030     explicit AdminInviteModel(QObject *parent = nullptr);
0031     ~AdminInviteModel() override;
0032 
0033     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0034     [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
0035     [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0036     [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0037 
0038     [[nodiscard]] const QVector<InviteInfo> &adminInvites() const;
0039     void setAdminInvites(const QVector<InviteInfo> &newAdminInvites);
0040 
0041     void removeInvite(const QString &identifier);
0042 
0043 private:
0044     [[nodiscard]] LIBRUQOLACORE_NO_EXPORT QString expireInvitation(const InviteInfo &inviteInfo) const;
0045     LIBRUQOLACORE_NO_EXPORT void clear();
0046     QVector<InviteInfo> mAdminInvites;
0047 };