File indexing completed on 2024-05-12 16:25:46

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 "libruqolacore_export.h"
0010 #include "roles/roleinfo.h"
0011 #include <QAbstractListModel>
0012 
0013 class LIBRUQOLACORE_EXPORT AdminRolesModel : public QAbstractListModel
0014 {
0015     Q_OBJECT
0016 public:
0017     enum AdminRoles {
0018         Identifier,
0019         Name,
0020         Scope,
0021         Protected,
0022         Mandatory2Fa,
0023         Description,
0024         LastColumn = Description,
0025     };
0026     Q_ENUM(AdminRoles)
0027 
0028     explicit AdminRolesModel(QObject *parent = nullptr);
0029     ~AdminRolesModel() override;
0030 
0031     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0032     [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
0033     [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0034     [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0035 
0036     void setRoles(const QVector<RoleInfo> &newRoles);
0037 
0038     [[nodiscard]] QVector<RoleInfo> roles() const;
0039 
0040 private:
0041     LIBRUQOLACORE_NO_EXPORT void clear();
0042     QVector<RoleInfo> mListRoleInfos;
0043 };