diff --git a/libtaskmanager/CMakeLists.txt b/libtaskmanager/CMakeLists.txt index 505bf1e82..d3f2ee203 100644 --- a/libtaskmanager/CMakeLists.txt +++ b/libtaskmanager/CMakeLists.txt @@ -1,109 +1,110 @@ add_subdirectory(declarative) add_subdirectory(autotests) set(taskmanager_LIB_SRCS abstracttasksmodel.cpp + abstracttasksproxymodeliface.cpp activityinfo.cpp concatenatetasksproxymodel.cpp flattentaskgroupsproxymodel.cpp launchertasksmodel.cpp startuptasksmodel.cpp taskfilterproxymodel.cpp taskgroupingproxymodel.cpp tasksmodel.cpp tasktools.cpp virtualdesktopinfo.cpp waylandtasksmodel.cpp windowtasksmodel.cpp ) if (X11_FOUND) set(taskmanager_LIB_SRCS ${taskmanager_LIB_SRCS} xwindowtasksmodel.cpp ) endif() add_library(taskmanager ${taskmanager_LIB_SRCS}) add_library(PW::LibTaskManager ALIAS taskmanager) generate_export_header(taskmanager) target_include_directories(taskmanager PUBLIC "$" "$") target_link_libraries(taskmanager PUBLIC Qt5::Core Qt5::Gui Qt5::Quick KF5::ItemModels PRIVATE KF5::Activities KF5::ConfigCore KF5::KIOCore KF5::KIOWidgets KF5::ProcessCore KF5::WaylandClient KF5::WindowSystem ) if (X11_FOUND) target_link_libraries(taskmanager PRIVATE Qt5::X11Extras KF5::IconThemes) endif() set_target_properties(taskmanager PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION 6 EXPORT_NAME LibTaskManager) install(TARGETS taskmanager EXPORT libtaskmanagerLibraryTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) install(FILES abstracttasksmodel.h abstracttasksmodeliface.h activityinfo.h concatenatetasksproxymodel.h flattentaskgroupsproxymodel.h launchertasksmodel.h startuptasksmodel.h taskfilterproxymodel.h taskgroupingproxymodel.h tasksmodel.h tasktools.h virtualdesktopinfo.h waylandtasksmodel.h windowtasksmodel.h ${CMAKE_CURRENT_BINARY_DIR}/taskmanager_export.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/taskmanager COMPONENT Devel ) if (X11_FOUND) install(FILES xwindowtasksmodel.h ${CMAKE_CURRENT_BINARY_DIR}/taskmanager_export.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/taskmanager COMPONENT Devel ) endif() write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/LibTaskManagerConfigVersion.cmake VERSION "${PROJECT_VERSION}" COMPATIBILITY AnyNewerVersion) set(CMAKECONFIG_INSTALL_DIR ${KDE_INSTALL_LIBDIR}/cmake/LibTaskManager) ecm_configure_package_config_file(LibTaskManagerConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/LibTaskManagerConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/LibTaskManagerConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/LibTaskManagerConfigVersion.cmake DESTINATION ${CMAKECONFIG_INSTALL_DIR}) install(EXPORT libtaskmanagerLibraryTargets NAMESPACE PW:: DESTINATION ${CMAKECONFIG_INSTALL_DIR} FILE LibTaskManagerLibraryTargets.cmake ) install(FILES taskmanagerrulesrc DESTINATION ${KDE_INSTALL_CONFDIR}) diff --git a/libtaskmanager/abstracttasksproxymodeliface.cpp b/libtaskmanager/abstracttasksproxymodeliface.cpp new file mode 100644 index 000000000..a67492678 --- /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/abstracttasksproxymodeliface.h similarity index 74% copy from libtaskmanager/concatenatetasksproxymodel.h copy to libtaskmanager/abstracttasksproxymodeliface.h index e04ef4d91..28bdb5b69 100644 --- a/libtaskmanager/concatenatetasksproxymodel.h +++ b/libtaskmanager/abstracttasksproxymodeliface.h @@ -1,206 +1,200 @@ /******************************************************************** Copyright 2016 Eike Hein 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 . *********************************************************************/ -#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. * * 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); + void requestMove(const QModelIndex &index) Q_DECL_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); + void requestResize(const QModelIndex &index) Q_DECL_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); + void requestToggleMinimized(const QModelIndex &index) Q_DECL_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); + void requestToggleMaximized(const QModelIndex &index) Q_DECL_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); + void requestToggleKeepAbove(const QModelIndex &index) Q_DECL_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); + void requestToggleKeepBelow(const QModelIndex &index) Q_DECL_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); + void requestToggleFullScreen(const QModelIndex &index) Q_DECL_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); + void requestToggleShaded(const QModelIndex &index) Q_DECL_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); + 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 * 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); + 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; + }; } #endif diff --git a/libtaskmanager/concatenatetasksproxymodel.cpp b/libtaskmanager/concatenatetasksproxymodel.cpp index daa0864df..61cea9f18 100644 --- a/libtaskmanager/concatenatetasksproxymodel.cpp +++ b/libtaskmanager/concatenatetasksproxymodel.cpp @@ -1,275 +1,40 @@ /******************************************************************** Copyright 2016 Eike Hein 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 "concatenatetasksproxymodel.h" namespace TaskManager { ConcatenateTasksProxyModel::ConcatenateTasksProxyModel(QObject *parent) : KConcatenateRowsProxyModel(parent) { } ConcatenateTasksProxyModel::~ConcatenateTasksProxyModel() { } -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/concatenatetasksproxymodel.h b/libtaskmanager/concatenatetasksproxymodel.h index e04ef4d91..c268ebaf6 100644 --- a/libtaskmanager/concatenatetasksproxymodel.h +++ b/libtaskmanager/concatenatetasksproxymodel.h @@ -1,206 +1,56 @@ /******************************************************************** Copyright 2016 Eike Hein 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 . *********************************************************************/ #ifndef CONCATENATETASKSPROXYMODEL_H #define CONCATENATETASKSPROXYMODEL_H -#include "abstracttasksmodeliface.h" +#include "abstracttasksproxymodeliface.h" #include #include "taskmanager_export.h" namespace TaskManager { /** * @short A proxy tasks model for concatenating multiple source tasks models. * * This proxy model is a subclass of KConcatenateRowsProxyModel implementing * AbstractTasksModelIface, forwarding calls to the correct source model. * * @author Eike Hein **/ 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; }; } #endif diff --git a/libtaskmanager/flattentaskgroupsproxymodel.cpp b/libtaskmanager/flattentaskgroupsproxymodel.cpp index 22fe52c1c..8b02d5714 100644 --- a/libtaskmanager/flattentaskgroupsproxymodel.cpp +++ b/libtaskmanager/flattentaskgroupsproxymodel.cpp @@ -1,164 +1,64 @@ /******************************************************************** Copyright 2016 Eike Hein 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 "flattentaskgroupsproxymodel.h" namespace TaskManager { class FlattenTaskGroupsProxyModel::Private { public: Private(FlattenTaskGroupsProxyModel *q); AbstractTasksModelIface *sourceTasksModel = nullptr; private: FlattenTaskGroupsProxyModel *q; }; FlattenTaskGroupsProxyModel::Private::Private(FlattenTaskGroupsProxyModel *q) : q(q) { } FlattenTaskGroupsProxyModel::FlattenTaskGroupsProxyModel(QObject *parent) : KDescendantsProxyModel(parent) , d(new Private(this)) { } FlattenTaskGroupsProxyModel::~FlattenTaskGroupsProxyModel() { } void FlattenTaskGroupsProxyModel::setSourceModel(QAbstractItemModel *sourceModel) { d->sourceTasksModel = dynamic_cast(sourceModel); 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/flattentaskgroupsproxymodel.h b/libtaskmanager/flattentaskgroupsproxymodel.h index 95a5675bd..44b65e475 100644 --- a/libtaskmanager/flattentaskgroupsproxymodel.h +++ b/libtaskmanager/flattentaskgroupsproxymodel.h @@ -1,211 +1,63 @@ /******************************************************************** Copyright 2016 Eike Hein 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 . *********************************************************************/ #ifndef FLATTENTASKGROUPSPROXYMODEL_H #define FLATTENTASKGROUPSPROXYMODEL_H -#include "abstracttasksmodeliface.h" +#include "abstracttasksproxymodeliface.h" #include #include "taskmanager_export.h" namespace TaskManager { /** * @short A proxy tasks model for flattening a tree-structured tasks model * into a list-structured tasks model. * * This proxy model is a subclass of KDescendantsProxyModel implementing * AbstractTasksModelIface. * * @author Eike Hein **/ class TASKMANAGER_EXPORT FlattenTaskGroupsProxyModel : public KDescendantsProxyModel, - public AbstractTasksModelIface + public AbstractTasksProxyModelIface { Q_OBJECT public: explicit FlattenTaskGroupsProxyModel(QObject *parent = 0); virtual ~FlattenTaskGroupsProxyModel(); 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; }; } #endif diff --git a/libtaskmanager/taskfilterproxymodel.cpp b/libtaskmanager/taskfilterproxymodel.cpp index 096481bc9..3db94ce94 100644 --- a/libtaskmanager/taskfilterproxymodel.cpp +++ b/libtaskmanager/taskfilterproxymodel.cpp @@ -1,372 +1,271 @@ /******************************************************************** Copyright 2016 Eike Hein 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 "taskfilterproxymodel.h" #include "abstracttasksmodel.h" namespace TaskManager { class TaskFilterProxyModel::Private { public: Private(TaskFilterProxyModel *q); AbstractTasksModelIface *sourceTasksModel = nullptr; uint virtualDesktop = 0; QRect screenGeometry; QString activity; bool filterByVirtualDesktop = false; bool filterByScreen = false; bool filterByActivity = false; bool filterNotMinimized = false; bool filterSkipTaskbar = true; private: TaskFilterProxyModel *q; }; TaskFilterProxyModel::Private::Private(TaskFilterProxyModel *q) : q(q) { } TaskFilterProxyModel::TaskFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent) , d(new Private(this)) { } TaskFilterProxyModel::~TaskFilterProxyModel() { } void TaskFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) { d->sourceTasksModel = dynamic_cast(sourceModel); QSortFilterProxyModel::setSourceModel(sourceModel); } uint TaskFilterProxyModel::virtualDesktop() const { return d->virtualDesktop; } void TaskFilterProxyModel::setVirtualDesktop(uint virtualDesktop) { if (d->virtualDesktop != virtualDesktop) { d->virtualDesktop = virtualDesktop; if (d->filterByVirtualDesktop) { invalidateFilter(); } emit virtualDesktopChanged(); } } QRect TaskFilterProxyModel::screenGeometry() const { return d->screenGeometry; } void TaskFilterProxyModel::setScreenGeometry(const QRect &geometry) { if (d->screenGeometry != geometry) { d->screenGeometry = geometry; if (d->filterByScreen) { invalidateFilter(); } emit screenGeometryChanged(); } } QString TaskFilterProxyModel::activity() const { return d->activity; } void TaskFilterProxyModel::setActivity(const QString &activity) { if (d->activity != activity) { d->activity = activity; if (d->filterByActivity) { invalidateFilter(); } emit activityChanged(); } } bool TaskFilterProxyModel::filterByVirtualDesktop() const { return d->filterByVirtualDesktop; } void TaskFilterProxyModel::setFilterByVirtualDesktop(bool filter) { if (d->filterByVirtualDesktop != filter) { d->filterByVirtualDesktop = filter; invalidateFilter(); emit filterByVirtualDesktopChanged(); } } bool TaskFilterProxyModel::filterByScreen() const { return d->filterByScreen; } void TaskFilterProxyModel::setFilterByScreen(bool filter) { if (d->filterByScreen != filter) { d->filterByScreen = filter; invalidateFilter(); emit filterByScreenChanged(); } } bool TaskFilterProxyModel::filterByActivity() const { return d->filterByActivity; } void TaskFilterProxyModel::setFilterByActivity(bool filter) { if (d->filterByActivity != filter) { d->filterByActivity = filter; invalidateFilter(); emit filterByActivityChanged(); } } bool TaskFilterProxyModel::filterNotMinimized() const { return d->filterNotMinimized; } void TaskFilterProxyModel::setFilterNotMinimized(bool filter) { if (d->filterNotMinimized != filter) { d->filterNotMinimized = filter; invalidateFilter(); emit filterNotMinimizedChanged(); } } bool TaskFilterProxyModel::filterSkipTaskbar() const { return d->filterSkipTaskbar; } void TaskFilterProxyModel::setFilterSkipTaskbar(bool filter) { if (d->filterSkipTaskbar != filter) { d->filterSkipTaskbar = filter; invalidateFilter(); emit filterSkipTaskbarChanged(); } } -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 { Q_UNUSED(sourceParent) const QModelIndex &sourceIdx = sourceModel()->index(sourceRow, 0); // Filter tasks that are not to be shown on the task bar. if (d->filterSkipTaskbar && sourceIdx.data(AbstractTasksModel::SkipTaskbar).toBool()) { return false; } // Filter by virtual desktop. if (d->filterByVirtualDesktop && d->virtualDesktop != 0) { if (!sourceIdx.data(AbstractTasksModel::IsOnAllVirtualDesktops).toBool() && !sourceIdx.data(AbstractTasksModel::IsDemandingAttention).toBool()) { const QVariant &virtualDesktop = sourceIdx.data(AbstractTasksModel::VirtualDesktop); if (!virtualDesktop.isNull()) { bool ok = false; const uint i = virtualDesktop.toUInt(&ok); if (ok && i != d->virtualDesktop) { return false; } } } } // 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) { return false; } } // Filter by activity. if (d->filterByActivity && !d->activity.isEmpty()) { const QVariant &activities = sourceIdx.data(AbstractTasksModel::Activities); if (!activities.isNull()) { const QStringList l = activities.toStringList(); if (!l.isEmpty() && !l.contains(d->activity)) { return false; } } } // Filter not minimized. if (d->filterNotMinimized) { bool isMinimized = sourceIdx.data(AbstractTasksModel::IsMinimized).toBool(); if (!isMinimized) { return false; } } return true; } } diff --git a/libtaskmanager/taskfilterproxymodel.h b/libtaskmanager/taskfilterproxymodel.h index c0f966b8e..04907b132 100644 --- a/libtaskmanager/taskfilterproxymodel.h +++ b/libtaskmanager/taskfilterproxymodel.h @@ -1,405 +1,253 @@ /******************************************************************** Copyright 2016 Eike Hein 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 . *********************************************************************/ #ifndef TASKFILTERPROXYMODEL_H #define TASKFILTERPROXYMODEL_H #include #include -#include "abstracttasksmodeliface.h" +#include "abstracttasksproxymodeliface.h" #include "taskmanager_export.h" namespace TaskManager { /** * @short A proxy tasks model filtering its source model by various properties. * * This proxy model class filters its source tasks model by properties such as * virtual desktop or minimixed state. The values to filter for or by are set * as properties on the proxy model instance. * * @author Eike Hein **/ -class TASKMANAGER_EXPORT TaskFilterProxyModel : public QSortFilterProxyModel, public AbstractTasksModelIface +class TASKMANAGER_EXPORT TaskFilterProxyModel : public QSortFilterProxyModel, public AbstractTasksProxyModelIface { Q_OBJECT Q_PROPERTY(int virtualDesktop READ virtualDesktop WRITE setVirtualDesktop NOTIFY virtualDesktopChanged) Q_PROPERTY(QRect screenGeomeyry READ screenGeometry WRITE setScreenGeometry NOTIFY screenGeometryChanged) Q_PROPERTY(QString activity READ activity WRITE setActivity NOTIFY activityChanged) Q_PROPERTY(bool filterByVirtualDesktop READ filterByVirtualDesktop WRITE setFilterByVirtualDesktop NOTIFY filterByVirtualDesktopChanged) Q_PROPERTY(bool filterByScreen READ filterByScreen WRITE setFilterByScreen NOTIFY filterByScreenChanged) Q_PROPERTY(bool filterByActivity READ filterByActivity WRITE setFilterByActivity NOTIFY filterByActivityChanged) Q_PROPERTY(bool filterNotMinimized READ filterNotMinimized WRITE setFilterNotMinimized NOTIFY filterNotMinimizedChanged) Q_PROPERTY(bool filterSkipTaskbar READ filterSkipTaskbar WRITE setFilterSkipTaskbar NOTIFY filterSkipTaskbarChanged) public: explicit TaskFilterProxyModel(QObject *parent = 0); virtual ~TaskFilterProxyModel(); void setSourceModel(QAbstractItemModel *sourceModel) override; /** * The number of the virtual desktop used in filtering by virtual * desktop. Usually set to the number of the current virtual desktop. * Defaults to @c 0 (virtual desktop numbers start at 1). * * @see setVirtualDesktop * @returns the number of the virtual desktop used in filtering. **/ uint virtualDesktop() const; /** * Set the number of the virtual desktop to use in filtering by virtual * desktop. * * If set to 0 (virtual desktop numbers start at 1), filtering by virtual * desktop is disabled. * * @see virtualDesktop * @param virtualDesktop A virtual desktop number. **/ void setVirtualDesktop(uint virtualDesktop); /** * The geometry of the screen used in filtering by screen. Defaults * to a null QRect. * * @see setGeometryScreen * @returns the geometry of the screen used in filtering. **/ QRect screenGeometry() const; /** * Set the geometry of the screen to use in filtering by screen. * * If set to an invalid QRect, filtering by screen is disabled. * * @see screenGeometry * @param geometry A screen geometry. **/ void setScreenGeometry(const QRect &geometry); /** * The id of the activity used in filtering by activity. Usually * set to the id of the current activity. Defaults to an empty id. * * @see setActivity * @returns the id of the activity used in filtering. **/ QString activity() const; /** * Set the id of the activity to use in filtering by activity. * * @see activity * @param activity An activity id. **/ void setActivity(const QString &activity); /** * Whether tasks should be filtered by virtual desktop. Defaults to * @c false. * * Filtering by virtual desktop only happens if a virtual desktop * number greater than -1 is set, even if this returns @c true. * * @see setFilterByVirtualDesktop * @see setVirtualDesktop * @returns @c true if tasks should be filtered by virtual desktop. **/ bool filterByVirtualDesktop() const; /** * Set whether tasks should be filtered by virtual desktop. * * Filtering by virtual desktop only happens if a virtual desktop * number is set, even if this is set to @c true. * * @see filterByVirtualDesktop * @see setVirtualDesktop * @param filter Whether tasks should be filtered by virtual desktop. **/ void setFilterByVirtualDesktop(bool filter); /** * Whether tasks should be filtered by screen. Defaults to @c false. * * Filtering by screen only happens if a screen number is set, even * if this returns @c true. * * @see setFilterByScreen * @see setScreen * @returns @c true if tasks should be filtered by screen. **/ bool filterByScreen() const; /** * Set whether tasks should be filtered by screen. * * Filtering by screen only happens if a screen number is set, even * if this is set to @c true. * * @see filterByScreen * @see setScreen * @param filter Whether tasks should be filtered by screen. **/ void setFilterByScreen(bool filter); /** * Whether tasks should be filtered by activity. Defaults to @c false. * * Filtering by activity only happens if an activity id is set, even * if this returns @c true. * * @see setFilterByActivity * @see setActivity * @returns @ctrue if tasks should be filtered by activity. **/ bool filterByActivity() const; /** * Set whether tasks should be filtered by activity. Defaults to * @c false. * * Filtering by virtual desktop only happens if an activity id is set, * even if this is set to @c true. * * @see filterByActivity * @see setActivity * @param filter Whether tasks should be filtered by activity. **/ void setFilterByActivity(bool filter); /** * Whether non-minimized tasks should be filtered. Defaults to * @c false. * * @see setFilterNotMinimized * @returns @c true if non-minimized tasks should be filtered. **/ bool filterNotMinimized() const; /** * Set whether non-minimized tasks should be filtered. * * @see filterNotMinimized * @param filter Whether non-minimized tasks should be filtered. **/ void setFilterNotMinimized(bool filter); /** * Whether tasks which indicate they want to be omitted from 'task bars' * should be filtered. Defaults to @c true. * * @see setFilterSkipTaskbar * @returns @c true if tasks which want to skip the 'task bar' should be * filtered. **/ bool filterSkipTaskbar() const; /** * Set whether tasks which indicate they want to be omitted from 'task bars' * should be filtered. * * @see filterSkipTaskbar * @param filter Whether tasks which want to skip the 'task bar' should be * 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; void activityChanged() const; void filterByVirtualDesktopChanged() const; void filterByScreenChanged() const; void filterByActivityChanged() const; void filterNotMinimizedChanged() const; void filterSkipTaskbarChanged() const; protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; + QModelIndex mapIfaceToSource(const QModelIndex &index) const Q_DECL_OVERRIDE; private: class Private; QScopedPointer d; }; } #endif diff --git a/libtaskmanager/windowtasksmodel.cpp b/libtaskmanager/windowtasksmodel.cpp index 8ac96529a..509d35856 100644 --- a/libtaskmanager/windowtasksmodel.cpp +++ b/libtaskmanager/windowtasksmodel.cpp @@ -1,210 +1,110 @@ /******************************************************************** Copyright 2016 Eike Hein 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 "windowtasksmodel.h" #include #include "waylandtasksmodel.h" #if HAVE_X11 #include "xwindowtasksmodel.h" #endif #include namespace TaskManager { class WindowTasksModel::Private { public: Private(WindowTasksModel *q); ~Private(); static int instanceCount; static AbstractTasksModel* sourceTasksModel; void initSourceTasksModel(); private: WindowTasksModel *q; }; int WindowTasksModel::Private::instanceCount = 0; AbstractTasksModel* WindowTasksModel::Private::sourceTasksModel = nullptr; WindowTasksModel::Private::Private(WindowTasksModel *q) : q(q) { ++instanceCount; } WindowTasksModel::Private::~Private() { --instanceCount; if (!instanceCount) { delete sourceTasksModel; sourceTasksModel = nullptr; } } void WindowTasksModel::Private::initSourceTasksModel() { if (!sourceTasksModel && KWindowSystem::isPlatformWayland()) { sourceTasksModel = new WaylandTasksModel(); } #if HAVE_X11 if (!sourceTasksModel && KWindowSystem::isPlatformX11()) { sourceTasksModel = new XWindowTasksModel(); } #endif q->setSourceModel(sourceTasksModel); } WindowTasksModel::WindowTasksModel(QObject *parent) : QIdentityProxyModel(parent) , d(new Private(this)) { d->initSourceTasksModel(); } WindowTasksModel::~WindowTasksModel() { } QHash WindowTasksModel::roleNames() const { if (d->sourceTasksModel) { return d->sourceTasksModel->roleNames(); } 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); } } diff --git a/libtaskmanager/windowtasksmodel.h b/libtaskmanager/windowtasksmodel.h index 5a75ef4c2..6c3a454cb 100644 --- a/libtaskmanager/windowtasksmodel.h +++ b/libtaskmanager/windowtasksmodel.h @@ -1,177 +1,62 @@ /******************************************************************** Copyright 2016 Eike Hein 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 . *********************************************************************/ #ifndef WINDOWTASKSMODEL_H #define WINDOWTASKSMODEL_H #include -#include "abstracttasksmodeliface.h" +#include "abstracttasksproxymodeliface.h" #include "taskmanager_export.h" namespace TaskManager { /** * @short A window tasks model. * * This model presents tasks sourced from window data retrieved from the * windowing server the host process is connected to. The underlying * windowing system is abstracted away. * * @author Eike Hein **/ -class TASKMANAGER_EXPORT WindowTasksModel : public QIdentityProxyModel, public AbstractTasksModelIface +class TASKMANAGER_EXPORT WindowTasksModel : public QIdentityProxyModel, public AbstractTasksProxyModelIface { Q_OBJECT public: explicit WindowTasksModel(QObject *parent = 0); virtual ~WindowTasksModel(); 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; }; } #endif