Add TaskManager requestActivities

Summary:
Acts like requestVirtualDesktops only with a QStringList

make runningActivities invokable

Test Plan: See subsequent plasma-desktop review

Reviewers: hein, #plasma

Reviewed By: hein, #plasma

Subscribers: hein, mart, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1814
wilder-5.14
David Edmundson 10 years ago
parent b227b91df8
commit b7f0f2fae7
  1. 6
      libtaskmanager/abstracttasksmodel.cpp
  2. 13
      libtaskmanager/abstracttasksmodel.h
  3. 12
      libtaskmanager/abstracttasksmodeliface.h
  4. 2
      libtaskmanager/activityinfo.h
  5. 17
      libtaskmanager/concatenatetasksproxymodel.cpp
  6. 13
      libtaskmanager/concatenatetasksproxymodel.h
  7. 7
      libtaskmanager/flattentaskgroupsproxymodel.cpp
  8. 11
      libtaskmanager/flattentaskgroupsproxymodel.h
  9. 7
      libtaskmanager/taskfilterproxymodel.cpp
  10. 13
      libtaskmanager/taskfilterproxymodel.h
  11. 21
      libtaskmanager/taskgroupingproxymodel.cpp
  12. 13
      libtaskmanager/taskgroupingproxymodel.h
  13. 7
      libtaskmanager/tasksmodel.cpp
  14. 13
      libtaskmanager/tasksmodel.h
  15. 6
      libtaskmanager/waylandtasksmodel.cpp
  16. 10
      libtaskmanager/waylandtasksmodel.h
  17. 12
      libtaskmanager/xwindowtasksmodel.cpp
  18. 11
      libtaskmanager/xwindowtasksmodel.h

@ -113,6 +113,12 @@ void AbstractTasksModel::requestVirtualDesktop(const QModelIndex &index, qint32
Q_UNUSED(desktop)
}
void AbstractTasksModel::requestActivities(const QModelIndex &index, const QStringList &activities)
{
Q_UNUSED(index)
Q_UNUSED(activities)
}
void AbstractTasksModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate)
{
Q_UNUSED(index)

@ -232,6 +232,19 @@ public:
**/
virtual 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.
**/
virtual 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

@ -159,6 +159,18 @@ public:
**/
virtual void requestVirtualDesktop(const QModelIndex &index, qint32 desktop = -1) = 0;
/**
* Request moving the task at the given index to the specified virtual
* 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.
**/
virtual void requestActivities(const QModelIndex &index, const QStringList &activities) = 0;
/**
* Request informing the window manager of new geometry for a visual
* delegate for the task at the given index. The geometry should be in

@ -72,7 +72,7 @@ public:
*
* @returns the list of currently-running activities defined in the session.
**/
QStringList runningActivities() const;
Q_INVOKABLE QStringList runningActivities() const;
/**
* The name of the activity of the given id.

@ -223,6 +223,23 @@ void ConcatenateTasksProxyModel::requestVirtualDesktop(const QModelIndex &index,
}
}
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<const AbstractTasksModelIface *>(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<AbstractTasksModelIface *>(m)->requestActivities(sourceIndex, activities);
}
}
void ConcatenateTasksProxyModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate)
{
if (!index.isValid() || index.model() != this) {

@ -164,6 +164,19 @@ public:
**/
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

@ -140,6 +140,13 @@ void FlattenTaskGroupsProxyModel::requestVirtualDesktop(const QModelIndex &index
}
}
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) {

@ -167,6 +167,17 @@ public:
**/
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);
/**
* Request informing the window manager of new geometry for a visual
* delegate for the task at the given index. The geometry should be in

@ -268,6 +268,13 @@ void TaskFilterProxyModel::requestVirtualDesktop(const QModelIndex &index, qint3
}
}
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) {

@ -324,6 +324,19 @@ public:
**/
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);
/**
* Request informing the window manager of new geometry for a visual
* delegate for the task at the given index. The geometry should be in

@ -1127,6 +1127,27 @@ void TaskGroupingProxyModel::requestVirtualDesktop(const QModelIndex &index, qin
}
}
void TaskGroupingProxyModel::requestActivities(const QModelIndex &index, const QStringList &activities)
{
if (!d->abstractTasksSourceModel || !index.isValid() || index.model() != this) {
return;
}
if (index.parent().isValid() || !d->isGroup(index.row())) {
d->abstractTasksSourceModel->requestActivities(mapToSource(index), activities);
} else {
const int row = index.row();
for (int i = (rowCount(index) - 1); i >= 1; --i) {
const QModelIndex &sourceChild = mapToSource(index.child(i, 0));
d->abstractTasksSourceModel->requestActivities(sourceChild, activities);
}
d->abstractTasksSourceModel->requestActivities(mapToSource(TaskGroupingProxyModel::index(row, 0)),
activities);
}
}
void TaskGroupingProxyModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate)
{
if (!d->abstractTasksSourceModel || !index.isValid() || index.model() != this) {

@ -316,6 +316,19 @@ public:
**/
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.
**/
virtual 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

@ -1232,6 +1232,13 @@ void TasksModel::requestVirtualDesktop(const QModelIndex &index, qint32 desktop)
}
}
void TasksModel::requestActivities(const QModelIndex &index, const QStringList &activities)
{
if (index.isValid() && index.model() == this) {
d->groupingProxyModel->requestActivities(mapToSource(index), activities);
}
}
void TasksModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate)
{
if (index.isValid() && index.model() == this) {

@ -622,6 +622,19 @@ public:
**/
Q_INVOKABLE 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.
**/
Q_INVOKABLE virtual 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

@ -462,6 +462,12 @@ void WaylandTasksModel::requestVirtualDesktop(const QModelIndex &index, qint32 d
d->windows.at(index.row())->requestVirtualDesktop(desktop);
}
void WaylandTasksModel::requestActivities(const QModelIndex &index, const QStringList &activities)
{
Q_UNUSED(index)
Q_UNUSED(activities)
}
void WaylandTasksModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate)
{
/*

@ -162,6 +162,16 @@ public:
**/
void requestVirtualDesktop(const QModelIndex &index, qint32 desktop) override;
/**
* Request moving the window at the given index to the specified activities
*
* FIXME: This currently does nothing as activities is not implementated in kwin/kwayland
*
* @param index An index in this window tasks model.
* @param desktop A virtual desktop number.
**/
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. The geometry is retrieved

@ -1199,6 +1199,18 @@ void XWindowTasksModel::requestVirtualDesktop(const QModelIndex &index, qint32 d
}
}
void XWindowTasksModel::requestActivities(const QModelIndex &index, const QStringList &activities)
{
if (!index.isValid() || index.model() != this || index.row() < 0 || index.row() >= d->windows.count()) {
return;
}
const WId window = d->windows.at(index.row());
KWindowSystem::setOnActivities(window, activities);
}
void XWindowTasksModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate)
{
Q_UNUSED(delegate)

@ -176,6 +176,17 @@ public:
**/
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 window at the given index.

Loading…
Cancel
Save