Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/tasksmodel.h
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | Copyright 2016 Eike Hein <hein.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 | #ifndef TASKSMODEL_H | ||||
22 | #define TASKSMODEL_H | ||||
23 | | ||||
24 | #include <QSortFilterProxyModel> | ||||
25 | | ||||
26 | #include "abstracttasksmodeliface.h" | ||||
27 | | ||||
28 | #include "taskmanager_export.h" | ||||
29 | | ||||
30 | namespace TaskManager | ||||
31 | { | ||||
32 | | ||||
33 | /** | ||||
34 | * @short A unified tasks model. | ||||
35 | * | ||||
36 | * This model presents tasks sourced from supplied launcher URLs, startup | ||||
37 | * notification data and window data retrieved from the windowing server | ||||
38 | * the host process is connected to. The underlying windowing system is | ||||
39 | * abstracted away. | ||||
40 | * | ||||
41 | * The source data is abstracted into a unified lifecycle for tasks | ||||
42 | * suitable for presentation in a user interface. | ||||
43 | * | ||||
44 | * Matching startup and window tasks replace launcher tasks. Startup | ||||
45 | * tasks are omitted when matching window tasks exist. Tasks that desire | ||||
46 | * not to be shown in a user interface are omitted. | ||||
47 | * | ||||
48 | * Tasks may be filtered, sorted or grouped by setting properties on the | ||||
49 | * model. | ||||
50 | * | ||||
51 | * Tasks may be interacted with by calling methods on the model. | ||||
52 | * | ||||
53 | * @author Eike Hein <hein@kde.org> | ||||
54 | **/ | ||||
55 | | ||||
56 | class TASKMANAGER_EXPORT TasksModel : public QSortFilterProxyModel, public AbstractTasksModelIface | ||||
57 | { | ||||
58 | Q_OBJECT | ||||
59 | | ||||
60 | Q_ENUMS(SortMode) | ||||
61 | Q_ENUMS(GroupMode) | ||||
62 | | ||||
63 | Q_PROPERTY(int count READ rowCount NOTIFY countChanged) | ||||
64 | Q_PROPERTY(int launcherCount READ launcherCount NOTIFY launcherCountChanged) | ||||
65 | | ||||
66 | Q_PROPERTY(QStringList launcherList READ launcherList WRITE setLauncherList NOTIFY launcherListChanged) | ||||
67 | | ||||
68 | Q_PROPERTY(bool anyTaskDemandsAttention READ anyTaskDemandsAttention NOTIFY anyTaskDemandsAttentionChanged) | ||||
69 | | ||||
70 | Q_PROPERTY(int virtualDesktop READ virtualDesktop WRITE setVirtualDesktop NOTIFY virtualDesktopChanged) | ||||
71 | Q_PROPERTY(int screen READ screen WRITE setScreen NOTIFY screenChanged) | ||||
72 | Q_PROPERTY(QString activity READ activity WRITE setActivity NOTIFY activityChanged) | ||||
73 | | ||||
74 | Q_PROPERTY(bool filterByVirtualDesktop READ filterByVirtualDesktop WRITE setFilterByVirtualDesktop NOTIFY filterByVirtualDesktopChanged) | ||||
75 | Q_PROPERTY(bool filterByScreen READ filterByScreen WRITE setFilterByScreen NOTIFY filterByScreenChanged) | ||||
76 | Q_PROPERTY(bool filterByActivity READ filterByActivity WRITE setFilterByActivity NOTIFY filterByActivityChanged) | ||||
77 | Q_PROPERTY(bool filterNotMinimized READ filterNotMinimized WRITE setFilterNotMinimized NOTIFY filterNotMinimizedChanged) | ||||
78 | | ||||
79 | Q_PROPERTY(SortMode sortMode READ sortMode WRITE setSortMode NOTIFY sortModeChanged) | ||||
80 | Q_PROPERTY(bool separateLaunchers READ separateLaunchers WRITE setSeparateLaunchers NOTIFY separateLaunchersChanged) | ||||
81 | Q_PROPERTY(bool launchInPlace READ launchInPlace WRITE setLaunchInPlace NOTIFY launchInPlaceChanged) | ||||
82 | | ||||
83 | Q_PROPERTY(GroupMode groupMode READ groupMode WRITE setGroupMode NOTIFY groupModeChanged) | ||||
84 | Q_PROPERTY(int groupingWindowTasksThreshold READ groupingWindowTasksThreshold | ||||
85 | WRITE setGroupingWindowTasksThreshold NOTIFY groupingWindowTasksThresholdChanged) | ||||
86 | Q_PROPERTY(QStringList groupingAppIdBlacklist READ groupingAppIdBlacklist | ||||
87 | WRITE setGroupingAppIdBlacklist NOTIFY groupingAppIdBlacklistChanged) | ||||
88 | Q_PROPERTY(QStringList groupingLauncherUrlBlacklist READ groupingLauncherUrlBlacklist | ||||
89 | WRITE setGroupingLauncherUrlBlacklist NOTIFY groupingLauncherUrlBlacklistChanged) | ||||
90 | | ||||
91 | public: | ||||
92 | enum SortMode { | ||||
93 | SortDisabled = 0, /**< No sorting is done. */ | ||||
94 | SortManual, /**< Tasks can be moved with move() and syncLaunchers(). */ | ||||
95 | SortAlpha, /**< Tasks are sorted alphabetically, by AbstractTasksModel::AppName and Qt::DisplayRole. */ | ||||
96 | SortVirtualDesktop, /**< Tasks are sorted by the virtual desktop they are on. */ | ||||
97 | SortActivity /**< Tasks are sorted by the number of tasks on the activities they're on. */ | ||||
98 | }; | ||||
99 | | ||||
100 | enum GroupMode { | ||||
101 | GroupDisabled = 0, /**< No grouping is done. */ | ||||
102 | GroupApplications /**< Tasks are grouped by the application backing them. */ | ||||
103 | }; | ||||
104 | | ||||
105 | explicit TasksModel(QObject *parent = 0); | ||||
106 | virtual ~TasksModel(); | ||||
107 | | ||||
108 | QHash<int, QByteArray> roleNames() const override; | ||||
109 | | ||||
110 | Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const; // Invokable. | ||||
111 | | ||||
112 | /** | ||||
113 | * The number of launcher tasks in the tast list. | ||||
114 | * | ||||
115 | * @returns the number of launcher tasks in the task list. | ||||
116 | **/ | ||||
117 | int launcherCount() const; | ||||
118 | | ||||
119 | /** | ||||
120 | * The list of launcher URLs serialized to strings. | ||||
121 | * | ||||
122 | * @see setLauncherList | ||||
123 | * @returns the list of launcher URLs serialized to strings. | ||||
124 | **/ | ||||
125 | QStringList launcherList() const; | ||||
126 | | ||||
127 | /** | ||||
128 | * Replace the list of launcher URL strings. | ||||
129 | * | ||||
130 | * Invalid or empty URLs will be rejected. Duplicate URLs will be | ||||
131 | * collapsed. | ||||
132 | * | ||||
133 | * @see launcherList | ||||
134 | * @param launchers A list of launcher URL strings. | ||||
135 | **/ | ||||
136 | void setLauncherList(const QStringList &launchers); | ||||
137 | | ||||
138 | /** | ||||
139 | * Returns whether any task in the model currently demands attention | ||||
140 | * (AbstractTasksModel::IsDemandingAttention). | ||||
141 | * | ||||
142 | * @returns whether any task in the model currently demands attention. | ||||
143 | **/ | ||||
144 | bool anyTaskDemandsAttention() const; | ||||
145 | | ||||
146 | /** | ||||
147 | * The number of the virtual desktop used in filtering by virtual | ||||
148 | * desktop. Usually set to the number of the current virtual desktop. | ||||
149 | * Defaults to @c -1. | ||||
150 | * | ||||
151 | * @see setVirtualDesktop | ||||
152 | * @returns the number of the virtual desktop used in filtering. | ||||
153 | **/ | ||||
154 | int virtualDesktop() const; | ||||
155 | | ||||
156 | /** | ||||
157 | * Set the number of the virtual desktop to use in filtering by virtual | ||||
158 | * desktop. | ||||
159 | * | ||||
160 | * If set to @c -1, filtering by virtual desktop is disabled. | ||||
161 | * | ||||
162 | * @see virtualDesktop | ||||
163 | * @param virtualDesktop A virtual desktop number. | ||||
164 | **/ | ||||
165 | void setVirtualDesktop(int virtualDesktop); | ||||
166 | | ||||
167 | /** | ||||
168 | * The number of the screen used in filtering by screen. Usually | ||||
169 | * set to the number of the current screen. Defaults to @c -1. | ||||
170 | * | ||||
171 | * @see setScreen | ||||
172 | * @returns the number of the screen used in filtering. | ||||
173 | **/ | ||||
174 | int screen() const; | ||||
175 | | ||||
176 | /** | ||||
177 | * Set the number of the screen to use in filtering by screen. | ||||
178 | * | ||||
179 | * If set to @c -1, filtering by screen is disabled. | ||||
180 | * | ||||
181 | * @see screen | ||||
182 | * @param screen A screen number. | ||||
183 | **/ | ||||
184 | void setScreen(int screen); | ||||
185 | | ||||
186 | /** | ||||
187 | * The id of the activity used in filtering by activity. Usually | ||||
188 | * set to the id of the current activity. Defaults to an empty id. | ||||
189 | * | ||||
190 | * FIXME: Implement. | ||||
191 | * | ||||
192 | * @see setActivity | ||||
193 | * @returns the id of the activity used in filtering. | ||||
194 | **/ | ||||
195 | QString activity() const; | ||||
196 | | ||||
197 | /** | ||||
198 | * Set the id of the activity to use in filtering by activity. | ||||
199 | * | ||||
200 | * FIXME: Implement. | ||||
201 | * | ||||
202 | * @see activity | ||||
203 | * @param activity An activity id. | ||||
204 | **/ | ||||
205 | void setActivity(const QString &activity); | ||||
206 | | ||||
207 | /** | ||||
208 | * Whether tasks should be filtered by virtual desktop. Defaults to | ||||
209 | * @c false. | ||||
210 | * | ||||
211 | * Filtering by virtual desktop only happens if a virtual desktop | ||||
212 | * number is set, even if this returns @c true. | ||||
213 | * | ||||
214 | * @see setFilterByVirtualDesktop | ||||
215 | * @see setVirtualDesktop | ||||
216 | * @returns @c true if tasks should be filtered by virtual desktop. | ||||
217 | **/ | ||||
218 | bool filterByVirtualDesktop() const; | ||||
219 | | ||||
220 | /** | ||||
221 | * Set whether tasks should be filtered by virtual desktop. | ||||
222 | * | ||||
223 | * Filtering by virtual desktop only happens if a virtual desktop | ||||
224 | * number is set, even if this is set to @c true. | ||||
225 | * | ||||
226 | * @see filterByVirtualDesktop | ||||
227 | * @see setVirtualDesktop | ||||
228 | * @param filter Whether tasks should be filtered by virtual desktop. | ||||
229 | **/ | ||||
230 | void setFilterByVirtualDesktop(bool filter); | ||||
231 | | ||||
232 | /** | ||||
233 | * Whether tasks should be filtered by screen. Defaults to @c false. | ||||
234 | * | ||||
235 | * Filtering by screen only happens if a screen number is set, even | ||||
236 | * if this returns @c true. | ||||
237 | * | ||||
238 | * @see setFilterByScreen | ||||
239 | * @see setScreen | ||||
240 | * @returns @c true if tasks should be filtered by screen. | ||||
241 | **/ | ||||
242 | bool filterByScreen() const; | ||||
243 | | ||||
244 | /** | ||||
245 | * Set whether tasks should be filtered by screen. | ||||
246 | * | ||||
247 | * Filtering by screen only happens if a screen number is set, even | ||||
248 | * if this is set to @c true. | ||||
249 | * | ||||
250 | * @see filterByScreen | ||||
251 | * @see setScreen | ||||
252 | * @param filter Whether tasks should be filtered by screen. | ||||
253 | **/ | ||||
254 | void setFilterByScreen(bool filter); | ||||
255 | | ||||
256 | /** | ||||
257 | * Whether tasks should be filtered by activity. Defaults to @c false. | ||||
258 | * | ||||
259 | * Filtering by activity only happens if an activity id is set, even | ||||
260 | * if this returns @c true. | ||||
261 | * | ||||
262 | * @see setFilterByActivity | ||||
263 | * @see setActivity | ||||
264 | * @returns @ctrue if tasks should be filtered by activity. | ||||
265 | **/ | ||||
266 | bool filterByActivity() const; | ||||
267 | | ||||
268 | /** | ||||
269 | * Set whether tasks should be filtered by activity. Defaults to | ||||
270 | * @c false. | ||||
271 | * | ||||
272 | * Filtering by virtual desktop only happens if an activity id is set, | ||||
273 | * even if this is set to @c true. | ||||
274 | * | ||||
275 | * @see filterByActivity | ||||
276 | * @see setActivity | ||||
277 | * @param filter Whether tasks should be filtered by activity. | ||||
278 | **/ | ||||
279 | void setFilterByActivity(bool filter); | ||||
280 | | ||||
281 | /** | ||||
282 | * Whether non-minimized tasks should be filtered. Defaults to | ||||
283 | * @c false. | ||||
284 | * | ||||
285 | * @see setFilterNotMinimized | ||||
286 | * @returns @c true if non-minimized tasks should be filtered. | ||||
287 | **/ | ||||
288 | bool filterNotMinimized() const; | ||||
289 | | ||||
290 | /** | ||||
291 | * Set whether non-minimized tasks should be filtered. | ||||
292 | * | ||||
293 | * @see filterNotMinimized | ||||
294 | * @param filter Whether non-minimized tasks should be filtered. | ||||
295 | **/ | ||||
296 | void setFilterNotMinimized(bool filter); | ||||
297 | | ||||
298 | /** | ||||
299 | * The sort mode used in sorting tasks. Defaults to SortAlpha. | ||||
300 | * | ||||
301 | * @see setSortMode | ||||
302 | * @returns the curent sort mode. | ||||
303 | **/ | ||||
304 | SortMode sortMode() const; | ||||
305 | | ||||
306 | /** | ||||
307 | * Sets the sort mode used in sorting tasks. | ||||
308 | * | ||||
309 | * @see sortMode | ||||
310 | * @param mode A sort mode. | ||||
311 | **/ | ||||
312 | void setSortMode(SortMode mode); | ||||
313 | | ||||
314 | // FIXME TODO: Add docs once fully implemented. | ||||
315 | bool separateLaunchers() const; | ||||
316 | void setSeparateLaunchers(bool separate); | ||||
317 | | ||||
318 | /** | ||||
319 | * Whether window tasks should be sorted as their associated launcher | ||||
320 | * tasks or separately. Defaults to @c false. | ||||
321 | * | ||||
322 | * @see setLaunchInPlace | ||||
323 | * @returns whether window tasks should be sorted as their associated | ||||
324 | * launcher tasks. | ||||
325 | **/ | ||||
326 | bool launchInPlace() const; | ||||
327 | | ||||
328 | /** | ||||
329 | * Sets whether window tasks should be sorted as their associated launcher | ||||
330 | * tasks or separately. | ||||
331 | * | ||||
332 | * @see launchInPlace | ||||
333 | * @param launchInPlace Whether window tasks should be sorted as their | ||||
334 | * associated launcher tasks. | ||||
335 | **/ | ||||
336 | void setLaunchInPlace(bool launchInPlace); | ||||
337 | | ||||
338 | /** | ||||
339 | * Returns the current group mode, i.e. the criteria by which tasks should | ||||
340 | * be grouped. | ||||
341 | * | ||||
342 | * Defaults to TasksModel::GroupApplication, which groups tasks backed by | ||||
343 | * the same application. | ||||
344 | * | ||||
345 | * If the group mode is TasksModel::GroupDisabled, no grouping is done. | ||||
346 | * | ||||
347 | * @see setGroupMode | ||||
348 | * @returns the current group mode. | ||||
349 | **/ | ||||
350 | TasksModel::GroupMode groupMode() const; | ||||
351 | | ||||
352 | /** | ||||
353 | * Sets the group mode, i.e. the criteria by which tasks should be grouped. | ||||
354 | * | ||||
355 | * The group mode can be set to TasksModel::GroupDisabled to disable grouping | ||||
356 | * entirely, breaking apart any existing groups. | ||||
357 | * | ||||
358 | * @see groupMode | ||||
359 | * @param mode A group mode. | ||||
360 | **/ | ||||
361 | void setGroupMode(TasksModel::GroupMode mode); | ||||
362 | | ||||
363 | /** | ||||
364 | * As window tasks (AbstractTasksModel::IsWindow) come and go, groups will | ||||
365 | * be formed when this threshold value is exceeded, and broken apart when | ||||
366 | * it matches or falls below. | ||||
367 | * | ||||
368 | * Defaults to @c -1, which means grouping is done regardless of the number | ||||
369 | * of window tasks. | ||||
370 | * | ||||
371 | * @see setGroupingWindowTasksThreshold | ||||
372 | * @return the threshold number of window tasks used in grouping decisions. | ||||
373 | **/ | ||||
374 | int groupingWindowTasksThreshold() const; | ||||
375 | | ||||
376 | /** | ||||
377 | * Sets the number of window tasks (AbstractTasksModel::IsWindow) above which | ||||
378 | * groups will be formed, and at or below which groups will be broken apart. | ||||
379 | * | ||||
380 | * If set to -1, grouping will be done regardless of the number of window tasks | ||||
381 | * in the source model. | ||||
382 | * | ||||
383 | * @see groupingWindowTasksThreshold | ||||
384 | * @param threshold A threshold number of window tasks used in grouping | ||||
385 | * decisions. | ||||
386 | **/ | ||||
387 | void setGroupingWindowTasksThreshold(int threshold); | ||||
388 | | ||||
389 | /** | ||||
390 | * A blacklist of app ids (AbstractTasksModel::AppId) that is consulted before | ||||
391 | * grouping a task. If a task's app id is found on the blacklist, it is not | ||||
392 | * grouped. | ||||
393 | * | ||||
394 | * The default app id blacklist is empty. | ||||
395 | * | ||||
396 | * @see setGroupingAppIdBlacklist | ||||
397 | * @returns the blacklist of app ids consulted before grouping a task. | ||||
398 | **/ | ||||
399 | QStringList groupingAppIdBlacklist() const; | ||||
400 | | ||||
401 | /** | ||||
402 | * Sets the blacklist of app ids (AbstractTasksModel::AppId) that is consulted | ||||
403 | * before grouping a task. If a task's app id is found on the blacklist, it is | ||||
404 | * not grouped. | ||||
405 | * | ||||
406 | * When set, groups will be formed and broken apart as necessary. | ||||
407 | * | ||||
408 | * @see groupingAppIdBlacklist | ||||
409 | * @param list a blacklist of app ids to be consulted before grouping a task. | ||||
410 | **/ | ||||
411 | void setGroupingAppIdBlacklist(const QStringList &list); | ||||
412 | | ||||
413 | /** | ||||
414 | * A blacklist of launcher URLs (AbstractTasksModel::LauncherUrl) that is | ||||
415 | * consulted before grouping a task. If a task's launcher URL is found on the | ||||
416 | * blacklist, it is not grouped. | ||||
417 | * | ||||
418 | * The default launcher URL blacklist is empty. | ||||
419 | * | ||||
420 | * @see setGroupingLauncherUrlBlacklist | ||||
421 | * @returns the blacklist of launcher URLs consulted before grouping a task. | ||||
422 | **/ | ||||
423 | QStringList groupingLauncherUrlBlacklist() const; | ||||
424 | | ||||
425 | /** | ||||
426 | * Sets the blacklist of launcher URLs (AbstractTasksModel::LauncherUrl) that | ||||
427 | * is consulted before grouping a task. If a task's launcher URL is found on | ||||
428 | * the blacklist, it is not grouped. | ||||
429 | * | ||||
430 | * When set, groups will be formed and broken apart as necessary. | ||||
431 | * | ||||
432 | * @see groupingLauncherUrlBlacklist | ||||
433 | * @param list a blacklist of launcher URLs to be consulted before grouping a task. | ||||
434 | **/ | ||||
435 | void setGroupingLauncherUrlBlacklist(const QStringList &list); | ||||
436 | | ||||
437 | /** | ||||
438 | * Request adding a launcher with the given URL. | ||||
439 | * | ||||
440 | * If this URL is already in the list, the request will fail. URLs are | ||||
441 | * compared for equality after removing the query string used to hold | ||||
442 | * metadata. | ||||
443 | * | ||||
444 | * @see launcherUrlsMatch | ||||
445 | * @param url A launcher URL. | ||||
446 | * @returns @c true if a launcher was added. | ||||
447 | */ | ||||
448 | Q_INVOKABLE bool requestAddLauncher(const QUrl &url); | ||||
449 | | ||||
450 | /** | ||||
451 | * Request removing the launcher with the given URL. | ||||
452 | * | ||||
453 | * If this URL is already in the list, the request will fail. URLs are | ||||
454 | * compared for equality after removing the query string used to hold | ||||
455 | * metadata. | ||||
456 | * | ||||
457 | * @see launcherUrlsMatch | ||||
458 | * @param url A launcher URL. | ||||
459 | * @returns @c true if the launcher was removed. | ||||
460 | */ | ||||
461 | Q_INVOKABLE bool requestRemoveLauncher(const QUrl &url); | ||||
462 | | ||||
463 | /** | ||||
464 | * Return the position of the launcher with the given URL. | ||||
465 | * | ||||
466 | * URLs are compared for equality after removing the query string used | ||||
467 | * to hold metadata. | ||||
468 | * | ||||
469 | * @see launcherUrlsMatch | ||||
470 | * @param url A launcher URL. | ||||
471 | * @returns @c -1 if no launcher exists for the given URL. | ||||
472 | */ | ||||
473 | Q_INVOKABLE int launcherPosition(const QUrl &url) const; | ||||
474 | | ||||
475 | /** | ||||
476 | * Request activation of the task at the given index. Derived classes are | ||||
477 | * free to interpret the meaning of "activate" themselves depending on | ||||
478 | * the nature and state of the task, e.g. launch or raise a window task. | ||||
479 | * | ||||
480 | * @param index An index in this tasks model. | ||||
481 | **/ | ||||
482 | Q_INVOKABLE void requestActivate(const QModelIndex &index); | ||||
483 | | ||||
484 | /** | ||||
485 | * Request an additional instance of the application backing the task | ||||
486 | * at the given index. | ||||
487 | * | ||||
488 | * @param index An index in this tasks model. | ||||
489 | **/ | ||||
490 | Q_INVOKABLE void requestNewInstance(const QModelIndex &index); | ||||
491 | | ||||
492 | /** | ||||
493 | * Request the task at the given index be closed. | ||||
494 | * | ||||
495 | * @param index An index in this tasks model. | ||||
496 | **/ | ||||
497 | Q_INVOKABLE void requestClose(const QModelIndex &index); | ||||
498 | | ||||
499 | /** | ||||
500 | * Request starting an interactive move for the task at the given index. | ||||
501 | * | ||||
502 | * This is meant for tasks that have an associated window, and may be | ||||
503 | * a no-op when there is no window. | ||||
504 | * | ||||
505 | * @param index An index in this tasks model. | ||||
506 | **/ | ||||
507 | Q_INVOKABLE void requestMove(const QModelIndex &index); | ||||
508 | | ||||
509 | /** | ||||
510 | * Request starting an interactive resize for the task at the given index. | ||||
511 | * | ||||
512 | * This is meant for tasks that have an associated window, and may be a | ||||
513 | * no-op when there is no window. | ||||
514 | * | ||||
515 | * @param index An index in this tasks model. | ||||
516 | **/ | ||||
517 | Q_INVOKABLE void requestResize(const QModelIndex &index); | ||||
518 | | ||||
519 | /** | ||||
520 | * Request toggling the minimized state of the task at the given index. | ||||
521 | * | ||||
522 | * This is meant for tasks that have an associated window, and may be | ||||
523 | * a no-op when there is no window. | ||||
524 | * | ||||
525 | * @param index An index in this tasks model. | ||||
526 | **/ | ||||
527 | Q_INVOKABLE void requestToggleMinimized(const QModelIndex &index); | ||||
528 | | ||||
529 | /** | ||||
530 | * Request toggling the maximized state of the task at the given index. | ||||
531 | * | ||||
532 | * This is meant for tasks that have an associated window, and may be | ||||
533 | * a no-op when there is no window. | ||||
534 | * | ||||
535 | * @param index An index in this tasks model. | ||||
536 | **/ | ||||
537 | Q_INVOKABLE void requestToggleMaximized(const QModelIndex &index); | ||||
538 | | ||||
539 | /** | ||||
540 | * Request toggling the keep-above state of the task at the given index. | ||||
541 | * | ||||
542 | * This is meant for tasks that have an associated window, and may be | ||||
543 | * a no-op when there is no window. | ||||
544 | * | ||||
545 | * @param index An index in this tasks model. | ||||
546 | **/ | ||||
547 | Q_INVOKABLE void requestToggleKeepAbove(const QModelIndex &index); | ||||
548 | | ||||
549 | /** | ||||
550 | * Request toggling the keep-below state of the task at the given index. | ||||
551 | * | ||||
552 | * This is meant for tasks that have an associated window, and may be | ||||
553 | * a no-op when there is no window. | ||||
554 | * | ||||
555 | * @param index An index in this tasks model. | ||||
556 | **/ | ||||
557 | Q_INVOKABLE void requestToggleKeepBelow(const QModelIndex &index); | ||||
558 | | ||||
559 | /** | ||||
560 | * Request toggling the fullscreen state of the task at the given index. | ||||
561 | * | ||||
562 | * This is meant for tasks that have an associated window, and may be | ||||
563 | * a no-op when there is no window. | ||||
564 | * | ||||
565 | * @param index An index in this tasks model. | ||||
566 | **/ | ||||
567 | Q_INVOKABLE void requestToggleFullScreen(const QModelIndex &index); | ||||
568 | | ||||
569 | /** | ||||
570 | * Request toggling the shaded state of the task at the given index. | ||||
571 | * | ||||
572 | * This is meant for tasks that have an associated window, and may be | ||||
573 | * a no-op when there is no window. | ||||
574 | * | ||||
575 | * @param index An index in this tasks model. | ||||
576 | **/ | ||||
577 | Q_INVOKABLE void requestToggleShaded(const QModelIndex &index); | ||||
578 | | ||||
579 | /** | ||||
580 | * Request moving the task at the given index to the specified virtual | ||||
581 | * desktop. | ||||
582 | * | ||||
583 | * This is meant for tasks that have an associated window, and may be | ||||
584 | * a no-op when there is no window. | ||||
585 | * | ||||
586 | * @param index An index in this tasks model. | ||||
587 | * @param desktop A virtual desktop number. | ||||
588 | **/ | ||||
589 | Q_INVOKABLE void requestVirtualDesktop(const QModelIndex &index, qint32 desktop); | ||||
590 | | ||||
591 | /** | ||||
592 | * Request informing the window manager of new geometry for a visual | ||||
593 | * delegate for the task at the given index. The geometry should be in | ||||
594 | * screen coordinates. | ||||
595 | * | ||||
596 | * If the task at the given index is a group parent, the geometry is | ||||
597 | * set for all of its children. If the task at the given index is a | ||||
598 | * group member, the geometry is set for all of its siblings. | ||||
599 | * | ||||
600 | * @param index An index in this tasks model. | ||||
601 | * @param geometry Visual delegate geometry in screen coordinates. | ||||
602 | * @param delegate The delegate. Implementations are on their own with | ||||
603 | * regard to extracting information from this, and should take care to | ||||
604 | * reject invalid objects. | ||||
605 | **/ | ||||
606 | Q_INVOKABLE void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, | ||||
607 | QObject *delegate = nullptr); | ||||
608 | | ||||
609 | /** | ||||
610 | * Request toggling whether the task at the given index, along with any | ||||
611 | * tasks matching its kind, should be grouped or not. Task groups will be | ||||
612 | * formed or broken apart as needed, along with affecting future grouping | ||||
613 | * decisions as new tasks appear. | ||||
614 | * | ||||
615 | * As grouping is toggled for a task, updates are made to the | ||||
616 | * grouping*Blacklist properties of the model instance. | ||||
617 | * | ||||
618 | * @see groupingAppIdBlacklist | ||||
619 | * @see groupingLauncherUrlBlacklist | ||||
620 | * | ||||
621 | * @param index An index in this tasks model. | ||||
622 | **/ | ||||
623 | Q_INVOKABLE void requestToggleGrouping(const QModelIndex &index); | ||||
624 | | ||||
625 | /** | ||||
626 | * Moves a (top-level) task to a new position in the list. The insert | ||||
627 | * position is bounded to the list start and end. | ||||
628 | * syncLaunchers() should be called after a set of move operations to | ||||
629 | * update the launcher list to reflect the new order. | ||||
630 | * | ||||
631 | * @see syncLaunchers | ||||
632 | * @see launcherList | ||||
633 | * @param index An index in this tasks model. | ||||
634 | * @param newPos The new list position to move the task to. | ||||
635 | */ | ||||
636 | Q_INVOKABLE bool move(int row, int newPos); | ||||
637 | | ||||
638 | /** | ||||
639 | * Updates the launcher list to reflect the new order after calls to | ||||
640 | * move(), if needed. | ||||
641 | * | ||||
642 | * @see move | ||||
643 | * @see launcherList | ||||
644 | */ | ||||
645 | Q_INVOKABLE void syncLaunchers(); | ||||
646 | | ||||
647 | /** | ||||
648 | * Finds the first active (AbstractTasksModel::IsActive) task in the model | ||||
649 | * and returns its QModelIndex, or a null QModelIndex if no active task is | ||||
650 | * found. | ||||
651 | * | ||||
652 | * @returns the model index for the first active task, if any. | ||||
653 | */ | ||||
654 | Q_INVOKABLE QModelIndex activeTask() const; | ||||
655 | | ||||
656 | /** | ||||
657 | * Given a row in the model, returns a QModelIndex for it. To get an index | ||||
658 | * for a child in a task group, an optional child row may be passed as well. | ||||
659 | * | ||||
660 | * This easier to use from Qt Quick views than QAbstractItemModel::index is. | ||||
661 | * | ||||
662 | * @param row A row index in the model. | ||||
663 | * @param childRow A row index for a child of the task group at the given row. | ||||
664 | * @returns a model index for the task at the given row, or for one of its | ||||
665 | * child tasks. | ||||
666 | */ | ||||
667 | Q_INVOKABLE QModelIndex makeModelIndex(int row, int childRow = -1) const; | ||||
668 | | ||||
669 | Q_SIGNALS: | ||||
670 | void countChanged() const; | ||||
671 | void launcherCountChanged() const; | ||||
672 | void launcherListChanged() const; | ||||
673 | void anyTaskDemandsAttentionChanged() const; | ||||
674 | void virtualDesktopChanged() const; | ||||
675 | void screenChanged() const; | ||||
676 | void activityChanged() const; | ||||
677 | void filterByVirtualDesktopChanged() const; | ||||
678 | void filterByScreenChanged() const; | ||||
679 | void filterByActivityChanged() const; | ||||
680 | void filterNotMinimizedChanged() const; | ||||
681 | void sortModeChanged() const; | ||||
682 | void separateLaunchersChanged() const; | ||||
683 | void launchInPlaceChanged() const; | ||||
684 | void groupModeChanged() const; | ||||
685 | void groupingWindowTasksThresholdChanged() const; | ||||
686 | void groupingAppIdBlacklistChanged() const; | ||||
687 | void groupingLauncherUrlBlacklistChanged() const; | ||||
688 | | ||||
689 | protected: | ||||
690 | bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; | ||||
691 | bool lessThan(const QModelIndex &left, const QModelIndex &right) const; | ||||
692 | | ||||
693 | private: | ||||
694 | class Private; | ||||
695 | class TasksModelLessThan; | ||||
696 | friend class TasksModelLessThan; | ||||
697 | QScopedPointer<Private> d; | ||||
698 | }; | ||||
699 | | ||||
700 | } | ||||
701 | | ||||
702 | #endif |