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

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 "libruqolacore_export.h"
0010 #include "oauth/oauthinfo.h"
0011 #include <QAbstractListModel>
0012 
0013 class LIBRUQOLACORE_EXPORT AdminOauthModel : public QAbstractListModel
0014 {
0015     Q_OBJECT
0016 public:
0017     enum AdminOauthRoles {
0018         Identifier,
0019         Name,
0020         ClientId,
0021         ClientSecret,
0022         RedirectUri,
0023         CreatedBy,
0024         CreatedAt,
0025         CreatedAtStr,
0026         Active,
0027         LastColumn = Active,
0028     };
0029     Q_ENUM(AdminOauthRoles)
0030 
0031     explicit AdminOauthModel(QObject *parent = nullptr);
0032     ~AdminOauthModel() override;
0033 
0034     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0035     [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
0036     [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0037     [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0038 
0039     const QVector<OauthInfo> &adminOauth() const;
0040     void setAdminOauth(const QVector<OauthInfo> &newAdminInvites);
0041 
0042     void removeOauth(const QString &identifier);
0043 
0044     void addMoreOauth(const OauthInfo &info);
0045 
0046 private:
0047     LIBRUQOLACORE_NO_EXPORT void clear();
0048     QVector<OauthInfo> mAdminOauth;
0049 };