File indexing completed on 2024-04-21 05:25:19

0001 /*
0002     SPDX-FileCopyrightText: 2022 Aditya Mehra <aix.m@outlook.com>
0003     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 */
0005 
0006 #ifndef KEYMAPMODEL_H
0007 #define KEYMAPMODEL_H
0008 
0009 #include <QAbstractListModel>
0010 #include <QObject>
0011 #include "keydisplayprovider.h"
0012 
0013 class KeyMapModel : public QAbstractListModel
0014 {
0015     Q_OBJECT
0016 
0017 public:
0018     explicit KeyMapModel(QObject *parent = nullptr);
0019     ~KeyMapModel();
0020     QHash<int, QByteArray> roleNames() const override;
0021     int rowCount(const QModelIndex &) const override;
0022     QVariant data(const QModelIndex &index, int role) const override;
0023     Q_INVOKABLE QVariantMap get(int index) const;
0024     int count() const;
0025     void load();
0026     void refresh();
0027 
0028     enum Roles {
0029         DeviceTypeRole = Qt::UserRole + 1,
0030         ButtonDisplayRole,
0031         ButtonTypeRole,
0032         ObjectNameRole,
0033         AssignedKeyRole,
0034         AssignedKeyDisplayRole,
0035         AssignedKeyIconRole
0036     };
0037 
0038     Q_ENUM(Roles)
0039      
0040 private:
0041     QHash<int, QByteArray> m_roleNames;
0042     QVector<QVariantMap>  m_keyMap;
0043     KeyDisplayProvider *m_keyDisplayProvider;
0044 };
0045 
0046 #endif // KEYMAPMODEL_H