forked from qt-creator/qt-creator
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:
@@ -107,6 +107,7 @@ void MessageModel::setupTaskHub()
|
|||||||
connect(hub, &ProjectExplorer::TaskHub::categoryAdded, this, &MessageModel::addCategory);
|
connect(hub, &ProjectExplorer::TaskHub::categoryAdded, this, &MessageModel::addCategory);
|
||||||
connect(hub, &ProjectExplorer::TaskHub::taskAdded, this, &MessageModel::addTask);
|
connect(hub, &ProjectExplorer::TaskHub::taskAdded, this, &MessageModel::addTask);
|
||||||
connect(hub, &ProjectExplorer::TaskHub::taskRemoved, this, &MessageModel::removeTask);
|
connect(hub, &ProjectExplorer::TaskHub::taskRemoved, this, &MessageModel::removeTask);
|
||||||
|
connect(hub, &ProjectExplorer::TaskHub::tasksCleared, this, &MessageModel::clearTasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageModel::addCategory(const ProjectExplorer::TaskCategory &category)
|
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)
|
void MessageModel::removeTask(const ProjectExplorer::Task &task)
|
||||||
{
|
{
|
||||||
for (int i = 0; std::cmp_less(i, m_tasks.size()); i++) {
|
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);
|
beginRemoveRows(QModelIndex(), i, i);
|
||||||
m_tasks.erase(m_tasks.begin() + i);
|
m_tasks.erase(m_tasks.begin() + i);
|
||||||
endRemoveRows();
|
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();
|
||||||
|
}
|
||||||
|
@@ -44,6 +44,7 @@ private:
|
|||||||
void addCategory(const ProjectExplorer::TaskCategory &category);
|
void addCategory(const ProjectExplorer::TaskCategory &category);
|
||||||
void addTask(const ProjectExplorer::Task &task);
|
void addTask(const ProjectExplorer::Task &task);
|
||||||
void removeTask(const ProjectExplorer::Task &task);
|
void removeTask(const ProjectExplorer::Task &task);
|
||||||
|
void clearTasks(const Utils::Id &categoryId);
|
||||||
|
|
||||||
std::vector<ProjectExplorer::Task> m_tasks = {};
|
std::vector<ProjectExplorer::Task> m_tasks = {};
|
||||||
std::unordered_map<quintptr, ProjectExplorer::TaskCategory> m_categories = {};
|
std::unordered_map<quintptr, ProjectExplorer::TaskCategory> m_categories = {};
|
||||||
|
Reference in New Issue
Block a user