File indexing completed on 2024-04-14 04:54:41

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 "commands/commands.h"
0010 #include "libruqolacore_export.h"
0011 #include <QAbstractListModel>
0012 
0013 // Model showing all emojis
0014 class LIBRUQOLACORE_EXPORT CommandsModel : public QAbstractListModel
0015 {
0016     Q_OBJECT
0017 public:
0018     enum CommandsRoles {
0019         CommandName = Qt::UserRole + 1,
0020         CompleterName, // keep value in sync with InputCompleterModel
0021         Description,
0022         Parameters,
0023         TranslatedDescription,
0024         TranslatedParams,
0025         Permissions,
0026     };
0027     Q_ENUM(CommandsRoles)
0028 
0029     explicit CommandsModel(QObject *parent = nullptr);
0030     ~CommandsModel() override;
0031 
0032     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0033     [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
0034 
0035     [[nodiscard]] Commands commands() const;
0036 
0037     void setCommands(const Commands &emoticons);
0038 
0039 private:
0040     LIBRUQOLACORE_NO_EXPORT void clear();
0041     Commands mCommands;
0042 };