From fb9a9ceede0d872742c44462292626475df9f145 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 16 Apr 2010 12:41:26 +0200 Subject: [PATCH] Added a method to remove individual tasks from the task window. --- src/plugins/projectexplorer/taskwindow.cpp | 29 +++++++++++++++------- src/plugins/projectexplorer/taskwindow.h | 1 + 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index a26b27376f2..ab407b0683f 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -116,6 +116,7 @@ public: QList tasks(const QString &categoryId = QString()) const; void addTask(const Task &task); + void removeTask(const Task &task); void clearTasks(const QString &categoryId = QString()); int sizeOfFile(); @@ -253,15 +254,16 @@ void TaskModel::addTask(const Task &task) m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.width(filename)); } -// -//void TaskModel::removeTask(const ITaskWindow::Task &task) -//{ -// Q_ASSERT(m_tasks.contains(task)); -// int index = m_tasks.indexOf(task); -// beginRemoveRows(QModelIndex(), index, index); -// m_tasks.removeAt(index); -// endRemoveRows(); -//} + +void TaskModel::removeTask(const Task &task) +{ + if (m_tasks.contains(task)) { + int index = m_tasks.indexOf(task); + beginRemoveRows(QModelIndex(), index, index); + m_tasks.removeAt(index); + endRemoveRows(); + } +} void TaskModel::clearTasks(const QString &categoryId) { @@ -557,6 +559,15 @@ void TaskWindow::addTask(const Task &task) navigateStateChanged(); } +void TaskWindow::removeTask(const Task &task) +{ + m_model->removeTask(task); + + updateActions(); + emit tasksChanged(); + navigateStateChanged(); +} + void TaskWindow::showTaskInFile(const QModelIndex &index) { if (!index.isValid()) diff --git a/src/plugins/projectexplorer/taskwindow.h b/src/plugins/projectexplorer/taskwindow.h index 2eca65e3cf7..be57524fd76 100644 --- a/src/plugins/projectexplorer/taskwindow.h +++ b/src/plugins/projectexplorer/taskwindow.h @@ -99,6 +99,7 @@ public: void addCategory(const QString &categoryId, const QString &displayName); void addTask(const Task &task); + void removeTask(const Task &task); void clearTasks(const QString &categoryId = QString()); int taskCount(const QString &categoryId = QString()) const;