diff --git a/libtaskmanager/tasksmodel.h b/libtaskmanager/tasksmodel.h --- a/libtaskmanager/tasksmodel.h +++ b/libtaskmanager/tasksmodel.h @@ -811,6 +811,17 @@ */ Q_INVOKABLE QModelIndex makeModelIndex(int row, int childRow = -1) const; + /** + * Given a row in the model, returns a QPersistentModelIndex for it. To get an index + * for a child in a task group, an optional child row may be passed as well. + * + * @param row A row index in the model. + * @param childRow A row index for a child of the task group at the given row. + * @returns a model index for the task at the given row, or for one of its + * child tasks. + */ + Q_INVOKABLE QPersistentModelIndex makePersistentModelIndex(int row, int childRow = -1) const; + void classBegin() override; void componentComplete() override; diff --git a/libtaskmanager/tasksmodel.cpp b/libtaskmanager/tasksmodel.cpp --- a/libtaskmanager/tasksmodel.cpp +++ b/libtaskmanager/tasksmodel.cpp @@ -1712,6 +1712,11 @@ return QModelIndex(); } +QPersistentModelIndex TasksModel::makePersistentModelIndex(int row, int childCount) const +{ + return QPersistentModelIndex(makeModelIndex(row, childCount)); +} + void TasksModel::classBegin() { d->usedByQml = true;