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
wilder-5.14
Eike Hein 8 years ago
parent a8b71fe5c0
commit 3f332a527c
  1. 4
      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);

Loading…
Cancel
Save