From 3f332a527c3a97d2dec5a70a5b66df717645bbdf Mon Sep 17 00:00:00 2001 From: Eike Hein Date: Sun, 16 Sep 2018 17:56:07 +0900 Subject: [PATCH] Move correct indices in the manual sort map when getting a move() call for group children Summary: Due to not passing `parent` to QAIM::index(), we were moving top-level indices in the map instead. This meant the sort map would become out of sync with the row move, and to the user it would look like both the group children and unrelated top-level entries moved. Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D15550 --- libtaskmanager/tasksmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libtaskmanager/tasksmodel.cpp b/libtaskmanager/tasksmodel.cpp index 40bcd2ea2..ffb43d523 100644 --- a/libtaskmanager/tasksmodel.cpp +++ b/libtaskmanager/tasksmodel.cpp @@ -1631,10 +1631,10 @@ bool TasksModel::move(int row, int newPos, const QModelIndex &parent) beginMoveRows(parent, row, row, parent, (newPos > row) ? newPos + 1 : newPos); // Translate to sort map indices. - const QModelIndex &groupingRowIndex = mapToSource(index(row, 0)); + const QModelIndex &groupingRowIndex = mapToSource(index(row, 0, parent)); const QModelIndex &preFilterRowIndex = d->preFilterIndex(groupingRowIndex); row = d->sortedPreFilterRows.indexOf(preFilterRowIndex.row()); - newPos = d->sortedPreFilterRows.indexOf(d->preFilterIndex(mapToSource(index(newPos, 0))).row()); + newPos = d->sortedPreFilterRows.indexOf(d->preFilterIndex(mapToSource(index(newPos, 0, parent))).row()); // Update sort mapping. d->sortedPreFilterRows.move(row, newPos);