From 73657e9185e7d4ba56a976b7030aca6cdbd7bd19 Mon Sep 17 00:00:00 2001 From: Fushan Wen Date: Mon, 12 Sep 2022 11:44:17 +0800 Subject: [PATCH] libtaskmanager: fix task reordering in a group Give model index a parent so a task in a group will not be mistaken for a launcher item. --- libtaskmanager/tasksmodel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libtaskmanager/tasksmodel.cpp b/libtaskmanager/tasksmodel.cpp index caeb68203..3c5aff484 100644 --- a/libtaskmanager/tasksmodel.cpp +++ b/libtaskmanager/tasksmodel.cpp @@ -1611,7 +1611,7 @@ bool TasksModel::move(int row, int newPos, const QModelIndex &parent) return false; } - const QModelIndex &idx = index(row, 0); + const QModelIndex &idx = index(row, 0, parent); bool isLauncherMove = false; // Figure out if we're moving a launcher so we can run barrier checks. @@ -1631,7 +1631,7 @@ bool TasksModel::move(int row, int newPos, const QModelIndex &parent) return false; } - if (d->separateLaunchers) { + if (d->separateLaunchers && !parent.isValid() /* Exclude tasks in a group */) { const int firstTask = (d->launcherTasksModel ? (d->launchInPlace ? d->launcherTasksModel->rowCount() : launcherCount()) : 0); // Don't allow launchers to be moved past the last launcher. @@ -1778,8 +1778,8 @@ bool TasksModel::move(int row, int newPos, const QModelIndex &parent) * - after moving: [pinned 1 (launcher item)] [unpinned] [pinned 1 (window)] * So also check the indexes before and after the unpinned task. */ - const QModelIndex beforeIdx = d->concatProxyModel->index(d->sortedPreFilterRows.at(newPos - 1), 0); - const QModelIndex afterIdx = d->concatProxyModel->index(d->sortedPreFilterRows.at(newPos + 1), 0); + const QModelIndex beforeIdx = d->concatProxyModel->index(d->sortedPreFilterRows.at(newPos - 1), 0, parent); + const QModelIndex afterIdx = d->concatProxyModel->index(d->sortedPreFilterRows.at(newPos + 1), 0, parent); if (appsMatch(beforeIdx, afterIdx)) { // after adjusting: [unpinned] [pinned 1 (launcher item)] [pinned 1]