Commit fb9a9cee authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Added a method to remove individual tasks from the task window.

parent 61b3a7be
......@@ -116,6 +116,7 @@ public:
QList<Task> 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())
......
......@@ -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;
......
Markdown is supported
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