Plasma-workspace

taskfilterproxymodel.h
1/*
2 SPDX-FileCopyrightText: 2016 Eike Hein <hein@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#pragma once
8
9#include <QRect>
10#include <QSortFilterProxyModel>
11
12#include <memory>
13
14#include "abstracttasksproxymodeliface.h"
15#include "regionfiltermode.h"
16
17#include "taskmanager_export.h"
18
19namespace TaskManager
20{
21/**
22 * @short A proxy tasks model filtering its source model by various properties.
23 *
24 * This proxy model class filters its source tasks model by properties such as
25 * virtual desktop or minimixed state. The values to filter for or by are set
26 * as properties on the proxy model instance.
27 *
28 * @author Eike Hein <hein@kde.org>
29 **/
30
32{
33 Q_OBJECT
34
35 Q_PROPERTY(QVariant virtualDesktop READ virtualDesktop WRITE setVirtualDesktop NOTIFY virtualDesktopChanged)
36 Q_PROPERTY(QRect screenGeometry READ screenGeometry WRITE setScreenGeometry NOTIFY screenGeometryChanged)
37 Q_PROPERTY(QRect regionGeometry READ regionGeometry WRITE setRegionGeometry NOTIFY regionGeometryChanged)
38 Q_PROPERTY(QString activity READ activity WRITE setActivity NOTIFY activityChanged)
39
40 Q_PROPERTY(bool filterByVirtualDesktop READ filterByVirtualDesktop WRITE setFilterByVirtualDesktop NOTIFY filterByVirtualDesktopChanged)
41 Q_PROPERTY(bool filterByScreen READ filterByScreen WRITE setFilterByScreen NOTIFY filterByScreenChanged)
42 Q_PROPERTY(bool filterByActivity READ filterByActivity WRITE setFilterByActivity NOTIFY filterByActivityChanged)
43 Q_PROPERTY(RegionFilterMode::Mode filterByRegion READ filterByRegion WRITE setFilterByRegion NOTIFY filterByRegionChanged)
44 Q_PROPERTY(bool filterMinimized READ filterMinimized WRITE setFilterMinimized NOTIFY filterMinimizedChanged)
45 Q_PROPERTY(bool filterNotMinimized READ filterNotMinimized WRITE setFilterNotMinimized NOTIFY filterNotMinimizedChanged)
46 Q_PROPERTY(bool filterNotMaximized READ filterNotMaximized WRITE setFilterNotMaximized NOTIFY filterNotMaximizedChanged)
47 Q_PROPERTY(bool filterHidden READ filterHidden WRITE setFilterHidden NOTIFY filterHiddenChanged)
48 Q_PROPERTY(bool filterSkipTaskbar READ filterSkipTaskbar WRITE setFilterSkipTaskbar NOTIFY filterSkipTaskbarChanged)
49 Q_PROPERTY(bool filterSkipPager READ filterSkipPager WRITE setFilterSkipPager NOTIFY filterSkipPagerChanged)
50
51 Q_PROPERTY(bool demandingAttentionSkipsFilters READ demandingAttentionSkipsFilters WRITE setDemandingAttentionSkipsFilters NOTIFY
52 demandingAttentionSkipsFiltersChanged)
53
54public:
55 explicit TaskFilterProxyModel(QObject *parent = nullptr);
56 ~TaskFilterProxyModel() override;
57
58 void setSourceModel(QAbstractItemModel *sourceModel) override;
59
60 /**
61 * The id of the virtual desktop used in filtering by virtual
62 * desktop. Usually set to the id of the current virtual desktop.
63 * Defaults to empty.
64 *
65 * @see setVirtualDesktop
66 * @returns the number of the virtual desktop used in filtering.
67 **/
68 QVariant virtualDesktop() const;
69
70 /**
71 * Set the id of the virtual desktop to use in filtering by virtual
72 * desktop.
73 *
74 * If set to an empty id, filtering by virtual desktop is disabled.
75 *
76 * @see virtualDesktop
77 * @param desktop A virtual desktop id (QString on Wayland; uint >0 on X11).
78 **/
79 void setVirtualDesktop(const QVariant &desktop = QVariant());
80
81 /**
82 * The geometry of the screen used in filtering by screen. Defaults
83 * to a null QRect.
84 *
85 * @see setGeometryScreen
86 * @returns the geometry of the screen used in filtering.
87 **/
88 QRect screenGeometry() const;
89
90 /**
91 * Set the geometry of the screen to use in filtering by screen.
92 *
93 * If set to an invalid QRect, filtering by screen is disabled.
94 *
95 * @see screenGeometry
96 * @param geometry A screen geometry.
97 **/
98 void setScreenGeometry(const QRect &geometry);
99
100 /**
101 * The geometry of the region used in filtering by region. Defaults
102 * to a null QRect.
103 *
104 * @see setRegionGeometry
105 * @since 6.0
106 * @returns the geometry of the region used in filtering.
107 **/
108 QRect regionGeometry() const;
109
110 /**
111 * Set the geometry of the screen to use in filtering by region.
112 *
113 * If set to an invalid QRect, filtering by region is disabled.
114 *
115 * @see regionGeometry
116 * @since 6.0
117 * @param geometry A region geometry.
118 **/
119 void setRegionGeometry(const QRect &geometry);
120
121 /**
122 * The id of the activity used in filtering by activity. Usually
123 * set to the id of the current activity. Defaults to an empty id.
124 *
125 * @see setActivity
126 * @returns the id of the activity used in filtering.
127 **/
128 QString activity() const;
129
130 /**
131 * Set the id of the activity to use in filtering by activity.
132 *
133 * @see activity
134 * @param activity An activity id.
135 **/
136 void setActivity(const QString &activity);
137
138 /**
139 * Whether tasks should be filtered by virtual desktop. Defaults to
140 * @c false.
141 *
142 * Filtering by virtual desktop only happens if a virtual desktop
143 * number greater than -1 is set, even if this returns @c true.
144 *
145 * @see setFilterByVirtualDesktop
146 * @see setVirtualDesktop
147 * @returns @c true if tasks should be filtered by virtual desktop.
148 **/
149 bool filterByVirtualDesktop() const;
150
151 /**
152 * Set whether tasks should be filtered by virtual desktop.
153 *
154 * Filtering by virtual desktop only happens if a virtual desktop
155 * number is set, even if this is set to @c true.
156 *
157 * @see filterByVirtualDesktop
158 * @see setVirtualDesktop
159 * @param filter Whether tasks should be filtered by virtual desktop.
160 **/
161 void setFilterByVirtualDesktop(bool filter);
162
163 /**
164 * Whether tasks should be filtered by screen. Defaults to @c false.
165 *
166 * Filtering by screen only happens if a screen number is set, even
167 * if this returns @c true.
168 *
169 * @see setFilterByScreen
170 * @see setScreenGeometry
171 * @returns @c true if tasks should be filtered by screen.
172 **/
173 bool filterByScreen() const;
174
175 /**
176 * Set whether tasks should be filtered by screen.
177 *
178 * Filtering by screen only happens if a screen number is set, even
179 * if this is set to @c true.
180 *
181 * @see filterByScreen
182 * @see setScreenGeometry
183 * @param filter Whether tasks should be filtered by screen.
184 **/
185 void setFilterByScreen(bool filter);
186
187 /**
188 * Whether tasks should be filtered by activity. Defaults to @c false.
189 *
190 * Filtering by activity only happens if an activity id is set, even
191 * if this returns @c true.
192 *
193 * @see setFilterByActivity
194 * @see setActivity
195 * @returns @ctrue if tasks should be filtered by activity.
196 **/
197 bool filterByActivity() const;
198
199 /**
200 * Set whether tasks should be filtered by activity. Defaults to
201 * @c false.
202 *
203 * Filtering by activity only happens if an activity id is set,
204 * even if this is set to @c true.
205 *
206 * @see filterByActivity
207 * @see setActivity
208 * @param filter Whether tasks should be filtered by activity.
209 **/
210 void setFilterByActivity(bool filter);
211
212 /**
213 * Whether tasks should be filtered by region. Defaults to @c RegionFilterMode::Disabled.
214 *
215 * Filtering by region only happens if a region is set, even
216 * if the filter is enabled.
217 *
218 * @see RegionFilterMode
219 * @see setFilterByRegion
220 * @see setRegionGeometry
221 * @since 6.0
222 * @returns Region filter mode.
223 **/
224 RegionFilterMode::Mode filterByRegion() const;
225
226 /**
227 * Set whether tasks should be filtered by region. Defaults to
228 * @c RegionFilterMode::Disabled.
229 *
230 * Filtering by region only happens if a region is set,
231 * even if the filter is enabled.
232 *
233 * @see RegionFilterMode
234 * @see filterByRegion
235 * @see setRegionGeometry
236 * @since 6.0
237 * @param mode Region filter mode.
238 **/
239 void setFilterByRegion(RegionFilterMode::Mode mode);
240
241 /**
242 * Whether minimized tasks should be filtered out. Defaults to
243 * @c false.
244 *
245 * @returns @c true if minimized tasks should be filtered out.
246 * @see setFilterMinimized
247 * @since 5.27
248 **/
249 bool filterMinimized() const;
250
251 /**
252 * Sets whether non-minimized tasks should be filtered out.
253 *
254 * @param filter Whether minimized tasks should be filtered out.
255 * @see filterMinimized
256 * @since 5.27
257 **/
258 void setFilterMinimized(bool filter);
259
260 /**
261 * Whether non-minimized tasks should be filtered. Defaults to
262 * @c false.
263 *
264 * @see setFilterNotMinimized
265 * @returns @c true if non-minimized tasks should be filtered.
266 **/
267 bool filterNotMinimized() const;
268
269 /**
270 * Set whether non-minimized tasks should be filtered.
271 *
272 * @see filterNotMinimized
273 * @param filter Whether non-minimized tasks should be filtered.
274 **/
275 void setFilterNotMinimized(bool filter);
276
277 /**
278 * Whether non-maximized tasks should be filtered. Defaults to
279 * @c false.
280 *
281 * @see setFilterNotMaximized
282 * @returns @c true if non-maximized tasks should be filtered.
283 **/
284 bool filterNotMaximized() const;
285
286 /**
287 * Set whether non-maximized tasks should be filtered.
288 *
289 * @see filterNotMaximized
290 * @param filter Whether non-maximized tasks should be filtered.
291 **/
292 void setFilterNotMaximized(bool filter);
293
294 /**
295 * Whether hidden tasks should be filtered. Defaults to
296 * @c false.
297 *
298 * @see setFilterHidden
299 * @returns @c true if hidden tasks should be filtered.
300 **/
301 bool filterHidden() const;
302
303 /**
304 * Set whether hidden tasks should be filtered.
305 *
306 * @see filterHidden
307 * @param filter Whether hidden tasks should be filtered.
308 **/
309 void setFilterHidden(bool filter);
310
311 /**
312 * Whether tasks which should be omitted from 'task bars' should be
313 * filtered. Defaults to @c true.
314 *
315 * @see setFilterSkipTaskbar
316 * @returns @c true if tasks which should not be on the 'task bar'
317 * should be filtered.
318 **/
319 bool filterSkipTaskbar() const;
320
321 /**
322 * Set whether tasks which should be omitted from 'task bars' should be
323 * filtered.
324 *
325 * @see filterSkipTaskbar
326 * @param filter Whether tasks whichs should not be on the 'task bar'
327 * should be filtered.
328 **/
329 void setFilterSkipTaskbar(bool filter);
330
331 /**
332 * Whether tasks which should be omitted from 'pagers' should be
333 * filtered. Defaults to @c true.
334 *
335 * @see setFilterSkipPager
336 * @returns @c true if tasks which should not be on the 'pager' should
337 * be filtered.
338 **/
339 bool filterSkipPager() const;
340
341 /**
342 * Set whether tasks which should be omitted from 'pagers' should be
343 * filtered.
344 *
345 * @see filterSkipPager
346 * @param filter Whether tasks which should not be on the 'pager' should
347 * be filtered.
348 **/
349 void setFilterSkipPager(bool filter);
350
351 /**
352 * Whether tasks which demand attention skip filters by virtual desktop
353 * or activity. Defaults to @c true.
354 *
355 * @see setDemandingAttentionSkipsFilters
356 * @returns @c true if tasks which demand attention skip filters.
357 **/
358 bool demandingAttentionSkipsFilters() const;
359
360 /**
361 * Sets whether tasks which demand attention should bypass filters by
362 * virtual desktop or activity.
363 *
364 * @see demandingAttentionSkipsFilters
365 * @param skip Whether tasks which demand attention should skip filters.
366 **/
367 void setDemandingAttentionSkipsFilters(bool skip);
368
369 /**
370 * Returns whether the filter model accepts this source row.
371 *
372 * @param int A row in the source model.
373 */
374 bool acceptsRow(int sourceRow) const;
375
376Q_SIGNALS:
377 void virtualDesktopChanged() const;
378 void screenGeometryChanged() const;
379 void regionGeometryChanged();
380 void activityChanged() const;
381 void filterByVirtualDesktopChanged() const;
382 void filterByScreenChanged() const;
383 void filterByActivityChanged() const;
384 void filterByRegionChanged();
385 void filterMinimizedChanged();
386 void filterNotMinimizedChanged() const;
387 void filterNotMaximizedChanged() const;
388 void filterHiddenChanged() const;
389 void filterSkipTaskbarChanged() const;
390 void filterSkipPagerChanged() const;
391 void demandingAttentionSkipsFiltersChanged() const;
392
393protected:
394 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
395 QModelIndex mapIfaceToSource(const QModelIndex &index) const override;
396
397private:
398 class Private;
399 std::unique_ptr<Private> d;
400};
401
402}
Pure method interface for tasks model implementations.
A proxy tasks model filtering its source model by various properties.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:55:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.