From 2a0dfe22b7c95ed9293fd024a8cd1adf334ddc94 Mon Sep 17 00:00:00 2001 From: Yari Polla Date: Sat, 12 Mar 2022 21:47:46 +0100 Subject: [PATCH] Revert "libtaskmanager: Add a new sort mode and relative handler in TasksModel" This reverts commit aceff05c3128e092bda1f0e7586520b32d352a19. --- libtaskmanager/taskfilterproxymodel.cpp | 13 ------ libtaskmanager/taskfilterproxymodel.h | 22 ---------- libtaskmanager/tasksmodel.cpp | 55 ------------------------- libtaskmanager/tasksmodel.h | 14 ------- 4 files changed, 104 deletions(-) diff --git a/libtaskmanager/taskfilterproxymodel.cpp b/libtaskmanager/taskfilterproxymodel.cpp index 498747be8..a05ed6be0 100644 --- a/libtaskmanager/taskfilterproxymodel.cpp +++ b/libtaskmanager/taskfilterproxymodel.cpp @@ -21,7 +21,6 @@ public: QVariant virtualDesktop; QRect screenGeometry; QString activity; - bool switchingFromActiveTask = false; bool filterByVirtualDesktop = false; bool filterByScreen = false; @@ -110,18 +109,6 @@ void TaskFilterProxyModel::setActivity(const QString &activity) } } -bool TaskFilterProxyModel::switchingFromActiveTask() const -{ - return d->switchingFromActiveTask; -} - -void TaskFilterProxyModel::setSwitchingFromActiveTask(const bool switchingFromActiveTask) -{ - d->switchingFromActiveTask = switchingFromActiveTask; - - Q_EMIT switchingFromActiveTaskChanged(); -} - bool TaskFilterProxyModel::filterByVirtualDesktop() const { return d->filterByVirtualDesktop; diff --git a/libtaskmanager/taskfilterproxymodel.h b/libtaskmanager/taskfilterproxymodel.h index 8887bfe10..4a4af2af2 100644 --- a/libtaskmanager/taskfilterproxymodel.h +++ b/libtaskmanager/taskfilterproxymodel.h @@ -32,7 +32,6 @@ class TASKMANAGER_EXPORT TaskFilterProxyModel : public QSortFilterProxyModel, pu Q_PROPERTY(QVariant virtualDesktop READ virtualDesktop WRITE setVirtualDesktop NOTIFY virtualDesktopChanged) Q_PROPERTY(QRect screenGeometry READ screenGeometry WRITE setScreenGeometry NOTIFY screenGeometryChanged) Q_PROPERTY(QString activity READ activity WRITE setActivity NOTIFY activityChanged) - Q_PROPERTY(bool switchingFromActiveTask READ switchingFromActiveTask WRITE setSwitchingFromActiveTask NOTIFY switchingFromActiveTaskChanged) Q_PROPERTY(bool filterByVirtualDesktop READ filterByVirtualDesktop WRITE setFilterByVirtualDesktop NOTIFY filterByVirtualDesktopChanged) Q_PROPERTY(bool filterByScreen READ filterByScreen WRITE setFilterByScreen NOTIFY filterByScreenChanged) @@ -109,26 +108,6 @@ public: **/ void setActivity(const QString &activity); - /** - * Whether the activation of the task was triggered while - * on an active task. - * Needed to activate delayed reordering in SortLastActivated sort mode. - * - * @see setSwitchingFromActiveTask - * @returns @c true if the activation of a task was triggered while on an active task - **/ - bool switchingFromActiveTask() const; - - /** - * Set whether the activation of the task is triggered while on - * an active task. - * - * @see switchingFromActiveTask - * @param switchingFromActiveTask whether the activation - * of the task is triggered while on an active task. - **/ - void setSwitchingFromActiveTask(const bool switchingFromActiveTask); - /** * Whether tasks should be filtered by virtual desktop. Defaults to * @c false. @@ -323,7 +302,6 @@ Q_SIGNALS: void virtualDesktopChanged() const; void screenGeometryChanged() const; void activityChanged() const; - void switchingFromActiveTaskChanged() const; void filterByVirtualDesktopChanged() const; void filterByScreenChanged() const; void filterByActivityChanged() const; diff --git a/libtaskmanager/tasksmodel.cpp b/libtaskmanager/tasksmodel.cpp index 020d23def..2dde23ec3 100644 --- a/libtaskmanager/tasksmodel.cpp +++ b/libtaskmanager/tasksmodel.cpp @@ -284,7 +284,6 @@ void TasksModel::Private::initModels() QObject::connect(filterProxyModel, &TaskFilterProxyModel::virtualDesktopChanged, q, &TasksModel::virtualDesktopChanged); QObject::connect(filterProxyModel, &TaskFilterProxyModel::screenGeometryChanged, q, &TasksModel::screenGeometryChanged); QObject::connect(filterProxyModel, &TaskFilterProxyModel::activityChanged, q, &TasksModel::activityChanged); - QObject::connect(filterProxyModel, &TaskFilterProxyModel::switchingFromActiveTaskChanged, q, &TasksModel::switchingFromActiveTaskChanged); QObject::connect(filterProxyModel, &TaskFilterProxyModel::filterByVirtualDesktopChanged, q, &TasksModel::filterByVirtualDesktopChanged); QObject::connect(filterProxyModel, &TaskFilterProxyModel::filterByScreenChanged, q, &TasksModel::filterByScreenChanged); QObject::connect(filterProxyModel, &TaskFilterProxyModel::filterByActivityChanged, q, &TasksModel::filterByActivityChanged); @@ -919,25 +918,6 @@ bool TasksModel::Private::lessThan(const QModelIndex &left, const QModelIndex &r return (leftScore > rightScore); } } - // fall through - case SortLastActivated: { - QTime leftSortTime = left.data(AbstractTasksModel::LastActivated).toTime(); - - if (!leftSortTime.isValid()) { - leftSortTime = left.data(Qt::DisplayRole).toTime(); - } - - QTime rightSortTime = right.data(AbstractTasksModel::LastActivated).toTime(); - - if (!rightSortTime.isValid()) { - rightSortTime = right.data(Qt::DisplayRole).toTime(); - } - - if (leftSortTime == rightSortTime) - return (left.row() < right.row()); - - return (leftSortTime < rightSortTime); - } // Fall through to source order if sorting is disabled or manual, or alphabetical by app name otherwise. // This marker comment makes gcc/clang happy: // fall through @@ -990,8 +970,6 @@ TasksModel::TasksModel(QObject *parent) : QSortFilterProxyModel(parent) , d(new Private(this)) { - reorderTimer = new QTimer(); - d->initModels(); // Start sorting. @@ -1235,34 +1213,6 @@ void TasksModel::setSortMode(SortMode mode) d->activityTaskCounts.clear(); setSortRole(Qt::DisplayRole); } - if (mode == SortLastActivated) { - setDynamicSortFilter(false); - - QObject::connect(this, &TasksModel::activeTaskChanged, reorderTimer, [this] { - if (!d->filterProxyModel->switchingFromActiveTask()) { - reorderTimer->stop(); - setDynamicSortFilter(true); - setDynamicSortFilter(false); - } else { - reorderTimer->start(5000); - } - }); - - QObject::connect(reorderTimer, &QTimer::timeout, reorderTimer, [this]() { - reorderTimer->stop(); - - if (d->filterProxyModel->switchingFromActiveTask()) { - d->filterProxyModel->setSwitchingFromActiveTask(false); - setDynamicSortFilter(true); - setDynamicSortFilter(false); - } - }); - - QObject::connect(this, &TasksModel::switchingFromActiveTaskChanged, this, [this]() { - if (d->filterProxyModel->switchingFromActiveTask()) - reorderTimer->start(5000); - }); - } d->sortMode = mode; @@ -1603,11 +1553,6 @@ void TasksModel::requestActivities(const QModelIndex &index, const QStringList & } } -void TasksModel::requestLastActivatedReorderDelay(const bool enableReorderDelay) -{ - d->filterProxyModel->setSwitchingFromActiveTask(enableReorderDelay); -} - void TasksModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate) { if (index.isValid() && index.model() == this) { diff --git a/libtaskmanager/tasksmodel.h b/libtaskmanager/tasksmodel.h index f7ba3cbca..6f4e8f5cc 100644 --- a/libtaskmanager/tasksmodel.h +++ b/libtaskmanager/tasksmodel.h @@ -12,7 +12,6 @@ #include "abstracttasksmodeliface.h" #include "taskmanager_export.h" -#include namespace TaskManager { @@ -82,7 +81,6 @@ public: SortAlpha, /**< Tasks are sorted alphabetically, by AbstractTasksModel::AppName and Qt::DisplayRole. */ SortVirtualDesktop, /**< Tasks are sorted by the virtual desktop they are on. */ SortActivity, /**< Tasks are sorted by the number of tasks on the activities they're on. */ - SortLastActivated, /**< Tasks are sorted by the last time they were active. */ }; Q_ENUM(SortMode) @@ -101,8 +99,6 @@ public: QVariant data(const QModelIndex &proxyIndex, int role) const override; - QTimer *reorderTimer; - /** * The number of launcher tasks in the tast list. * @@ -774,15 +770,6 @@ public: **/ Q_INVOKABLE void requestActivities(const QModelIndex &index, const QStringList &activities) override; - /** - * Request whether to enable delay in the reorder phase of tasks model when the sort mode is SortLastActivated. - * - * This base implementation does nothing. - * - * @param enableReorderDelay @c true to enable the delay - **/ - Q_INVOKABLE void requestLastActivatedReorderDelay(const bool enableReorderDelay); - /** * Request informing the window manager of new geometry for a visual * delegate for the task at the given index. The geometry should be in @@ -878,7 +865,6 @@ Q_SIGNALS: void virtualDesktopChanged() const; void screenGeometryChanged() const; void activityChanged() const; - void switchingFromActiveTaskChanged() const; void filterByVirtualDesktopChanged() const; void filterByScreenChanged() const; void filterByActivityChanged() const;