Add support for moving group members within a group.

Summary: BUG:383405

Reviewers: #plasma, davidedmundson, argonel

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D7267
wilder-5.14
Eike Hein 9 years ago
parent 2be88cc4b3
commit 592dc9e0bc
  1. 9
      libtaskmanager/tasksmodel.cpp
  2. 7
      libtaskmanager/tasksmodel.h

@ -1430,9 +1430,9 @@ void TasksModel::requestToggleGrouping(const QModelIndex &index)
} }
} }
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; return false;
} }
@ -1523,7 +1523,7 @@ bool TasksModel::move(int row, int newPos)
endMoveRows(); endMoveRows();
} else { } 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. // Translate to sort map indices.
const QModelIndex &groupingRowIndex = mapToSource(index(row, 0)); const QModelIndex &groupingRowIndex = mapToSource(index(row, 0));
@ -1535,7 +1535,8 @@ bool TasksModel::move(int row, int newPos)
d->sortedPreFilterRows.move(row, newPos); d->sortedPreFilterRows.move(row, newPos);
// If we moved a group parent, consolidate sort map for children. // 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); d->consolidateManualSortMapForGroup(groupingRowIndex);
} }

@ -769,8 +769,8 @@ public:
Q_INVOKABLE void requestToggleGrouping(const QModelIndex &index); Q_INVOKABLE void requestToggleGrouping(const QModelIndex &index);
/** /**
* Moves a (top-level) task to a new position in the list. The insert * Moves a task to a new position in the list. The insert position is
* position is bounded to the list start and end. * is bounded to the list start and end.
* *
* syncLaunchers() should be called after a set of move operations to * syncLaunchers() should be called after a set of move operations to
* update the launcherList property to reflect the new order. * update the launcherList property to reflect the new order.
@ -784,7 +784,8 @@ public:
* @param index An index in this tasks model. * @param index An index in this tasks model.
* @param newPos The new list position to move the task to. * @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 * Updates the launcher list to reflect the new order after calls to

Loading…
Cancel
Save