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

KDE's Doxygen guidelines are available online.