Changeset View
Changeset View
Standalone View
Standalone View
kcms/keyboard/layoutmodel/layout_list_model_base.cpp
- This file was added.
1 | #include "layout_list_model_base.h" | ||||
---|---|---|---|---|---|
2 | | ||||
3 | #include <algorithm> | ||||
4 | #include <QAbstractProxyModel> | ||||
5 | #include <KConcatenateRowsProxyModel> | ||||
6 | #include <QDebug> | ||||
7 | | ||||
8 | QHash<int, QByteArray> LayoutListModelBase::roleNames() const | ||||
9 | { | ||||
10 | return { | ||||
11 | { Roles::NameRole, "name" }, | ||||
12 | { Roles::DescriptionRole, "description" }, | ||||
13 | { Roles::LanguagesRole, "languages" }, | ||||
14 | { Roles::EnabledRole, "enabled" }, | ||||
15 | { Roles::IsConfigurableRole, "is_configurable" }, | ||||
16 | { Roles::ConfigModelRole, "config_model" }, | ||||
17 | { Roles::SourceRole, "source" }, | ||||
18 | { Roles::PriorityRole, "priority" }, | ||||
19 | { Roles::SaveNameRole, "save_name" }, | ||||
20 | { Roles::IsLatinModeEnabledRole, "is_latin_mode_enabled" }, | ||||
21 | { Roles::LatinModeLayoutRole, "latin_mode_layout" }, | ||||
22 | }; | ||||
23 | } | ||||
24 | | ||||
25 | int LayoutListModelBase::role(QString const& roleName) const | ||||
26 | { | ||||
27 | auto roles = roleNames(); | ||||
28 | for (auto it = roles.keyValueBegin(); it != roles.keyValueEnd(); ++it) { | ||||
29 | if ((*it).second == roleName) { | ||||
30 | return (*it).first; | ||||
31 | } | ||||
32 | } | ||||
33 | return -1; | ||||
34 | } |