Changeset View
Changeset View
Standalone View
Standalone View
kcms/keyboard/layoutmodel/xkb_layout_config_model.cpp
- This file was added.
1 | #include "xkb_layout_config_model.h" | ||||
---|---|---|---|---|---|
2 | | ||||
3 | #include "../xkb_rules.h" | ||||
4 | #include <QDebug> | ||||
5 | | ||||
6 | XkbLayoutConfigModel::XkbLayoutConfigModel(XkbRules* rules, QObject* parent) | ||||
7 | : QAbstractItemModel(parent) | ||||
8 | , m_rules(rules) | ||||
9 | { | ||||
10 | } | ||||
11 | | ||||
12 | QModelIndex XkbLayoutConfigModel::index(int row, int column, const QModelIndex&) const | ||||
13 | { | ||||
14 | return createIndex(row, column, quintptr(row)); | ||||
15 | } | ||||
16 | | ||||
17 | QModelIndex XkbLayoutConfigModel::parent(const QModelIndex&) const | ||||
18 | { | ||||
19 | return QModelIndex(); | ||||
20 | } | ||||
21 | | ||||
22 | int XkbLayoutConfigModel::rowCount(const QModelIndex& parent) const | ||||
23 | { | ||||
24 | if (parent.isValid()) { | ||||
25 | return 0; | ||||
26 | } | ||||
27 | return m_rules->optionGroupInfos.size(); | ||||
28 | } | ||||
29 | | ||||
30 | int XkbLayoutConfigModel::columnCount(const QModelIndex& parent) const | ||||
31 | { | ||||
32 | if (parent.isValid()) { | ||||
33 | return 0; | ||||
34 | } | ||||
35 | return m_rules->optionGroupInfos.size(); | ||||
36 | } | ||||
37 | | ||||
38 | QVariant XkbLayoutConfigModel::data(const QModelIndex& index, int role) const | ||||
39 | { | ||||
40 | if (!index.isValid()) { | ||||
41 | return QVariant(); | ||||
42 | } | ||||
43 | | ||||
44 | if (role == Roles::DescriptionRole) { | ||||
45 | return m_rules->optionGroupInfos[index.row()]->description; | ||||
46 | } | ||||
47 | return QVariant(); | ||||
48 | } | ||||
49 | | ||||
50 | QHash<int, QByteArray> XkbLayoutConfigModel::roleNames() const | ||||
51 | { | ||||
52 | return { | ||||
53 | { Roles::DescriptionRole, "description" } | ||||
54 | }; | ||||
55 | } | ||||
56 | | ||||
57 | void XkbLayoutConfigModel::save() const | ||||
58 | { | ||||
59 | qDebug() << "save"; | ||||
60 | } |