File indexing completed on 2024-05-05 05:38:34
0001 /* 0002 SPDX-FileCopyrightText: 2016 Eike Hein <hein@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "abstractwindowtasksmodel.h" 0008 0009 #include <QGuiApplication> 0010 #include <QScreen> 0011 0012 namespace TaskManager 0013 { 0014 AbstractWindowTasksModel::AbstractWindowTasksModel(QObject *parent) 0015 : AbstractTasksModel(parent) 0016 { 0017 // TODO: The following will refresh the ScreenGeometry data role for 0018 // all rows whenever any screen is added or changes its geometry. No 0019 // attempt is made to be intelligent and exempt rows that are tech- 0020 // nically unaffected by the change. Doing so would require tracking 0021 // far more state (i.e. what screen a window is on) and be so 0022 // complicated as to invite bugs. As the trigger conditions are 0023 // expected to be rare, this would be premature optimization at this 0024 // time. That assessment may change in the future. 0025 0026 auto screenAdded = [this](const QScreen *screen) { 0027 connect(screen, &QScreen::geometryChanged, this, [this]() { 0028 if (rowCount() == 0) { 0029 return; 0030 } 0031 Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0), QList<int>{ScreenGeometry}); 0032 }); 0033 }; 0034 0035 connect(qGuiApp, &QGuiApplication::screenAdded, this, screenAdded); 0036 0037 foreach (const QScreen *screen, QGuiApplication::screens()) { 0038 screenAdded(screen); 0039 } 0040 } 0041 0042 AbstractWindowTasksModel::~AbstractWindowTasksModel() 0043 { 0044 } 0045 0046 }