Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwineffects/effectsfilterproxymodel.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 Vlad Zagorodniy <vladzzag@gmail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU General Public License | ||||
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
16 | */ | ||||
17 | | ||||
18 | #pragma once | ||||
19 | | ||||
20 | #include <QSortFilterProxyModel> | ||||
21 | | ||||
22 | namespace KWin | ||||
23 | { | ||||
24 | | ||||
25 | class EffectsFilterProxyModel : public QSortFilterProxyModel | ||||
26 | { | ||||
27 | Q_OBJECT | ||||
28 | Q_PROPERTY(QAbstractItemModel *sourceModel READ sourceModel WRITE setSourceModel) | ||||
29 | Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged) | ||||
30 | Q_PROPERTY(bool excludeInternal READ excludeInternal WRITE setExcludeInternal NOTIFY excludeInternalChanged) | ||||
31 | Q_PROPERTY(bool excludeUnsupported READ excludeUnsupported WRITE setExcludeUnsupported NOTIFY excludeUnsupportedChanged) | ||||
32 | | ||||
33 | public: | ||||
34 | explicit EffectsFilterProxyModel(QObject *parent = nullptr); | ||||
35 | ~EffectsFilterProxyModel() override; | ||||
36 | | ||||
37 | QString query() const; | ||||
38 | void setQuery(const QString &query); | ||||
39 | | ||||
40 | bool excludeInternal() const; | ||||
41 | void setExcludeInternal(bool exclude); | ||||
42 | | ||||
43 | bool excludeUnsupported() const; | ||||
44 | void setExcludeUnsupported(bool exclude); | ||||
45 | | ||||
46 | Q_SIGNALS: | ||||
47 | void queryChanged(); | ||||
48 | void excludeInternalChanged(); | ||||
49 | void excludeUnsupportedChanged(); | ||||
50 | | ||||
51 | protected: | ||||
52 | bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; | ||||
53 | | ||||
54 | private: | ||||
55 | QString m_query; | ||||
56 | bool m_excludeInternal = true; | ||||
57 | bool m_excludeUnsupported = true; | ||||
58 | | ||||
59 | Q_DISABLE_COPY(EffectsFilterProxyModel) | ||||
60 | }; | ||||
61 | | ||||
62 | } // namespace KWin |