/
mob1le
/
simple-task-manager
Обзор
Документация
Войти
/
mob1le
/
simple-task-manager
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/task.cpp
99 строк
2 KB
bessalovs
fix id (now unique) + format all documents
13 май 2026, 13:41
13 май 2026, 13:41
621c9d5
Код
Авторство
О чём код?
#include "task.h" Task::Task(QString title, QString description) { this->id = QUuid::createUuid(); this->title = title; this->description = description; this->isCompleted = false; this->createdAt = QDate::currentDate(); } Task::Task(QString id, QString title, QString description, bool isCompleted, QDate createdAt) { this->id = QUuid(id); this->title = title; this->description = description; this->isCompleted = isCompleted; this->createdAt = createdAt; } Task Task::fromModel(const QAbstractTableModel *model, const QModelIndex &index) { return Task( model->data(model->index(index.row(),MyColumns::Id)).toString(), model->data(model->index(index.row(),MyColumns::Title)).toString(), model->data(model->index(index.row(),MyColumns::Desription)).toString(), model->data(model->index(index.row(),MyColumns::IsCompleted)).toBool(), model->data(model->index(index.row(),MyColumns::CreatedAt)).toDate() ); } Task::~Task() { } QUuid Task::getId() const { return this->id; } QString Task::getTitle() const { return this->title; } QString Task::getDesription() const { return this->description; } bool Task::getIsCompleted() const { return this->isCompleted; } QDate Task::getCreatedDate() const { return this->createdAt; } void Task::editTitle(QString edited_title) { this->title = edited_title; } void Task::editDescription(QString edited_description) { this->description = edited_description; } void Task::switchComplete() { this->isCompleted = (this->getIsCompleted() ? false : true); } QJsonObject Task::fromTaskToJson() const { QJsonObject task; task["id"] = this->id.toString(); task["title"] = this->title; task["description"] = this->description; task["isCompleted"] = this->isCompleted; task["createdAt"] = this->createdAt.toString(Qt::ISODate); return task; } Task Task::fromJsonToTask(const QJsonObject json) { Task task; task.id = QUuid(json["id"].toString()); task.title = json["title"].toString(); task.description = json["description"].toString(); task.isCompleted = json["isCompleted"].toBool(); QString date = json["createdAt"].toString(); task.createdAt = QDate::fromString(date, Qt::ISODate); return task; }