Plasma-workspace

abstractwindowtasksmodel.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 "abstractwindowtasksmodel.h"
8
9#include <QGuiApplication>
10#include <QScreen>
11
12namespace TaskManager
13{
14AbstractWindowTasksModel::AbstractWindowTasksModel(QObject *parent)
15 : AbstractTasksModel(parent)
16{
17 // TODO: The following will refresh the ScreenGeometry data role for
18 // all rows whenever any screen is added or changes its geometry. No
19 // attempt is made to be intelligent and exempt rows that are tech-
20 // nically unaffected by the change. Doing so would require tracking
21 // far more state (i.e. what screen a window is on) and be so
22 // complicated as to invite bugs. As the trigger conditions are
23 // expected to be rare, this would be premature optimization at this
24 // time. That assessment may change in the future.
25
26 auto screenAdded = [this](const QScreen *screen) {
27 connect(screen, &QScreen::geometryChanged, this, [this]() {
28 if (rowCount() == 0) {
29 return;
30 }
31 Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0), QList<int>{ScreenGeometry});
32 });
33 };
34
35 connect(qGuiApp, &QGuiApplication::screenAdded, this, screenAdded);
36
37 foreach (const QScreen *screen, QGuiApplication::screens()) {
38 screenAdded(screen);
39 }
40}
41
42AbstractWindowTasksModel::~AbstractWindowTasksModel()
43{
44}
45
46}
void screenAdded(QScreen *screen)
QList< QScreen * > screens()
void geometryChanged(const QRect &geometry)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
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.