Respect the task hubs tasksCleared signal

Fixes: QDS-13528
Change-Id: I86b620e31f5a3e718ea9e1d56d50dc2d20a96708
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Knud Dollereder
2024-09-03 11:54:57 +02:00
parent 40f462cf07
commit 8dfe44db93
2 changed files with 13 additions and 1 deletions

View File

@@ -107,6 +107,7 @@ void MessageModel::setupTaskHub()
connect(hub, &ProjectExplorer::TaskHub::categoryAdded, this, &MessageModel::addCategory);
connect(hub, &ProjectExplorer::TaskHub::taskAdded, this, &MessageModel::addTask);
connect(hub, &ProjectExplorer::TaskHub::taskRemoved, this, &MessageModel::removeTask);
connect(hub, &ProjectExplorer::TaskHub::tasksCleared, this, &MessageModel::clearTasks);
}
void MessageModel::addCategory(const ProjectExplorer::TaskCategory &category)
@@ -126,7 +127,7 @@ void MessageModel::addTask(const ProjectExplorer::Task &task)
void MessageModel::removeTask(const ProjectExplorer::Task &task)
{
for (int i = 0; std::cmp_less(i, m_tasks.size()); i++) {
if (m_tasks.at(i) == task) {
if (m_tasks[static_cast<size_t>(i)] == task) {
beginRemoveRows(QModelIndex(), i, i);
m_tasks.erase(m_tasks.begin() + i);
endRemoveRows();
@@ -135,3 +136,13 @@ void MessageModel::removeTask(const ProjectExplorer::Task &task)
}
}
}
void MessageModel::clearTasks(const Utils::Id &categoryId)
{
beginResetModel();
std::erase_if(m_tasks, [categoryId](const ProjectExplorer::Task& task) {
return task.category == categoryId;
});
endResetModel();
emit modelChanged();
}

View File

@@ -44,6 +44,7 @@ private:
void addCategory(const ProjectExplorer::TaskCategory &category);
void addTask(const ProjectExplorer::Task &task);
void removeTask(const ProjectExplorer::Task &task);
void clearTasks(const Utils::Id &categoryId);
std::vector<ProjectExplorer::Task> m_tasks = {};
std::unordered_map<quintptr, ProjectExplorer::TaskCategory> m_categories = {};