File indexing completed on 2024-02-18 15:43:53

0001 /*
0002    SPDX-FileCopyrightText: 2021-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 <QStandardItemModel>
0011 #include <QVector>
0012 class RoleInfo;
0013 class LIBRUQOLACORE_EXPORT RolesModel : public QStandardItemModel
0014 {
0015     Q_OBJECT
0016 public:
0017     enum RolesInfoRoles {
0018         Name = Qt::UserRole + 1,
0019         Identifier,
0020     };
0021     Q_ENUM(RolesInfoRoles)
0022 
0023     explicit RolesModel(QObject *parent = nullptr);
0024     ~RolesModel() override;
0025 
0026     void setRoles(const QVector<RoleInfo> &newRoles);
0027 
0028     [[nodiscard]] QStringList rolesSelected() const;
0029     void setRolesSelected(const QStringList &newRolesSelected);
0030 
0031 private:
0032     LIBRUQOLACORE_NO_EXPORT void createItem(const QString &displayStr, const QString &identifier);
0033 
0034     QStringList mRolesSelected;
0035     void fillRoleSelected();
0036 };