Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/flattentaskgroupsproxymodel.cpp
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | Copyright 2016 Eike Hein <hein@kde.org> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Lesser General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | later version accepted by the membership of KDE e.V. (or its | ||||
9 | successor approved by the membership of KDE e.V.), which shall | ||||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | | ||||
12 | This library is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | Lesser General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU Lesser General Public | ||||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | *********************************************************************/ | ||||
20 | | ||||
21 | #include "flattentaskgroupsproxymodel.h" | ||||
22 | | ||||
23 | namespace TaskManager | ||||
24 | { | ||||
25 | | ||||
26 | class FlattenTaskGroupsProxyModel::Private | ||||
27 | { | ||||
28 | public: | ||||
29 | Private(FlattenTaskGroupsProxyModel *q); | ||||
30 | | ||||
31 | AbstractTasksModelIface *sourceTasksModel = nullptr; | ||||
32 | | ||||
33 | private: | ||||
34 | FlattenTaskGroupsProxyModel *q; | ||||
35 | }; | ||||
36 | | ||||
37 | FlattenTaskGroupsProxyModel::Private::Private(FlattenTaskGroupsProxyModel *q) | ||||
38 | : q(q) | ||||
39 | { | ||||
40 | } | ||||
41 | | ||||
42 | FlattenTaskGroupsProxyModel::FlattenTaskGroupsProxyModel(QObject *parent) | ||||
43 | : KDescendantsProxyModel(parent) | ||||
44 | , d(new Private(this)) | ||||
45 | { | ||||
46 | } | ||||
47 | | ||||
48 | FlattenTaskGroupsProxyModel::~FlattenTaskGroupsProxyModel() | ||||
49 | { | ||||
50 | } | ||||
51 | | ||||
52 | void FlattenTaskGroupsProxyModel::setSourceModel(QAbstractItemModel *sourceModel) | ||||
53 | { | ||||
54 | d->sourceTasksModel = dynamic_cast<AbstractTasksModelIface *>(sourceModel); | ||||
55 | | ||||
56 | KDescendantsProxyModel::setSourceModel(sourceModel); | ||||
57 | } | ||||
58 | | ||||
59 | void FlattenTaskGroupsProxyModel::requestActivate(const QModelIndex &index) | ||||
60 | { | ||||
61 | if (d->sourceTasksModel && index.isValid() && index.model() == this) { | ||||
62 | d->sourceTasksModel->requestActivate(mapToSource(index)); | ||||
63 | } | ||||
64 | } | ||||
65 | | ||||
66 | void FlattenTaskGroupsProxyModel::requestNewInstance(const QModelIndex &index) | ||||
67 | { | ||||
68 | if (d->sourceTasksModel && index.isValid() && index.model() == this) { | ||||
69 | d->sourceTasksModel->requestNewInstance(mapToSource(index)); | ||||
70 | } | ||||
71 | } | ||||
72 | | ||||
73 | void FlattenTaskGroupsProxyModel::requestClose(const QModelIndex &index) | ||||
74 | { | ||||
75 | if (d->sourceTasksModel && index.isValid() && index.model() == this) { | ||||
76 | d->sourceTasksModel->requestClose(mapToSource(index)); | ||||
77 | } | ||||
78 | } | ||||
79 | | ||||
80 | void FlattenTaskGroupsProxyModel::requestMove(const QModelIndex &index) | ||||
81 | { | ||||
82 | if (d->sourceTasksModel && index.isValid() && index.model() == this) { | ||||
83 | d->sourceTasksModel->requestMove(mapToSource(index)); | ||||
84 | } | ||||
85 | } | ||||
86 | | ||||
87 | void FlattenTaskGroupsProxyModel::requestResize(const QModelIndex &index) | ||||
88 | { | ||||
89 | if (d->sourceTasksModel && index.isValid() && index.model() == this) { | ||||
90 | d->sourceTasksModel->requestResize(mapToSource(index)); | ||||
91 | } | ||||
92 | } | ||||
93 | | ||||
94 | void FlattenTaskGroupsProxyModel::requestToggleMinimized(const QModelIndex &index) | ||||
95 | { | ||||
96 | if (d->sourceTasksModel && index.isValid() && index.model() == this) { | ||||
97 | d->sourceTasksModel->requestToggleMinimized(mapToSource(index)); | ||||
98 | } | ||||
99 | } | ||||
100 | | ||||
101 | void FlattenTaskGroupsProxyModel::requestToggleMaximized(const QModelIndex &index) | ||||
102 | { | ||||
103 | if (d->sourceTasksModel && index.isValid() && index.model() == this) { | ||||
104 | d->sourceTasksModel->requestToggleMaximized(mapToSource(index)); | ||||
105 | } | ||||
106 | } | ||||
107 | | ||||
108 | void FlattenTaskGroupsProxyModel::requestToggleKeepAbove(const QModelIndex &index) | ||||
109 | { | ||||
110 | if (d->sourceTasksModel && index.isValid() && index.model() == this) { | ||||
111 | d->sourceTasksModel->requestToggleKeepAbove(mapToSource(index)); | ||||
112 | } | ||||
113 | } | ||||
114 | | ||||
115 | void FlattenTaskGroupsProxyModel::requestToggleKeepBelow(const QModelIndex &index) | ||||
116 | { | ||||
117 | if (d->sourceTasksModel && index.isValid() && index.model() == this) { | ||||
118 | d->sourceTasksModel->requestToggleKeepBelow(mapToSource(index)); | ||||
119 | } | ||||
120 | } | ||||
121 | | ||||
122 | void FlattenTaskGroupsProxyModel::requestToggleFullScreen(const QModelIndex &index) | ||||
123 | { | ||||
124 | if (d->sourceTasksModel && index.isValid() && index.model() == this) { | ||||
125 | d->sourceTasksModel->requestToggleFullScreen(mapToSource(index)); | ||||
126 | } | ||||
127 | } | ||||
128 | | ||||
129 | void FlattenTaskGroupsProxyModel::requestToggleShaded(const QModelIndex &index) | ||||
130 | { | ||||
131 | if (d->sourceTasksModel && index.isValid() && index.model() == this) { | ||||
132 | d->sourceTasksModel->requestToggleShaded(mapToSource(index)); | ||||
133 | } | ||||
134 | } | ||||
135 | | ||||
136 | void FlattenTaskGroupsProxyModel::requestVirtualDesktop(const QModelIndex &index, qint32 desktop) | ||||
137 | { | ||||
138 | if (d->sourceTasksModel && index.isValid() && index.model() == this) { | ||||
139 | d->sourceTasksModel->requestVirtualDesktop(mapToSource(index), desktop); | ||||
140 | } | ||||
141 | } | ||||
142 | | ||||
143 | void FlattenTaskGroupsProxyModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate) | ||||
144 | { | ||||
145 | if (index.isValid() && index.model() == this) { | ||||
146 | d->sourceTasksModel->requestPublishDelegateGeometry(mapToSource(index), geometry, delegate); | ||||
147 | } | ||||
148 | } | ||||
149 | | ||||
150 | } |