Plasma-workspace

abstracttasksmodel.cpp
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#include "abstracttasksmodel.h"
8
9#include <QMetaEnum>
10
11namespace TaskManager
12{
13AbstractTasksModel::AbstractTasksModel(QObject *parent)
14 : QAbstractListModel(parent)
15{
16}
17
18AbstractTasksModel::~AbstractTasksModel()
19{
20}
21
22QHash<int, QByteArray> AbstractTasksModel::roleNames() const
23{
25
26 QMetaEnum e = metaObject()->enumerator(metaObject()->indexOfEnumerator("AdditionalRoles"));
27
28 for (int i = 0; i < e.keyCount(); ++i) {
29 roles.insert(e.value(i), e.key(i));
30 }
31
32 return roles;
33}
34
35QVariant AbstractTasksModel::data(const QModelIndex &, int role) const
36{
37 switch (role) {
38 case Qt::DisplayRole:
39 return QString();
41 return QVariant();
42 case AppId:
43 return 0;
44 case AppName:
45 case GenericName:
46 return QString();
47 case LauncherUrl:
48 case LauncherUrlWithoutIcon:
49 return QVariant();
50 case WinIdList:
51 return QVariantList();
52 case MimeType:
53 return QString();
54 case MimeData:
55 return QVariant();
56 case IsWindow:
57 case IsStartup:
58 case IsLauncher:
59 case HasLauncher:
60 case IsGroupParent:
61 return false;
62 case ChildCount:
63 return 0;
64 case IsGroupable:
65 case IsActive:
66 case IsClosable:
67 case IsMovable:
68 case IsResizable:
69 case IsMaximizable:
70 case IsMaximized:
71 case IsMinimizable:
72 case IsMinimized:
73 case IsKeepAbove:
74 case IsKeepBelow:
75 case IsFullScreenable:
76 case IsFullScreen:
77 case IsShadeable:
78 case IsShaded:
79 case IsVirtualDesktopsChangeable:
80 return false;
81 case VirtualDesktops:
82 return QVariantList{0};
83 case IsOnAllVirtualDesktops:
84 return false;
85 case Geometry:
86 case ScreenGeometry:
87 return QVariant();
88 case Activities:
89 return QStringList();
90 case IsDemandingAttention:
91 case SkipTaskbar:
92 case SkipPager:
93 return false;
94 case AppPid:
95 return 0;
96 case StackingOrder:
97 case LastActivated:
98 return QVariant();
99 case ApplicationMenuServiceName:
100 case ApplicationMenuObjectPath:
101 return QString();
102 case IsHidden:
103 case CanLaunchNewInstance:
104 case CanSetNoBorder:
105 case HasNoBorder:
106 return false;
107 default:
108 return QVariant();
109 }
110 Q_UNREACHABLE();
111}
112
113QModelIndex AbstractTasksModel::index(int row, int column, const QModelIndex &parent) const
114{
115 return hasIndex(row, column, parent) ? createIndex(row, column, nullptr) : QModelIndex();
116}
117
119{
120 Q_UNUSED(index)
121}
122
124{
125 Q_UNUSED(index)
126}
127
129{
130 Q_UNUSED(index)
131 Q_UNUSED(urls)
132}
133
135{
136 Q_UNUSED(index)
137}
138
140{
141 Q_UNUSED(index)
142}
143
145{
146 Q_UNUSED(index)
147}
148
150{
151 Q_UNUSED(index)
152}
153
155{
156 Q_UNUSED(index)
157}
158
160{
161 Q_UNUSED(index)
162}
163
165{
166 Q_UNUSED(index)
167}
168
170{
171 Q_UNUSED(index)
172}
173
175{
176 Q_UNUSED(index)
177}
178
180{
181 Q_UNUSED(index);
182}
183
184void AbstractTasksModel::requestVirtualDesktops(const QModelIndex &index, const QVariantList &desktops)
185{
186 Q_UNUSED(index)
187 Q_UNUSED(desktops)
188}
189
191{
192 Q_UNUSED(index)
193}
194
196{
197 Q_UNUSED(index)
198 Q_UNUSED(activities)
199}
200
202{
203 Q_UNUSED(index)
204 Q_UNUSED(geometry)
205 Q_UNUSED(delegate)
206}
207
208}
209
210#include "moc_abstracttasksmodel.cpp"
void requestActivate(const QModelIndex &index) override
Request activation of the task at the given index.
void requestResize(const QModelIndex &index) override
Request starting an interactive resize for the task at the given index.
void requestMove(const QModelIndex &index) override
Request starting an interactive move for the task at the given index.
void requestNewInstance(const QModelIndex &index) override
Request an additional instance of the application backing the task at the given index.
void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate=nullptr) override
Request informing the window manager of new geometry for a visual delegate for the task at the given ...
void requestToggleMinimized(const QModelIndex &index) override
Request toggling the minimized state of the task at the given index.
void requestNewVirtualDesktop(const QModelIndex &index) override
Request entering the window at the given index on a new virtual desktop, which is created in response...
void requestClose(const QModelIndex &index) override
Request the task at the given index be closed.
void requestToggleNoBorder(const QModelIndex &index) override
Request toggling the no border state of the task at given index.
void requestOpenUrls(const QModelIndex &index, const QList< QUrl > &urls) override
Requests to open the given URLs with the application backing the task at the given index.
void requestToggleKeepAbove(const QModelIndex &index) override
Request toggling the keep-above state of the task at the given index.
void requestToggleKeepBelow(const QModelIndex &index) override
Request toggling the keep-below state of the task at the given index.
void requestToggleShaded(const QModelIndex &index) override
Request toggling the shaded state of the task at the given index.
void requestToggleMaximized(const QModelIndex &index) override
Request toggling the maximized state of the task at the given index.
void requestActivities(const QModelIndex &index, const QStringList &activities) override
Request moving the task at the given index to the specified activities.
void requestToggleFullScreen(const QModelIndex &index) override
Request toggling the fullscreen state of the task at the given index.
void requestVirtualDesktops(const QModelIndex &index, const QVariantList &desktops) override
Request entering the window at the given index on the specified virtual desktops, leaving any other d...
virtual QHash< int, QByteArray > roleNames() const const
iterator insert(const Key &key, const T &value)
const char * key(int index) const const
int keyCount() const const
int value(int index) const const
QObject(QObject *parent)
DisplayRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Mar 28 2025 11:53:53 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.