Task Service

The Knut task service is represented by the Task object. The incoming communication from the server is handled by the TaskClient which calls a corresponding handler method for each message type.

class Task : public QObject

An implementation of the Knut task service.

This class implements the Knut task service and communicates any changes through the KnutClient client to the Knut server.

Public Types

enum Due

This enum defines when the due date is relative to the current date.

Values:

Overdue

the date is already past due.

Today

the due date is today.

Tomorrow

the due date is tomorrow.

ThisWeek

the due date is within the current week.

Later

the due date is at some date after the current week.

Public Functions

void handleStatusResponse(const QJsonObject &message)

Handles a task response.

Applies the new status parsed by the message to the Task.

See

TaskClient::TASK_RESPONSE

Signals

void remind()

This signal is emitted when a reminder message is received from the Knut server.

Property

property Task::assignee

This property holds the assignee to the task.

property Task::author

This property holds the task’s author.

property Task::body

This property holds the description text body of the task as CommonMark plus the GitHub extensions for tables and task lists.

property Task::done

This property describes whether the task is done or not.

property Task::due

This property holds the due date and time of the task.

property Task::dueType

This property holds the Task::Due type of the Task.

property Task::reminder

This property holds the date and time when a reminder should be send.

property Task::title

This property holds the title of the task.

property Task::uid

This property holds the unique id of the task.

class TaskClient : public QObject

Handles all Task services.

Public Types

enum MessageType

This enum type describes the message types used to communicate with the Knut server via the KnutClient::writeRequest() as specified by the Knut task API.

Values:

REMINDER = 1

A reminder send by the server.

TASK_REQUEST = 2

Requests a task.

TASK_RESPONSE = 3

The task send by the server.

ALL_TASKS_REQUEST = 4

Requests all tasks.

ALL_TASKS_RESPONSE = 5

The state of all Task services.

DELETE_TASK_REQUEST = 6

Requests to delete a Task.

Public Functions

void addTask(const QString &assignee, const QString &body, const QDateTime &due, const QDateTime &reminder, const QString &title)

Add a new task.

Sends a request to the Knut server to create a new task with an assignee, description body, a due date, reminder and a title.

Note: This function can be invoked via the meta-object system and from QML.

void deleteTask(const QVariant &task)

Sends a request to delete a task.

Note: This function can be invoked via the meta-object system and from QML.

void connectToClient(KnutClient *knutClient)

Connects to the KnutClient knutClient.

Connects the onKnutConnected() slot to the KnutClient::knutConnected() signal and the onReadyRead() slot to the signal KnutClient::receivedMessage() signal.

Public Slots

void onReadyRead(const QJsonObject &message, const quint8 &serviceId, const quint16 &messageType)

Slot called when a message is available.

If a message is received by the KnutClient, this slot is called. If the serviceId is 0x03, a corresponding response handle method is called for the messageType.

See

TaskClient::MessageType

Property

property TaskClient::taskModel

This property holds the model of all tasks with the roles due and task where task references to a Task service.