Changeset View
Changeset View
Standalone View
Standalone View
kcms/keyboard/kcmui/keyboard_model_model.h
- This file was added.
1 | #ifndef KCM_KEYBOARD_KEYBOARDMODELMODEL_H | ||||
---|---|---|---|---|---|
2 | #define KCM_KEYBOARD_KEYBOARDMODELMODEL_H | ||||
3 | | ||||
4 | #include <QAbstractListModel> | ||||
5 | #include <QVector> | ||||
6 | | ||||
7 | #include "../xkb_rules.h" | ||||
8 | | ||||
9 | class KeyboardModelModel : public QAbstractListModel { | ||||
10 | Q_OBJECT | ||||
11 | | ||||
12 | public: | ||||
13 | explicit KeyboardModelModel(XkbRules const& rules, QObject* parent = nullptr); | ||||
14 | | ||||
15 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||||
16 | | ||||
17 | QVariant data(const QModelIndex& index, int role) const override; | ||||
18 | | ||||
19 | Qt::ItemFlags flags(const QModelIndex& index) const override; | ||||
20 | | ||||
21 | struct Roles { | ||||
22 | enum { | ||||
23 | DescriptionRole = Qt::UserRole + 1, | ||||
24 | NameRole, | ||||
25 | }; | ||||
26 | }; | ||||
27 | | ||||
28 | QHash<int, QByteArray> roleNames() const override; | ||||
29 | | ||||
30 | public: | ||||
31 | int findIndexByName(QString const& name) const; | ||||
32 | | ||||
33 | private: | ||||
34 | struct KeyboardModel { | ||||
35 | QString vendor; | ||||
36 | QString name; | ||||
37 | QString description; | ||||
38 | | ||||
39 | QString display_text() const; | ||||
40 | }; | ||||
41 | QVector<KeyboardModel> m_list; | ||||
42 | }; | ||||
43 | | ||||
44 | #endif // KCM_KEYBOARD_KEYBOARDMODELMODEL_H |