File indexing completed on 2024-05-12 05:35:40
0001 /* 0002 SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com> 0003 SPDX-FileCopyrightText: 2023 Jeremy Whiting <jpwhiting@kde.org> 0004 SPDX-FileCopyrightText: 2023 Niccolò Venerandi <niccolo@venerandi.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include <QAbstractTableModel> 0012 #include <SDL2/SDL_gamecontroller.h> 0013 0014 class Gamepad; 0015 0016 class ButtonModel : public QAbstractTableModel 0017 { 0018 Q_OBJECT 0019 0020 Q_PROPERTY(Gamepad *device MEMBER m_device NOTIFY deviceChanged REQUIRED) 0021 0022 public: 0023 explicit ButtonModel(QObject *parent = nullptr); 0024 0025 int rowCount(const QModelIndex &) const override; 0026 int columnCount(const QModelIndex &) const override; 0027 0028 QVariant data(const QModelIndex &index, int role) const override; 0029 0030 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0031 0032 Q_SIGNALS: 0033 void deviceChanged(); 0034 0035 private: 0036 Q_SLOT void initDeviceButtons(); 0037 0038 private: 0039 Gamepad *m_device = nullptr; 0040 QList<SDL_GameControllerButton> m_buttons; 0041 };