[plasma/plasma-workspace] libtaskmanager: Avoid the updateCounts function

Nate Graham <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 7b42461e84553e3e9ceaf8ae656f181068e76332 by Nate Graham, on behalf of Marco Martin.
Committed on 05/08/2026 at 13:45.
Pushed by mart into branch 'master'.

Avoid the updateCounts function

connect countChanged to updateActiveTask, as new tasks that appear might
be immediately active

M  +7    -0    libtaskmanager/tasksmodel.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/7b42461e84553e3e9ceaf8ae656f181068e76332

diff --git a/libtaskmanager/tasksmodel.cpp b/libtaskmanager/tasksmodel.cpp
index 8ec42c2b15..9c7f37597e 100644
--- a/libtaskmanager/tasksmodel.cpp
+++ b/libtaskmanager/tasksmodel.cpp
@@ -678,6 +678,10 @@ void TasksModel::Private::updateGroupInline()
         QObject::connect(q, &QAbstractItemModel::rowsRemoved, q, &TasksModel::updateLauncherCount, Qt::UniqueConnection);
         QObject::connect(q, &QAbstractItemModel::modelReset, q, &TasksModel::updateLauncherCount, Qt::UniqueConnection);
 
+        QObject::connect(q, &QAbstractItemModel::rowsInserted, q, &TasksModel::countChanged, Qt::UniqueConnection);
+        QObject::connect(q, &QAbstractItemModel::rowsRemoved, q, &TasksModel::countChanged, Qt::UniqueConnection);
+        QObject::connect(q, &QAbstractItemModel::modelReset, q, &TasksModel::countChanged, Qt::UniqueConnection);
+
         activeTaskWinIds = q->activeTask().data(AbstractTasksModel::WinIdList).toList();
     }
 }
@@ -1024,6 +1028,9 @@ TasksModel::TasksModel(QObject *parent)
     connect(this, &TasksModel::countChanged, this, [this]() {
         d->updateActiveTask();
     });
+    connect(this, &TasksModel::layoutChanged, this, [this]() {
+        d->updateActiveTask();
+    });
 }
 
 TasksModel::~TasksModel() = default;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.