diff --git a/libtaskmanager/tasksmodel.h b/libtaskmanager/tasksmodel.h --- a/libtaskmanager/tasksmodel.h +++ b/libtaskmanager/tasksmodel.h @@ -769,8 +769,8 @@ Q_INVOKABLE void requestToggleGrouping(const QModelIndex &index); /** - * Moves a (top-level) task to a new position in the list. The insert - * position is bounded to the list start and end. + * Moves a task to a new position in the list. The insert position is + * is bounded to the list start and end. * * syncLaunchers() should be called after a set of move operations to * update the launcherList property to reflect the new order. @@ -784,7 +784,8 @@ * @param index An index in this tasks model. * @param newPos The new list position to move the task to. */ - Q_INVOKABLE bool move(int row, int newPos); + Q_INVOKABLE bool move(int row, int newPos, + const QModelIndex &parent = QModelIndex()); /** * Updates the launcher list to reflect the new order after calls to diff --git a/libtaskmanager/tasksmodel.cpp b/libtaskmanager/tasksmodel.cpp --- a/libtaskmanager/tasksmodel.cpp +++ b/libtaskmanager/tasksmodel.cpp @@ -1430,9 +1430,9 @@ } } -bool TasksModel::move(int row, int newPos) +bool TasksModel::move(int row, int newPos, const QModelIndex &parent) { - if (d->sortMode != SortManual || row == newPos || newPos < 0 || newPos >= rowCount()) { + if (d->sortMode != SortManual || row == newPos || newPos < 0 || newPos >= rowCount(parent)) { return false; } @@ -1523,7 +1523,7 @@ endMoveRows(); } else { - beginMoveRows(QModelIndex(), row, row, QModelIndex(), (newPos > row) ? newPos + 1 : newPos); + beginMoveRows(parent, row, row, parent, (newPos > row) ? newPos + 1 : newPos); // Translate to sort map indices. const QModelIndex &groupingRowIndex = mapToSource(index(row, 0)); @@ -1535,7 +1535,8 @@ d->sortedPreFilterRows.move(row, newPos); // If we moved a group parent, consolidate sort map for children. - if (groupMode() != GroupDisabled && d->groupingProxyModel->rowCount(groupingRowIndex)) { + if (!parent.isValid() && groupMode() != GroupDisabled + && d->groupingProxyModel->rowCount(groupingRowIndex)) { d->consolidateManualSortMapForGroup(groupingRowIndex); }