diff --git a/libtaskmanager/CMakeLists.txt b/libtaskmanager/CMakeLists.txt --- a/libtaskmanager/CMakeLists.txt +++ b/libtaskmanager/CMakeLists.txt @@ -3,6 +3,7 @@ set(taskmanager_LIB_SRCS abstracttasksmodel.cpp + abstracttasksproxymodeliface.cpp activityinfo.cpp concatenatetasksproxymodel.cpp flattentaskgroupsproxymodel.cpp diff --git a/libtaskmanager/concatenatetasksproxymodel.h b/libtaskmanager/abstracttasksproxymodeliface.h copy from libtaskmanager/concatenatetasksproxymodel.h copy to libtaskmanager/abstracttasksproxymodeliface.h --- a/libtaskmanager/concatenatetasksproxymodel.h +++ b/libtaskmanager/abstracttasksproxymodeliface.h @@ -18,68 +18,55 @@ License along with this library. If not, see . *********************************************************************/ -#ifndef CONCATENATETASKSPROXYMODEL_H -#define CONCATENATETASKSPROXYMODEL_H +#ifndef ABSTRACTASKSPROXYMODELIFACE_H +#define ABSTRACTASKSPROXYMODELIFACE_H -#include "abstracttasksmodeliface.h" - -#include +#include #include "taskmanager_export.h" +#include "abstracttasksmodeliface.h" namespace TaskManager { /** - * @short A proxy tasks model for concatenating multiple source tasks models. + * @short Pure method interface for tasks model implementations. * - * This proxy model is a subclass of KConcatenateRowsProxyModel implementing - * AbstractTasksModelIface, forwarding calls to the correct source model. + * This is the pure method interface implemented by AbstractTasksModel, + * as well as other model classes in this library which cannot inherit from + * AbstractTasksModel. * * @author Eike Hein **/ -class TASKMANAGER_EXPORT ConcatenateTasksProxyModel : public KConcatenateRowsProxyModel, - public AbstractTasksModelIface +class TASKMANAGER_EXPORT AbstractTasksProxyModelIface : public AbstractTasksModelIface { - Q_OBJECT - public: - explicit ConcatenateTasksProxyModel(QObject *parent = 0); - virtual ~ConcatenateTasksProxyModel(); + ~AbstractTasksProxyModelIface() {} /** - * Request activation of the task at the given index. Derived classes are - * free to interpret the meaning of "activate" themselves depending on + * Request activation of the task at the given index. Implementing classes + * are free to interpret the meaning of "activate" themselves depending on * the nature and state of the task, e.g. launch or raise a window task. * * @param index An index in this tasks model. **/ - void requestActivate(const QModelIndex &index); + void requestActivate(const QModelIndex &index) Q_DECL_OVERRIDE; /** * Request an additional instance of the application backing the task * at the given index. * * @param index An index in this tasks model. **/ - void requestNewInstance(const QModelIndex &index); - - /** - * Requests to open the given URLs with the application backing the task - * at the given index. - * - * @param index An index in this tasks model. - * @param urls The URLs to be passed to the application. - **/ - virtual void requestOpenUrls(const QModelIndex &index, const QList &urls); + void requestNewInstance(const QModelIndex &index) Q_DECL_OVERRIDE; /** * Request the task at the given index be closed. * * @param index An index in this tasks model. **/ - void requestClose(const QModelIndex &index); + void requestClose(const QModelIndex &index) Q_DECL_OVERRIDE; /** * Request starting an interactive move for the task at the given index. @@ -89,7 +76,7 @@ * * @param index An index in this tasks model. **/ - void requestMove(const QModelIndex &index); + void requestMove(const QModelIndex &index) Q_DECL_OVERRIDE; /** * Request starting an interactive resize for the task at the given index. @@ -99,7 +86,7 @@ * * @param index An index in this tasks model. **/ - void requestResize(const QModelIndex &index); + void requestResize(const QModelIndex &index) Q_DECL_OVERRIDE; /** * Request toggling the minimized state of the task at the given index. @@ -109,7 +96,7 @@ * * @param index An index in this tasks model. **/ - void requestToggleMinimized(const QModelIndex &index); + void requestToggleMinimized(const QModelIndex &index) Q_DECL_OVERRIDE; /** * Request toggling the maximized state of the task at the given index. @@ -119,7 +106,7 @@ * * @param index An index in this tasks model. **/ - void requestToggleMaximized(const QModelIndex &index); + void requestToggleMaximized(const QModelIndex &index) Q_DECL_OVERRIDE; /** * Request toggling the keep-above state of the task at the given index. @@ -129,7 +116,7 @@ * * @param index An index in this tasks model. **/ - void requestToggleKeepAbove(const QModelIndex &index); + void requestToggleKeepAbove(const QModelIndex &index) Q_DECL_OVERRIDE; /** * Request toggling the keep-below state of the task at the given index. @@ -139,7 +126,7 @@ * * @param index An index in this tasks model. **/ - void requestToggleKeepBelow(const QModelIndex &index); + void requestToggleKeepBelow(const QModelIndex &index) Q_DECL_OVERRIDE; /** * Request toggling the fullscreen state of the task at the given index. @@ -149,7 +136,7 @@ * * @param index An index in this tasks model. **/ - void requestToggleFullScreen(const QModelIndex &index); + void requestToggleFullScreen(const QModelIndex &index) Q_DECL_OVERRIDE; /** * Request toggling the shaded state of the task at the given index. @@ -159,7 +146,7 @@ * * @param index An index in this tasks model. **/ - void requestToggleShaded(const QModelIndex &index); + void requestToggleShaded(const QModelIndex &index) Q_DECL_OVERRIDE; /** * Request moving the task at the given index to the specified virtual @@ -171,20 +158,18 @@ * @param index An index in this tasks model. * @param desktop A virtual desktop number. **/ - void requestVirtualDesktop(const QModelIndex &index, qint32 desktop); + void requestVirtualDesktop(const QModelIndex &index, qint32 desktop = -1) Q_DECL_OVERRIDE; /** * Request moving the task at the given index to the specified activities. * * This is meant for tasks that have an associated window, and may be * a no-op when there is no window. * - * This base implementation does nothing. - * * @param index An index in this tasks model. * @param activities The new list of activities. **/ - void requestActivities(const QModelIndex &index, const QStringList &activities); + void requestActivities(const QModelIndex &index, const QStringList &activities) Q_DECL_OVERRIDE; /** * Request informing the window manager of new geometry for a visual @@ -198,7 +183,16 @@ * reject invalid objects. **/ void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, - QObject *delegate = nullptr); + QObject *delegate = nullptr) Q_DECL_OVERRIDE; + +protected: + /* + * Map the passed QModelIndex to the source model index + * so that AbstractTasksModelIface methods can be passed on + * Subclasses should override this. + */ + virtual QModelIndex mapIfaceToSource(const QModelIndex &index) const = 0; + }; } diff --git a/libtaskmanager/abstracttasksproxymodeliface.cpp b/libtaskmanager/abstracttasksproxymodeliface.cpp new file mode 100644 --- /dev/null +++ b/libtaskmanager/abstracttasksproxymodeliface.cpp @@ -0,0 +1,225 @@ +/******************************************************************** +Copyright 2016 David Edmundson + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*********************************************************************/ + +#include "abstracttasksproxymodeliface.h" + +#include +#include + +namespace TaskManager +{ + +void AbstractTasksProxyModelIface::requestActivate(const QModelIndex &index) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestActivate(sourceIndex); + } +} + +void AbstractTasksProxyModelIface::requestNewInstance(const QModelIndex &index) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestNewInstance(sourceIndex); + } +} + +void AbstractTasksProxyModelIface::requestClose(const QModelIndex &index) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestClose(sourceIndex); + } +} +void AbstractTasksProxyModelIface::requestMove(const QModelIndex &index) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestMove(sourceIndex); + } +} + +void AbstractTasksProxyModelIface::requestResize(const QModelIndex &index) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestResize(sourceIndex); + } +} + +void AbstractTasksProxyModelIface::requestToggleMinimized(const QModelIndex &index) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestToggleMinimized(sourceIndex); + } +} + +void AbstractTasksProxyModelIface::requestToggleMaximized(const QModelIndex &index) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestToggleMaximized(sourceIndex); + } +} + +void AbstractTasksProxyModelIface::requestToggleKeepAbove(const QModelIndex &index) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestToggleKeepAbove(sourceIndex); + } +} + +void AbstractTasksProxyModelIface::requestToggleKeepBelow(const QModelIndex &index) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestToggleKeepBelow(sourceIndex); + } +} + +void AbstractTasksProxyModelIface::requestToggleFullScreen(const QModelIndex &index) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestToggleFullScreen(sourceIndex); + } +} + +void AbstractTasksProxyModelIface::requestToggleShaded(const QModelIndex &index) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestToggleShaded(sourceIndex); + } +} + +void AbstractTasksProxyModelIface::requestVirtualDesktop(const QModelIndex &index, qint32 desktop) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestVirtualDesktop(sourceIndex, desktop); + } +} + +void AbstractTasksProxyModelIface::requestActivities(const QModelIndex &index, const QStringList &activities) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestActivities(sourceIndex, activities); + } +} + + +void AbstractTasksProxyModelIface::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate) +{ + if (!index.isValid()) { + return; + } + + const QModelIndex &sourceIndex = mapIfaceToSource(index); + const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); + + if (m) { + const_cast(m)->requestPublishDelegateGeometry(sourceIndex, geometry, delegate); + } +} + +} diff --git a/libtaskmanager/concatenatetasksproxymodel.h b/libtaskmanager/concatenatetasksproxymodel.h --- a/libtaskmanager/concatenatetasksproxymodel.h +++ b/libtaskmanager/concatenatetasksproxymodel.h @@ -21,7 +21,7 @@ #ifndef CONCATENATETASKSPROXYMODEL_H #define CONCATENATETASKSPROXYMODEL_H -#include "abstracttasksmodeliface.h" +#include "abstracttasksproxymodeliface.h" #include @@ -40,165 +40,15 @@ **/ class TASKMANAGER_EXPORT ConcatenateTasksProxyModel : public KConcatenateRowsProxyModel, - public AbstractTasksModelIface + public AbstractTasksProxyModelIface { Q_OBJECT public: explicit ConcatenateTasksProxyModel(QObject *parent = 0); virtual ~ConcatenateTasksProxyModel(); - - /** - * Request activation of the task at the given index. Derived classes are - * free to interpret the meaning of "activate" themselves depending on - * the nature and state of the task, e.g. launch or raise a window task. - * - * @param index An index in this tasks model. - **/ - void requestActivate(const QModelIndex &index); - - /** - * Request an additional instance of the application backing the task - * at the given index. - * - * @param index An index in this tasks model. - **/ - void requestNewInstance(const QModelIndex &index); - - /** - * Requests to open the given URLs with the application backing the task - * at the given index. - * - * @param index An index in this tasks model. - * @param urls The URLs to be passed to the application. - **/ - virtual void requestOpenUrls(const QModelIndex &index, const QList &urls); - - /** - * Request the task at the given index be closed. - * - * @param index An index in this tasks model. - **/ - void requestClose(const QModelIndex &index); - - /** - * Request starting an interactive move for the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestMove(const QModelIndex &index); - - /** - * Request starting an interactive resize for the task at the given index. - * - * This is meant for tasks that have an associated window, and may be a - * no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestResize(const QModelIndex &index); - - /** - * Request toggling the minimized state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleMinimized(const QModelIndex &index); - - /** - * Request toggling the maximized state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleMaximized(const QModelIndex &index); - - /** - * Request toggling the keep-above state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleKeepAbove(const QModelIndex &index); - - /** - * Request toggling the keep-below state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleKeepBelow(const QModelIndex &index); - - /** - * Request toggling the fullscreen state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleFullScreen(const QModelIndex &index); - - /** - * Request toggling the shaded state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleShaded(const QModelIndex &index); - - /** - * Request moving the task at the given index to the specified virtual - * desktop. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - * @param desktop A virtual desktop number. - **/ - void requestVirtualDesktop(const QModelIndex &index, qint32 desktop); - - /** - * Request moving the task at the given index to the specified activities. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * This base implementation does nothing. - * - * @param index An index in this tasks model. - * @param activities The new list of activities. - **/ - void requestActivities(const QModelIndex &index, const QStringList &activities); - - /** - * Request informing the window manager of new geometry for a visual - * delegate for the task at the given index. The geometry should be in - * screen coordinates. - * - * @param index An index in this tasks model. - * @param geometry Visual delegate geometry in screen coordinates. - * @param delegate The delegate. Implementations are on their own with - * regard to extracting information from this, and should take care to - * reject invalid objects. - **/ - void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, - QObject *delegate = nullptr); +protected: + QModelIndex mapIfaceToSource(const QModelIndex &index) const Q_DECL_OVERRIDE; }; } diff --git a/libtaskmanager/concatenatetasksproxymodel.cpp b/libtaskmanager/concatenatetasksproxymodel.cpp --- a/libtaskmanager/concatenatetasksproxymodel.cpp +++ b/libtaskmanager/concatenatetasksproxymodel.cpp @@ -32,244 +32,9 @@ { } -void ConcatenateTasksProxyModel::requestActivate(const QModelIndex &index) +QModelIndex ConcatenateTasksProxyModel::mapIfaceToSource(const QModelIndex &index) const { - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestActivate(sourceIndex); - } -} - -void ConcatenateTasksProxyModel::requestNewInstance(const QModelIndex &index) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestNewInstance(sourceIndex); - } -} - -void ConcatenateTasksProxyModel::requestOpenUrls(const QModelIndex &index, const QList &urls) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestOpenUrls(sourceIndex, urls); - } -} - -void ConcatenateTasksProxyModel::requestClose(const QModelIndex &index) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestClose(sourceIndex); - } -} -void ConcatenateTasksProxyModel::requestMove(const QModelIndex &index) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestMove(sourceIndex); - } -} - -void ConcatenateTasksProxyModel::requestResize(const QModelIndex &index) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestResize(sourceIndex); - } -} - -void ConcatenateTasksProxyModel::requestToggleMinimized(const QModelIndex &index) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestToggleMinimized(sourceIndex); - } -} - -void ConcatenateTasksProxyModel::requestToggleMaximized(const QModelIndex &index) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestToggleMaximized(sourceIndex); - } -} - -void ConcatenateTasksProxyModel::requestToggleKeepAbove(const QModelIndex &index) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestToggleKeepAbove(sourceIndex); - } -} - -void ConcatenateTasksProxyModel::requestToggleKeepBelow(const QModelIndex &index) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestToggleKeepBelow(sourceIndex); - } -} - -void ConcatenateTasksProxyModel::requestToggleFullScreen(const QModelIndex &index) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestToggleFullScreen(sourceIndex); - } -} - -void ConcatenateTasksProxyModel::requestToggleShaded(const QModelIndex &index) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestToggleShaded(sourceIndex); - } -} - -void ConcatenateTasksProxyModel::requestVirtualDesktop(const QModelIndex &index, qint32 desktop) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestVirtualDesktop(sourceIndex, desktop); - } -} - -void ConcatenateTasksProxyModel::requestActivities(const QModelIndex &index, const QStringList &activities) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestActivities(sourceIndex, activities); - } -} - - -void ConcatenateTasksProxyModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate) -{ - if (!index.isValid() || index.model() != this) { - return; - } - - const QModelIndex &sourceIndex = mapToSource(index); - const AbstractTasksModelIface *m = dynamic_cast(sourceIndex.model()); - - if (m) { - // NOTE: KConcatenateRowsProxyModel offers no way to get a non-const pointer - // to one of the source models, so we have to go through a mapped index. - const_cast(m)->requestPublishDelegateGeometry(sourceIndex, geometry, delegate); - } + return mapToSource(index); } } diff --git a/libtaskmanager/flattentaskgroupsproxymodel.h b/libtaskmanager/flattentaskgroupsproxymodel.h --- a/libtaskmanager/flattentaskgroupsproxymodel.h +++ b/libtaskmanager/flattentaskgroupsproxymodel.h @@ -21,7 +21,7 @@ #ifndef FLATTENTASKGROUPSPROXYMODEL_H #define FLATTENTASKGROUPSPROXYMODEL_H -#include "abstracttasksmodeliface.h" +#include "abstracttasksproxymodeliface.h" #include @@ -41,7 +41,7 @@ **/ class TASKMANAGER_EXPORT FlattenTaskGroupsProxyModel : public KDescendantsProxyModel, - public AbstractTasksModelIface + public AbstractTasksProxyModelIface { Q_OBJECT @@ -51,156 +51,8 @@ void setSourceModel(QAbstractItemModel *sourceModel) override; - /** - * Request activation of the task at the given index. Derived classes are - * free to interpret the meaning of "activate" themselves depending on - * the nature and state of the task, e.g. launch or raise a window task. - * - * @param index An index in this tasks model. - **/ - void requestActivate(const QModelIndex &index) override; - - /** - * Request an additional instance of the application backing the task - * at the given index. - * - * @param index An index in this tasks model. - **/ - void requestNewInstance(const QModelIndex &index) override; - - /** - * Requests to open the given URLs with the application backing the task - * at the given index. - * - * @param index An index in this tasks model. - * @param urls The URLs to be passed to the application. - **/ - virtual void requestOpenUrls(const QModelIndex &index, const QList &urls); - - /** - * Request the task at the given index be closed. - * - * @param index An index in this tasks model. - **/ - void requestClose(const QModelIndex &index) override; - - /** - * Request starting an interactive move for the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestMove(const QModelIndex &index) override; - - /** - * Request starting an interactive resize for the task at the given index. - * - * This is meant for tasks that have an associated window, and may be a - * no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestResize(const QModelIndex &index) override; - - /** - * Request toggling the minimized state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleMinimized(const QModelIndex &index) override; - - /** - * Request toggling the maximized state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleMaximized(const QModelIndex &index) override; - - /** - * Request toggling the keep-above state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleKeepAbove(const QModelIndex &index) override; - - /** - * Request toggling the keep-below state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleKeepBelow(const QModelIndex &index) override; - - /** - * Request toggling the fullscreen state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleFullScreen(const QModelIndex &index) override; - - /** - * Request toggling the shaded state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleShaded(const QModelIndex &index) override; - - /** - * Request moving the task at the given index to the specified virtual - * desktop. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - * @param desktop A virtual desktop number. - **/ - void requestVirtualDesktop(const QModelIndex &index, qint32 desktop) override; - - /** - * Request moving the task at the given index to the specified activities. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * * - * @param index An index in this tasks model. - * @param activities The new list of activities. - **/ - void requestActivities(const QModelIndex &index, const QStringList &activities) override; - - /** - * Request informing the window manager of new geometry for a visual - * delegate for the task at the given index. The geometry should be in - * screen coordinates. - * - * @param index An index in this tasks model. - * @param geometry Visual delegate geometry in screen coordinates. - * @param delegate The delegate. Implementations are on their own with - * regard to extracting information from this, and should take care to - * reject invalid objects. - **/ - void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, - QObject *delegate = nullptr) override; - +protected: + QModelIndex mapIfaceToSource(const QModelIndex &index) const Q_DECL_OVERRIDE; private: class Private; QScopedPointer d; diff --git a/libtaskmanager/flattentaskgroupsproxymodel.cpp b/libtaskmanager/flattentaskgroupsproxymodel.cpp --- a/libtaskmanager/flattentaskgroupsproxymodel.cpp +++ b/libtaskmanager/flattentaskgroupsproxymodel.cpp @@ -56,109 +56,9 @@ KDescendantsProxyModel::setSourceModel(sourceModel); } -void FlattenTaskGroupsProxyModel::requestActivate(const QModelIndex &index) +QModelIndex FlattenTaskGroupsProxyModel::mapIfaceToSource(const QModelIndex &index) const { - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestActivate(mapToSource(index)); - } -} - -void FlattenTaskGroupsProxyModel::requestNewInstance(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestNewInstance(mapToSource(index)); - } -} - -void FlattenTaskGroupsProxyModel::requestOpenUrls(const QModelIndex &index, const QList &urls) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestOpenUrls(mapToSource(index), urls); - } -} - -void FlattenTaskGroupsProxyModel::requestClose(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestClose(mapToSource(index)); - } -} - -void FlattenTaskGroupsProxyModel::requestMove(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestMove(mapToSource(index)); - } -} - -void FlattenTaskGroupsProxyModel::requestResize(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestResize(mapToSource(index)); - } -} - -void FlattenTaskGroupsProxyModel::requestToggleMinimized(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleMinimized(mapToSource(index)); - } -} - -void FlattenTaskGroupsProxyModel::requestToggleMaximized(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleMaximized(mapToSource(index)); - } -} - -void FlattenTaskGroupsProxyModel::requestToggleKeepAbove(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleKeepAbove(mapToSource(index)); - } -} - -void FlattenTaskGroupsProxyModel::requestToggleKeepBelow(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleKeepBelow(mapToSource(index)); - } -} - -void FlattenTaskGroupsProxyModel::requestToggleFullScreen(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleFullScreen(mapToSource(index)); - } -} - -void FlattenTaskGroupsProxyModel::requestToggleShaded(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleShaded(mapToSource(index)); - } -} - -void FlattenTaskGroupsProxyModel::requestVirtualDesktop(const QModelIndex &index, qint32 desktop) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestVirtualDesktop(mapToSource(index), desktop); - } -} - -void FlattenTaskGroupsProxyModel::requestActivities(const QModelIndex &index, const QStringList &activities) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestActivities(mapToSource(index), activities); - } -} - -void FlattenTaskGroupsProxyModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate) -{ - if (index.isValid() && index.model() == this) { - d->sourceTasksModel->requestPublishDelegateGeometry(mapToSource(index), geometry, delegate); - } + return mapToSource(index); } } diff --git a/libtaskmanager/taskfilterproxymodel.h b/libtaskmanager/taskfilterproxymodel.h --- a/libtaskmanager/taskfilterproxymodel.h +++ b/libtaskmanager/taskfilterproxymodel.h @@ -24,7 +24,7 @@ #include #include -#include "abstracttasksmodeliface.h" +#include "abstracttasksproxymodeliface.h" #include "taskmanager_export.h" @@ -41,7 +41,7 @@ * @author Eike Hein **/ -class TASKMANAGER_EXPORT TaskFilterProxyModel : public QSortFilterProxyModel, public AbstractTasksModelIface +class TASKMANAGER_EXPORT TaskFilterProxyModel : public QSortFilterProxyModel, public AbstractTasksProxyModelIface { Q_OBJECT @@ -229,159 +229,6 @@ * filtered. **/ void setFilterSkipTaskbar(bool filter); - - /** - * Request activation of the task at the given index. Derived classes are - * free to interpret the meaning of "activate" themselves depending on - * the nature and state of the task, e.g. launch or raise a window task. - * - * @param index An index in this tasks model. - **/ - void requestActivate(const QModelIndex &index) override; - - /** - * Request an additional instance of the application backing the task - * at the given index. - * - * @param index An index in this tasks model. - **/ - void requestNewInstance(const QModelIndex &index) override; - - /** - * Requests to open the given URLs with the application backing the task - * at the given index. - * - * @param index An index in this tasks model. - * @param urls The URLs to be passed to the application. - **/ - virtual void requestOpenUrls(const QModelIndex &index, const QList &urls); - - /** - * Request the task at the given index be closed. - * - * @param index An index in this tasks model. - **/ - void requestClose(const QModelIndex &index) override; - - /** - * Request starting an interactive move for the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestMove(const QModelIndex &index) override; - - /** - * Request starting an interactive resize for the task at the given index. - * - * This is meant for tasks that have an associated window, and may be a - * no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestResize(const QModelIndex &index) override; - - /** - * Request toggling the minimized state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleMinimized(const QModelIndex &index) override; - - /** - * Request toggling the maximized state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleMaximized(const QModelIndex &index) override; - - /** - * Request toggling the keep-above state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleKeepAbove(const QModelIndex &index) override; - - /** - * Request toggling the keep-below state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleKeepBelow(const QModelIndex &index) override; - - /** - * Request toggling the fullscreen state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleFullScreen(const QModelIndex &index) override; - - /** - * Request toggling the shaded state of the task at the given index. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - **/ - void requestToggleShaded(const QModelIndex &index) override; - - /** - * Request moving the task at the given index to the specified virtual - * desktop. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * @param index An index in this tasks model. - * @param desktop A virtual desktop number. - **/ - void requestVirtualDesktop(const QModelIndex &index, qint32 desktop) override; - - /** - * Request moving the task at the given index to the specified activities. - * - * This is meant for tasks that have an associated window, and may be - * a no-op when there is no window. - * - * This base implementation does nothing. - * - * @param index An index in this tasks model. - * @param activities The new list of activities. - **/ - void requestActivities(const QModelIndex &index, const QStringList &activities) override; - - /** - * Request informing the window manager of new geometry for a visual - * delegate for the task at the given index. The geometry should be in - * screen coordinates. - * - * @param index An index in this tasks model. - * @param geometry Visual delegate geometry in screen coordinates. - * @param delegate The delegate. Implementations are on their own with - * regard to extracting information from this, and should take care to - * reject invalid objects. - **/ - void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, - QObject *delegate = nullptr) override; - Q_SIGNALS: void virtualDesktopChanged() const; void screenGeometryChanged() const; @@ -394,6 +241,7 @@ protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; + QModelIndex mapIfaceToSource(const QModelIndex &index) const Q_DECL_OVERRIDE; private: class Private; diff --git a/libtaskmanager/taskfilterproxymodel.cpp b/libtaskmanager/taskfilterproxymodel.cpp --- a/libtaskmanager/taskfilterproxymodel.cpp +++ b/libtaskmanager/taskfilterproxymodel.cpp @@ -201,110 +201,9 @@ } } -void TaskFilterProxyModel::requestActivate(const QModelIndex &index) +QModelIndex TaskFilterProxyModel::mapIfaceToSource(const QModelIndex &index) const { - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestActivate(mapToSource(index)); - } -} - -void TaskFilterProxyModel::requestNewInstance(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestNewInstance(mapToSource(index)); - } -} - -void TaskFilterProxyModel::requestOpenUrls(const QModelIndex &index, const QList &urls) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestOpenUrls(mapToSource(index), urls); - } -} - - -void TaskFilterProxyModel::requestClose(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestClose(mapToSource(index)); - } -} - -void TaskFilterProxyModel::requestMove(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestMove(mapToSource(index)); - } -} - -void TaskFilterProxyModel::requestResize(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestResize(mapToSource(index)); - } -} - -void TaskFilterProxyModel::requestToggleMinimized(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleMinimized(mapToSource(index)); - } -} - -void TaskFilterProxyModel::requestToggleMaximized(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleMaximized(mapToSource(index)); - } -} - -void TaskFilterProxyModel::requestToggleKeepAbove(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleKeepAbove(mapToSource(index)); - } -} - -void TaskFilterProxyModel::requestToggleKeepBelow(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleKeepBelow(mapToSource(index)); - } -} - -void TaskFilterProxyModel::requestToggleFullScreen(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleFullScreen(mapToSource(index)); - } -} - -void TaskFilterProxyModel::requestToggleShaded(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleShaded(mapToSource(index)); - } -} - -void TaskFilterProxyModel::requestVirtualDesktop(const QModelIndex &index, qint32 desktop) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestVirtualDesktop(mapToSource(index), desktop); - } -} - -void TaskFilterProxyModel::requestActivities(const QModelIndex &index, const QStringList &activities) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestActivities(mapToSource(index), activities); - } -} - -void TaskFilterProxyModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate) -{ - if (index.isValid() && index.model() == this) { - d->sourceTasksModel->requestPublishDelegateGeometry(mapToSource(index), geometry, delegate); - } + return mapToSource(index); } bool TaskFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const @@ -336,7 +235,7 @@ } // Filter by screen. - if (d->filterByScreen && d->screenGeometry.isValid()) { + if (d->filterByScreen && d->screenGeometry.isValid()) { const QRect &screenGeometry = sourceIdx.data(AbstractTasksModel::ScreenGeometry).toRect(); if (screenGeometry.isValid() && screenGeometry != d->screenGeometry) { diff --git a/libtaskmanager/windowtasksmodel.h b/libtaskmanager/windowtasksmodel.h --- a/libtaskmanager/windowtasksmodel.h +++ b/libtaskmanager/windowtasksmodel.h @@ -23,7 +23,7 @@ #include -#include "abstracttasksmodeliface.h" +#include "abstracttasksproxymodeliface.h" #include "taskmanager_export.h" @@ -40,7 +40,7 @@ * @author Eike Hein **/ -class TASKMANAGER_EXPORT WindowTasksModel : public QIdentityProxyModel, public AbstractTasksModelIface +class TASKMANAGER_EXPORT WindowTasksModel : public QIdentityProxyModel, public AbstractTasksProxyModelIface { Q_OBJECT @@ -50,123 +50,8 @@ QHash roleNames() const override; - /** - * Request activation of the window at the given index. - * - * @param index An index in this window tasks model. - **/ - void requestActivate(const QModelIndex &index) override; - - /** - * Request an additional instance of the application owning the window - * at the given index. Success depends on whether a - * AbstractTasksModel::LauncherUrl could be derived from window metadata. - * - * @param index An index in this window tasks model. - **/ - void requestNewInstance(const QModelIndex &index) override; - - /** - * Runs the application backing the launcher at the given index with the given URLs. - * Success depends on whether a AbstractTasksModel::LauncherUrl could be - * derived from window metadata and a KService could be found from that. - * - * @param index An index in this launcher tasks model - * @param urls The URLs to be passed to the application - */ - void requestOpenUrls(const QModelIndex &index, const QList &urls) override; - - /** - * Request the window at the given index be closed. - * - * @param index An index in this window tasks model. - **/ - void requestClose(const QModelIndex &index) override; - - /** - * Request starting an interactive move for the window at the given index. - * - * @param index An index in this window tasks model. - **/ - void requestMove(const QModelIndex &index) override; - - /** - * Request starting an interactive resize for the window at the given index. - * - * @param index An index in this window tasks model. - **/ - void requestResize(const QModelIndex &index) override; - - /** - * Request toggling the minimized state of the window at the given index. - * - * @param index An index in this window tasks model. - **/ - void requestToggleMinimized(const QModelIndex &index) override; - - /** - * Request toggling the maximized state of the window at the given index. - * - * @param index An index in this window tasks model. - **/ - void requestToggleMaximized(const QModelIndex &index) override; - - /** - * Request toggling the keep-above state of the window at the given index. - * - * @param index An index in this window tasks model. - **/ - void requestToggleKeepAbove(const QModelIndex &index) override; - - /** - * Request toggling the keep-below state of the window at the given index. - * - * @param index An index in this window tasks model. - **/ - void requestToggleKeepBelow(const QModelIndex &index) override; - - /** - * Request toggling the fullscreen state of the window at the given index. - * - * @param index An index in this window tasks model. - **/ - void requestToggleFullScreen(const QModelIndex &index) override; - - /** - * Request toggling the shaded state of the window at the given index. - * - * @param index An index in this window tasks model. - **/ - void requestToggleShaded(const QModelIndex &index) override; - - /** - * Request moving the window at the given index to the specified virtual - * desktop. - * - * @param index An index in this window tasks model. - * @param desktop A virtual desktop number. - **/ - void requestVirtualDesktop(const QModelIndex &index, qint32 desktop) override; - - /** - * Request moving the window at the given index to the specified activities. - * - * @param index An index in this tasks model. - * @param activities The new list of activities. - **/ - void requestActivities(const QModelIndex &index, const QStringList &activities) override; - - /** - * Request informing the window manager of new geometry for a visual - * delegate for the window at the given index. - * - * @param index An index in this window tasks model. - * @param geometry Visual delegate geometry in screen coordinates. - * @param delegate The delegate. - **/ - void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, - QObject *delegate = nullptr) override; - +protected: + QModelIndex mapIfaceToSource(const QModelIndex &index) const Q_DECL_OVERRIDE; private: class Private; QScopedPointer d; diff --git a/libtaskmanager/windowtasksmodel.cpp b/libtaskmanager/windowtasksmodel.cpp --- a/libtaskmanager/windowtasksmodel.cpp +++ b/libtaskmanager/windowtasksmodel.cpp @@ -102,109 +102,9 @@ return QHash(); } -void WindowTasksModel::requestActivate(const QModelIndex &index) +QModelIndex WindowTasksModel::mapIfaceToSource(const QModelIndex &index) const { - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestActivate(mapToSource(index)); - } -} - -void WindowTasksModel::requestNewInstance(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestNewInstance(mapToSource(index)); - } -} - -void WindowTasksModel::requestOpenUrls(const QModelIndex &index, const QList &urls) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestOpenUrls(mapToSource(index), urls); - } -} - -void WindowTasksModel::requestClose(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestClose(mapToSource(index)); - } -} - -void WindowTasksModel::requestMove(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestMove(mapToSource(index)); - } -} - -void WindowTasksModel::requestResize(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestResize(mapToSource(index)); - } -} - -void WindowTasksModel::requestToggleMinimized(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleMinimized(mapToSource(index)); - } -} - -void WindowTasksModel::requestToggleMaximized(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleMaximized(mapToSource(index)); - } -} - -void WindowTasksModel::requestToggleKeepAbove(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleKeepAbove(mapToSource(index)); - } -} - -void WindowTasksModel::requestToggleKeepBelow(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleKeepBelow(mapToSource(index)); - } -} - -void WindowTasksModel::requestToggleFullScreen(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleFullScreen(mapToSource(index)); - } -} - -void WindowTasksModel::requestToggleShaded(const QModelIndex &index) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestToggleShaded(mapToSource(index)); - } -} - -void WindowTasksModel::requestVirtualDesktop(const QModelIndex &index, qint32 desktop) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestVirtualDesktop(mapToSource(index), desktop); - } -} - -void WindowTasksModel::requestActivities(const QModelIndex &index, const QStringList &activities) -{ - if (d->sourceTasksModel && index.isValid() && index.model() == this) { - d->sourceTasksModel->requestActivities(mapToSource(index), activities); - } -} - -void WindowTasksModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate) -{ - if (index.isValid() && index.model() == this) { - d->sourceTasksModel->requestPublishDelegateGeometry(mapToSource(index), geometry, delegate); - } + return mapToSource(index); } }