TaskListModel.h header

#include <ew/app/TaskListModel.h>

Namespace ew::app

TaskListModel class

class ew::app::TaskListModel

A checkable list model over a project's tasks, for a to-do checklist view. Rows are ordered incomplete-first, then by descending priority, then title. Each row shows the task's title (with a due-date hint) and a checkbox; toggling the checkbox pushes an undoable SetTaskDoneCommand onto the workspace command stack. The row order is fixed until refresh(), so a task does not jump when it is checked.

Members

ew::app::TaskListModel::TaskListModel(QObject *parent=nullptr)

Constructs a task list model with the optional parent.

void ew::app::TaskListModel::setWorkspace(Workspace *workspace)

Points the model at workspace (not owned; may be null): it reads the project for rows and pushes commands on the workspace command stack when a task is toggled.

void ew::app::TaskListModel::refresh()

Re-reads the project, re-sorts the rows, and resets the model.

ew::core::ContentId ew::app::TaskListModel::taskIdAt(const QModelIndex &index) const

The id of the task at index, or a null id if the index is invalid.

int ew::app::TaskListModel::rowCount(const QModelIndex &parent=QModelIndex()) const override

Returns the number of task rows (QAbstractListModel).

QVariant ew::app::TaskListModel::data(const QModelIndex &index, int role=Qt::DisplayRole) const override

Returns the task's data for index and role (QAbstractListModel).

Qt::ItemFlags ew::app::TaskListModel::flags(const QModelIndex &index) const override

Returns the item flags for index, including its checkable checkbox (QAbstractListModel).

bool ew::app::TaskListModel::setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override

Toggles the task's done state for index via an undoable command (QAbstractListModel).