Plasma-workspace

abstracttasksmodel.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 "abstracttasksmodeliface.h"
10
11#include <QAbstractListModel>
12
13#include "taskmanager_export.h"
14
15namespace TaskManager
16{
17/**
18 * @short An abstract base class for (flat) tasks models.
19 *
20 * This class serves as abstract base class for flat tasks model implementations.
21 * It provides data roles and no-op default implementations of methods in the
22 * AbstractTasksModelIface interface.
23 *
24 * @author Eike Hein <hein@kde.org>
25 **/
26class TASKMANAGER_EXPORT AbstractTasksModel : public QAbstractListModel, public AbstractTasksModelIface
27{
28 Q_OBJECT
29
30public:
32 AppId = Qt::UserRole + 1, /**< KService storage id (.desktop name sans extension). */
33 AppName, /**< Application name. */
34 GenericName, /**< Generic application name. */
35 LauncherUrl, /**< URL that can be used to launch this application (.desktop or executable). */
36 LauncherUrlWithoutIcon, /**< Special path to get a launcher URL while skipping fallback icon encoding. Used as speed optimization. */
37 WinIdList, /**< NOTE: On Wayland, these ids are only useful within the same process. On X11, they are global window ids. */
38 MimeType, /**< MIME type for this task (window, window group), needed for DND. */
39 MimeData, /**< Data for MimeType. */
40 IsWindow, /**< This is a window task. */
41 IsStartup, /**< This is a startup task. */
42 IsLauncher, /**< This is a launcher task. */
43 HasLauncher, /**< A launcher exists for this task. Only implemented by TasksModel, not by either the single-type or munging tasks models. */
44 IsGroupParent, /**< This is a parent item for a group of child tasks. */
45 ChildCount, /**< The number of tasks in this group. */
46 IsGroupable, /**< Whether this task is being ignored by grouping or not. */
47 IsActive, /**< This is the currently active task. */
48 IsClosable, /**< requestClose (see below) available. */
49 IsMovable, /**< requestMove (see below) available. */
50 IsResizable, /**< requestResize (see below) available. */
51 IsMaximizable, /**< requestToggleMaximize (see below) available. */
52 IsMaximized, /**< Task (i.e. window) is maximized. */
53 IsMinimizable, /**< requestToggleMinimize (see below) available. */
54 IsMinimized, /**< Task (i.e. window) is minimized. */
55 IsKeepAbove, /**< Task (i.e. window) is keep-above. */
56 IsKeepBelow, /**< Task (i.e. window) is keep-below. */
57 IsFullScreenable, /**< requestToggleFullScreen (see below) available. */
58 IsFullScreen, /**< Task (i.e. window) is fullscreen. */
59 IsShadeable, /**< requestToggleShade (see below) available. */
60 IsShaded, /**< Task (i.e. window) is shaded. */
61 IsVirtualDesktopsChangeable, /**< requestVirtualDesktop (see below) available. */
62 VirtualDesktops, /**< Virtual desktops for the task (i.e. window). */
63 IsOnAllVirtualDesktops, /**< Task is on all virtual desktops. */
64 Geometry, /**< The task's geometry (i.e. the window's). */
65 ScreenGeometry, /**< Screen geometry for the task (i.e. the window's screen). */
66 Activities, /**< Activities for the task (i.e. window). */
67 IsDemandingAttention, /**< Task is demanding attention. */
68 SkipTaskbar, /**< Task should not be shown in a 'task bar' user interface. */
69 SkipPager, /**< Task should not to be shown in a 'pager' user interface. */
70 AppPid, /**< Application Process ID. This is provided best-effort, and may not
71 be what you expect: For window tasks owned by processes started
72 from e.g. kwin_wayland, it would be the process id of kwin
73 itself. DO NOT use this for destructive actions such as closing
74 the application. The intended use case is to try and (smartly)
75 gather more information about the task when needed. */
76 StackingOrder, /**< A window task's index in the window stacking order. Care must be
77 taken not to assume this index to be unique when iterating over
78 model contents due to the asynchronous nature of the windowing
79 system. */
80 LastActivated, /**< The timestamp of the last time a task was the active task. */
81 ApplicationMenuServiceName, /**< The DBus service name for the application's menu.
82 May be empty. @since 5.19 */
83 ApplicationMenuObjectPath, /**< The DBus object path for the application's menu.
84 May be empty. @since 5.19 */
85 IsHidden, /**< Task (i.e window) is hidden on screen. A minimzed
86 window is not necessarily hidden. */
87 CanLaunchNewInstance, /**< A new instance of the task can be launched. @since 5.24 */
88 };
89 Q_ENUM(AdditionalRoles)
90
91 explicit AbstractTasksModel(QObject *parent = nullptr);
92 ~AbstractTasksModel() override;
93
94 QHash<int, QByteArray> roleNames() const override;
95
96 QVariant data(const QModelIndex &index, int role) const override;
97 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
98
99 /**
100 * Request activation of the task at the given index. Derived classes are
101 * free to interpret the meaning of "activate" themselves depending on
102 * the nature and state of the task, e.g. launch or raise a window task.
103 *
104 * This base implementation does nothing.
105 *
106 * @param index An index in this tasks model.
107 **/
108 void requestActivate(const QModelIndex &index) override;
109
110 /**
111 * Request an additional instance of the application backing the task
112 * at the given index.
113 *
114 * This base implementation does nothing.
115 *
116 * @param index An index in this tasks model.
117 **/
118 void requestNewInstance(const QModelIndex &index) override;
119
120 /**
121 * Requests to open the given URLs with the application backing the task
122 * at the given index.
123 *
124 * This base implementation does nothing.
125 *
126 * @param index An index in this tasks model.
127 * @param urls The URLs to be passed to the application.
128 **/
129 void requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) override;
130
131 /**
132 * Request the task at the given index be closed.
133 *
134 * This base implementation does nothing.
135 *
136 * @param index An index in this tasks model.
137 **/
138 void requestClose(const QModelIndex &index) override;
139
140 /**
141 * Request starting an interactive move for the task at the given index.
142 *
143 * This is meant for tasks that have an associated window, and may be
144 * a no-op when there is no window.
145 *
146 * This base implementation does nothing.
147 *
148 * @param index An index in this tasks model.
149 **/
150 void requestMove(const QModelIndex &index) override;
151
152 /**
153 * Request starting an interactive resize for the task at the given index.
154 *
155 * This is meant for tasks that have an associated window, and may be a
156 * no-op when there is no window.
157 *
158 * This base implementation does nothing.
159 *
160 * @param index An index in this tasks model.
161 **/
162 void requestResize(const QModelIndex &index) override;
163
164 /**
165 * Request toggling the minimized state of the task at the given index.
166 *
167 * This is meant for tasks that have an associated window, and may be
168 * a no-op when there is no window.
169 *
170 * This base implementation does nothing.
171 *
172 * @param index An index in this tasks model.
173 **/
174 void requestToggleMinimized(const QModelIndex &index) override;
175
176 /**
177 * Request toggling the maximized state of the task at the given index.
178 *
179 * This is meant for tasks that have an associated window, and may be
180 * a no-op when there is no window.
181 *
182 * This base implementation does nothing.
183 *
184 * @param index An index in this tasks model.
185 **/
186 void requestToggleMaximized(const QModelIndex &index) override;
187
188 /**
189 * Request toggling the keep-above state of the task at the given index.
190 *
191 * This is meant for tasks that have an associated window, and may be
192 * a no-op when there is no window.
193 *
194 * This base implementation does nothing.
195 *
196 * @param index An index in this tasks model.
197 **/
198 void requestToggleKeepAbove(const QModelIndex &index) override;
199
200 /**
201 * Request toggling the keep-below state of the task at the given index.
202 *
203 * This is meant for tasks that have an associated window, and may be
204 * a no-op when there is no window.
205 *
206 * This base implementation does nothing.
207 *
208 * @param index An index in this tasks model.
209 **/
210 void requestToggleKeepBelow(const QModelIndex &index) override;
211
212 /**
213 * Request toggling the fullscreen state of the task at the given index.
214 *
215 * This is meant for tasks that have an associated window, and may be
216 * a no-op when there is no window.
217 *
218 * This base implementation does nothing.
219 *
220 * @param index An index in this tasks model.
221 **/
222 void requestToggleFullScreen(const QModelIndex &index) override;
223
224 /**
225 * Request toggling the shaded state of the task at the given index.
226 *
227 * This is meant for tasks that have an associated window, and may be
228 * a no-op when there is no window.
229 *
230 * This base implementation does nothing.
231 *
232 * @param index An index in this tasks model.
233 **/
234 void requestToggleShaded(const QModelIndex &index) override;
235
236 /**
237 * Request entering the window at the given index on the specified virtual desktops,
238 * leaving any other desktops.
239 *
240 * On Wayland, virtual desktop ids are QStrings. On X11, they are uint >0.
241 *
242 * An empty list has a special meaning: The window is entered on all virtual desktops
243 * in the session.
244 *
245 * On X11, a window can only be on one or all virtual desktops. Therefore, only the
246 * first list entry is actually used.
247 *
248 * On X11, the id 0 has a special meaning: The window is entered on all virtual
249 * desktops in the session.
250 *
251 * @param index An index in this window tasks model.
252 * @param desktops A list of virtual desktop ids.
253 **/
254 void requestVirtualDesktops(const QModelIndex &index, const QVariantList &desktops) override;
255
256 /**
257 * Request entering the window at the given index on a new virtual desktop,
258 * which is created in response to this request.
259 *
260 * @param index An index in this window tasks model.
261 **/
262 void requestNewVirtualDesktop(const QModelIndex &index) override;
263
264 /**
265 * Request moving the task at the given index to the specified activities.
266 *
267 * This is meant for tasks that have an associated window, and may be
268 * a no-op when there is no window.
269 *
270 * This base implementation does nothing.
271 *
272 * @param index An index in this tasks model.
273 * @param activities The new list of activities.
274 **/
275 void requestActivities(const QModelIndex &index, const QStringList &activities) override;
276
277 /**
278 * Request informing the window manager of new geometry for a visual
279 * delegate for the task at the given index. The geometry should be in
280 * screen coordinates.
281 *
282 * This base implementation does nothing.
283 *
284 * @param index An index in this tasks model.
285 * @param geometry Visual delegate geometry in screen coordinates.
286 * @param delegate The delegate. Implementations are on their own with
287 * regard to extracting information from this, and should take care to
288 * reject invalid objects.
289 **/
290 void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate = nullptr) override;
291};
292
293}
Pure virtual method interface for tasks model implementations.
An abstract base class for (flat) tasks models.
@ IsGroupable
Whether this task is being ignored by grouping or not.
@ MimeType
MIME type for this task (window, window group), needed for DND.
@ IsLauncher
This is a launcher task.
@ LauncherUrl
URL that can be used to launch this application (.desktop or executable).
@ IsClosable
requestClose (see below) available.
@ Activities
Activities for the task (i.e.
@ IsDemandingAttention
Task is demanding attention.
@ IsActive
This is the currently active task.
@ SkipTaskbar
Task should not be shown in a 'task bar' user interface.
@ IsFullScreenable
requestToggleFullScreen (see below) available.
@ IsWindow
This is a window task.
@ IsVirtualDesktopsChangeable
requestVirtualDesktop (see below) available.
@ IsGroupParent
This is a parent item for a group of child tasks.
@ IsStartup
This is a startup task.
@ VirtualDesktops
Virtual desktops for the task (i.e.
@ GenericName
Generic application name.
@ IsShadeable
requestToggleShade (see below) available.
@ HasLauncher
A launcher exists for this task.
@ SkipPager
Task should not to be shown in a 'pager' user interface.
@ IsOnAllVirtualDesktops
Task is on all virtual desktops.
@ IsResizable
requestResize (see below) available.
@ WinIdList
NOTE: On Wayland, these ids are only useful within the same process.
@ LauncherUrlWithoutIcon
Special path to get a launcher URL while skipping fallback icon encoding.
@ IsMinimizable
requestToggleMinimize (see below) available.
@ Geometry
The task's geometry (i.e.
@ LastActivated
The timestamp of the last time a task was the active task.
@ IsMovable
requestMove (see below) available.
@ ChildCount
The number of tasks in this group.
@ ScreenGeometry
Screen geometry for the task (i.e.
@ IsMaximizable
requestToggleMaximize (see below) available.
@ CanLaunchNewInstance
A new instance of the task can be launched.
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:42 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.