File indexing completed on 2024-05-05 05:38:34

0001 /*
0002     SPDX-FileCopyrightText: 2016 David Edmundson <davidedmundson@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 "abstracttasksproxymodeliface.h"
0008 
0009 #include <QAbstractItemModel>
0010 #include <QModelIndex>
0011 
0012 namespace TaskManager
0013 {
0014 void AbstractTasksProxyModelIface::requestActivate(const QModelIndex &index)
0015 {
0016     if (!index.isValid()) {
0017         return;
0018     }
0019 
0020     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0021     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0022 
0023     if (m) {
0024         const_cast<AbstractTasksModelIface *>(m)->requestActivate(sourceIndex);
0025     }
0026 }
0027 
0028 void AbstractTasksProxyModelIface::requestNewInstance(const QModelIndex &index)
0029 {
0030     if (!index.isValid()) {
0031         return;
0032     }
0033 
0034     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0035     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0036 
0037     if (m) {
0038         const_cast<AbstractTasksModelIface *>(m)->requestNewInstance(sourceIndex);
0039     }
0040 }
0041 
0042 void AbstractTasksProxyModelIface::requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls)
0043 {
0044     if (!index.isValid()) {
0045         return;
0046     }
0047 
0048     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0049     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0050 
0051     if (m) {
0052         const_cast<AbstractTasksModelIface *>(m)->requestOpenUrls(sourceIndex, urls);
0053     }
0054 }
0055 
0056 void AbstractTasksProxyModelIface::requestClose(const QModelIndex &index)
0057 {
0058     if (!index.isValid()) {
0059         return;
0060     }
0061 
0062     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0063     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0064 
0065     if (m) {
0066         const_cast<AbstractTasksModelIface *>(m)->requestClose(sourceIndex);
0067     }
0068 }
0069 void AbstractTasksProxyModelIface::requestMove(const QModelIndex &index)
0070 {
0071     if (!index.isValid()) {
0072         return;
0073     }
0074 
0075     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0076     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0077 
0078     if (m) {
0079         const_cast<AbstractTasksModelIface *>(m)->requestMove(sourceIndex);
0080     }
0081 }
0082 
0083 void AbstractTasksProxyModelIface::requestResize(const QModelIndex &index)
0084 {
0085     if (!index.isValid()) {
0086         return;
0087     }
0088 
0089     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0090     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0091 
0092     if (m) {
0093         const_cast<AbstractTasksModelIface *>(m)->requestResize(sourceIndex);
0094     }
0095 }
0096 
0097 void AbstractTasksProxyModelIface::requestToggleMinimized(const QModelIndex &index)
0098 {
0099     if (!index.isValid()) {
0100         return;
0101     }
0102 
0103     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0104     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0105 
0106     if (m) {
0107         const_cast<AbstractTasksModelIface *>(m)->requestToggleMinimized(sourceIndex);
0108     }
0109 }
0110 
0111 void AbstractTasksProxyModelIface::requestToggleMaximized(const QModelIndex &index)
0112 {
0113     if (!index.isValid()) {
0114         return;
0115     }
0116 
0117     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0118     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0119 
0120     if (m) {
0121         const_cast<AbstractTasksModelIface *>(m)->requestToggleMaximized(sourceIndex);
0122     }
0123 }
0124 
0125 void AbstractTasksProxyModelIface::requestToggleKeepAbove(const QModelIndex &index)
0126 {
0127     if (!index.isValid()) {
0128         return;
0129     }
0130 
0131     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0132     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0133 
0134     if (m) {
0135         const_cast<AbstractTasksModelIface *>(m)->requestToggleKeepAbove(sourceIndex);
0136     }
0137 }
0138 
0139 void AbstractTasksProxyModelIface::requestToggleKeepBelow(const QModelIndex &index)
0140 {
0141     if (!index.isValid()) {
0142         return;
0143     }
0144 
0145     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0146     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0147 
0148     if (m) {
0149         const_cast<AbstractTasksModelIface *>(m)->requestToggleKeepBelow(sourceIndex);
0150     }
0151 }
0152 
0153 void AbstractTasksProxyModelIface::requestToggleFullScreen(const QModelIndex &index)
0154 {
0155     if (!index.isValid()) {
0156         return;
0157     }
0158 
0159     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0160     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0161 
0162     if (m) {
0163         const_cast<AbstractTasksModelIface *>(m)->requestToggleFullScreen(sourceIndex);
0164     }
0165 }
0166 
0167 void AbstractTasksProxyModelIface::requestToggleShaded(const QModelIndex &index)
0168 {
0169     if (!index.isValid()) {
0170         return;
0171     }
0172 
0173     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0174     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0175 
0176     if (m) {
0177         const_cast<AbstractTasksModelIface *>(m)->requestToggleShaded(sourceIndex);
0178     }
0179 }
0180 
0181 void AbstractTasksProxyModelIface::requestVirtualDesktops(const QModelIndex &index, const QVariantList &desktops)
0182 {
0183     if (!index.isValid()) {
0184         return;
0185     }
0186 
0187     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0188     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0189 
0190     if (m) {
0191         const_cast<AbstractTasksModelIface *>(m)->requestVirtualDesktops(sourceIndex, desktops);
0192     }
0193 }
0194 
0195 void AbstractTasksProxyModelIface::requestNewVirtualDesktop(const QModelIndex &index)
0196 {
0197     if (!index.isValid()) {
0198         return;
0199     }
0200 
0201     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0202     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0203 
0204     if (m) {
0205         const_cast<AbstractTasksModelIface *>(m)->requestNewVirtualDesktop(sourceIndex);
0206     }
0207 }
0208 
0209 void AbstractTasksProxyModelIface::requestActivities(const QModelIndex &index, const QStringList &activities)
0210 {
0211     if (!index.isValid()) {
0212         return;
0213     }
0214 
0215     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0216     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0217 
0218     if (m) {
0219         const_cast<AbstractTasksModelIface *>(m)->requestActivities(sourceIndex, activities);
0220     }
0221 }
0222 
0223 void AbstractTasksProxyModelIface::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate)
0224 {
0225     if (!index.isValid()) {
0226         return;
0227     }
0228 
0229     const QModelIndex &sourceIndex = mapIfaceToSource(index);
0230     const AbstractTasksModelIface *m = dynamic_cast<const AbstractTasksModelIface *>(sourceIndex.model());
0231 
0232     if (m) {
0233         const_cast<AbstractTasksModelIface *>(m)->requestPublishDelegateGeometry(sourceIndex, geometry, delegate);
0234     }
0235 }
0236 
0237 }