Verified Commit 7364149a authored by Fushan Wen's avatar Fushan Wen
Browse files

libtaskmanager: Port to QConcatenateTablesProxyModel for ConcatenateTasksProxyModel

Add source model before connecting to model signals to avoid crashes.
parent 7ea65e0f
......@@ -9,7 +9,7 @@
namespace TaskManager
{
ConcatenateTasksProxyModel::ConcatenateTasksProxyModel(QObject *parent)
: KConcatenateRowsProxyModel(parent)
: QConcatenateTablesProxyModel(parent)
{
}
......
......@@ -8,7 +8,7 @@
#include "abstracttasksproxymodeliface.h"
#include <KConcatenateRowsProxyModel>
#include <QConcatenateTablesProxyModel>
#include "taskmanager_export.h"
......@@ -17,13 +17,13 @@ namespace TaskManager
/**
* @short A proxy tasks model for concatenating multiple source tasks models.
*
* This proxy model is a subclass of KConcatenateRowsProxyModel implementing
* This proxy model is a subclass of \QConcatenateTablesProxyModel implementing
* AbstractTasksModelIface, forwarding calls to the correct source model.
*
* @author Eike Hein <hein@kde.org>
**/
class TASKMANAGER_EXPORT ConcatenateTasksProxyModel : public KConcatenateRowsProxyModel, public AbstractTasksProxyModelIface
class TASKMANAGER_EXPORT ConcatenateTasksProxyModel : public QConcatenateTablesProxyModel, public AbstractTasksProxyModelIface
{
Q_OBJECT
......
......@@ -152,10 +152,14 @@ void TasksModel::Private::initModels()
// -> flattenGroupsProxyModel (optionally, if groupInline == true) flattens groups out.
// -> TasksModel collapses (top-level) items into task lifecycle abstraction; sorts.
concatProxyModel = new ConcatenateTasksProxyModel(q);
if (!windowTasksModel) {
windowTasksModel = new WindowTasksModel();
}
concatProxyModel->addSourceModel(windowTasksModel);
QObject::connect(windowTasksModel, &QAbstractItemModel::rowsInserted, q, [this]() {
if (sortMode == SortActivity) {
updateActivityTaskCounts();
......@@ -204,9 +208,6 @@ void TasksModel::Private::initModels()
startupTasksModel = new StartupTasksModel();
}
concatProxyModel = new ConcatenateTasksProxyModel(q);
concatProxyModel->addSourceModel(windowTasksModel);
concatProxyModel->addSourceModel(startupTasksModel);
// If we're in manual sort mode, we need to seed the sort map on pending row
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment