1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef INPUTDEVICEMODEL_H
#define INPUTDEVICEMODEL_H
#include <QAbstractItemModel>
class QInputDevice;
class InputDeviceModel : public QAbstractItemModel
{
Q_OBJECT
public:
enum Role {
Name = Qt::UserRole + 1,
DeviceType,
PointerType,
Capabilities,
SystemId,
SeatName,
AvailableVirtualGeometry,
MaximumPoints,
ButtonCount,
UniqueId,
NRoles
};
Q_ENUM(Role);
explicit InputDeviceModel(QObject *parent = nullptr);
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
signals:
void deviceAdded(const QObject *o);
private slots:
void onDeviceAdded(const QObject *o);
private:
void watchDevice(const QInputDevice *dev) const;
void deviceDestroyed(QObject *o);
mutable QList<const QInputDevice *> m_known;
};
#endif // INPUTDEVICEMODEL_H
|