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 return false;
105 default:
106 return QVariant();
107 }
108 Q_UNREACHABLE();
109}
110
111QModelIndex AbstractTasksModel::index(int row, int column, const QModelIndex &parent) const
112{
113 return hasIndex(row, column, parent) ? createIndex(row, column, nullptr) : QModelIndex();
114}
115
117{
118 Q_UNUSED(index)
119}
120
122{
123 Q_UNUSED(index)
124}
125
127{
128 Q_UNUSED(index)
129 Q_UNUSED(urls)
130}
131
133{
134 Q_UNUSED(index)
135}
136
138{
139 Q_UNUSED(index)
140}
141
143{
144 Q_UNUSED(index)
145}
146
148{
149 Q_UNUSED(index)
150}
151
153{
154 Q_UNUSED(index)
155}
156
158{
159 Q_UNUSED(index)
160}
161
163{
164 Q_UNUSED(index)
165}
166
168{
169 Q_UNUSED(index)
170}
171
173{
174 Q_UNUSED(index)
175}
176
177void AbstractTasksModel::requestVirtualDesktops(const QModelIndex &index, const QVariantList &desktops)
178{
179 Q_UNUSED(index)
180 Q_UNUSED(desktops)
181}
182
184{
185 Q_UNUSED(index)
186}
187
189{
190 Q_UNUSED(index)
191 Q_UNUSED(activities)
192}
193
195{
196 Q_UNUSED(index)
197 Q_UNUSED(geometry)
198 Q_UNUSED(delegate)
199}
200
201}
202
203#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 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 Jan 24 2025 11:57:53 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.