From 317b515e22f491788376d735822f162511c90b70 Mon Sep 17 00:00:00 2001 From: Vyn Date: Thu, 11 Apr 2024 14:08:09 +0200 Subject: [PATCH] Date time is now visible on each task --- src/TaskItem.cpp | 7 +++++++ src/TaskItem.h | 2 ++ src/core/TodoMd.cpp | 18 +++++++++--------- src/qml/TaskItem.qml | 10 +++++++++- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/TaskItem.cpp b/src/TaskItem.cpp index 3f0439a..156e591 100644 --- a/src/TaskItem.cpp +++ b/src/TaskItem.cpp @@ -23,6 +23,13 @@ QString QMLTaskItem::getDate() { return QString::fromStdString(taskItem->getDate()); } +QString QMLTaskItem::getTime() { + if (taskItem->getStartTime() != "" && taskItem->getEndTime() != "") { + return QString::fromStdString(taskItem->getStartTime() + "-" + taskItem->getEndTime()); + } + return ""; +} + QList QMLTaskItem::getTags() { return tags; } diff --git a/src/TaskItem.h b/src/TaskItem.h index 0687d84..34bc0b2 100644 --- a/src/TaskItem.h +++ b/src/TaskItem.h @@ -23,6 +23,7 @@ struct QMLTaskItem { Q_PROPERTY(QString date READ getDate) Q_PROPERTY(QList tags READ getTags) Q_PROPERTY(bool shouldShowDate READ getShouldShowDate) + Q_PROPERTY(QString time READ getTime) QML_VALUE_TYPE(taskItem) public: @@ -31,6 +32,7 @@ public: QString getRawFormat(); QString getState(); QString getDate(); + QString getTime(); QList getTags(); bool getShouldShowDate(); diff --git a/src/core/TodoMd.cpp b/src/core/TodoMd.cpp index ee80b25..bc777fd 100644 --- a/src/core/TodoMd.cpp +++ b/src/core/TodoMd.cpp @@ -87,15 +87,15 @@ namespace mirai { std::regex regex("- \\[(\\s|X)\\] (([0-9]{2}:[0-9]{2})-([0-9]{2}:[0-9]{2}) > )?(.*?)( -- (.*))?"); std::regex_match(str, matches, regex); - std::cout << "line " << str << std::endl; - std::cout << "M 0 " << matches[0] << std::endl; - std::cout << "M 1 " << matches[1] << std::endl; - std::cout << "M 2 " << matches[2] << std::endl; - std::cout << "M 3 " << matches[3] << std::endl; - std::cout << "M 4 " << matches[4] << std::endl; - std::cout << "M 5 " << matches[5] << std::endl; - std::cout << "M 6 " << matches[6] << std::endl; - std::cout << "M 7 " << matches[7] << std::endl; + /*std::cout << "line " << str << std::endl;*/ + /*std::cout << "M 0 " << matches[0] << std::endl;*/ + /*std::cout << "M 1 " << matches[1] << std::endl;*/ + /*std::cout << "M 2 " << matches[2] << std::endl;*/ + /*std::cout << "M 3 " << matches[3] << std::endl;*/ + /*std::cout << "M 4 " << matches[4] << std::endl;*/ + /*std::cout << "M 5 " << matches[5] << std::endl;*/ + /*std::cout << "M 6 " << matches[6] << std::endl;*/ + /*std::cout << "M 7 " << matches[7] << std::endl;*/ std::string text = matches[5]; trim(text); diff --git a/src/qml/TaskItem.qml b/src/qml/TaskItem.qml index b41daa3..a077312 100644 --- a/src/qml/TaskItem.qml +++ b/src/qml/TaskItem.qml @@ -10,11 +10,19 @@ import QtQuick.Layouts import Mirai RowLayout { + id: control property taskItem task + function getFormatedText() { + if (task?.time && task.time != "") { + return `${task.time} \> ${task.text}` + } + return task.text + } + AppCheckbox { id: checkbox - text: task.text + text: control.getFormatedText() checked: task.state === 'DONE' textComponent.color: task.date < internal.todayDate ? colorPalette.selected.palette.pink // : task.date === internal.todayDate ? colorPalette.selected.palette.sapphire