Changeset View
Changeset View
Standalone View
Standalone View
kcms/keyboard/layoutmodel/layout_list_current_proxy_model.cpp
- This file was added.
1 | #include "layout_list_current_proxy_model.h" | ||||
---|---|---|---|---|---|
2 | #include "input_sources.h" | ||||
3 | #include <QDebug> | ||||
4 | | ||||
5 | LayoutListCurrentProxyModel::LayoutListCurrentProxyModel(QObject* parent) | ||||
6 | : QSortFilterProxyModel(parent) | ||||
7 | { | ||||
8 | connect(InputSources::self(), &InputSources::currentSourceChanged, this, &LayoutListCurrentProxyModel::currentInputSourceChanged); | ||||
9 | } | ||||
10 | | ||||
11 | bool LayoutListCurrentProxyModel::filterAcceptsRow(int source_row, const QModelIndex &) const | ||||
12 | { | ||||
13 | int source = sourceModel()->data( | ||||
14 | sourceModel()->index(source_row, 0), | ||||
15 | Roles::SourceRole).toInt(); | ||||
16 | return source == InputSources::self()->currentSource(); | ||||
17 | } | ||||
18 | | ||||
19 | void LayoutListCurrentProxyModel::currentInputSourceChanged() | ||||
20 | { | ||||
21 | invalidateFilter(); | ||||
22 | } |