diff --git a/CMakeLists.txt b/CMakeLists.txt index 81bcb90..b38b0f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ qt_add_qml_module(mirai # Qt related files src/Backend.h src/Backend.cpp src/TaskItem.h src/TaskItem.cpp + src/TasksFile.h src/TasksFile.cpp # Core related files src/core/Mirai.h src/core/Mirai.cpp src/core/TaskItem.h src/core/TaskItem.cpp diff --git a/src/Backend.h b/src/Backend.h index 8e67dcc..02906bd 100644 --- a/src/Backend.h +++ b/src/Backend.h @@ -10,6 +10,7 @@ #include "QtCore/qcontainerfwd.h" #include "QtCore/qtmetamacros.h" #include "QtCore/qvariant.h" +#include "TasksFile.h" #include "core/Mirai.h" #include "core/TasksView.h" #include diff --git a/src/TaskItem.cpp b/src/TaskItem.cpp index f7e8fe3..80bd79f 100644 --- a/src/TaskItem.cpp +++ b/src/TaskItem.cpp @@ -7,16 +7,6 @@ #include "TaskItem.h" #include "core/TodoMd.h" -QString QMLTasksFile::getName() -{ - return QString::fromStdString(tasksFile->getName()); -} - -QString QMLTasksFile::getPath() -{ - return QString::fromStdString(tasksFile->getPath()); -} - QString QMLTaskItem::getRawFormat() { return QString::fromStdString(mirai::TodoMdFormat::TaskToString(*taskItem)); diff --git a/src/TaskItem.h b/src/TaskItem.h index 0f13c3f..f28b49b 100644 --- a/src/TaskItem.h +++ b/src/TaskItem.h @@ -10,24 +10,8 @@ #include "QtCore/qvariant.h" #include #include -#include #include "core/TaskItem.h" -#include "core/TasksFile.h" - -struct QMLTasksFile { - - Q_GADGET - Q_PROPERTY(QString name READ getName) - Q_PROPERTY(QString path READ getPath) - QML_VALUE_TYPE(tasksFile) - - public: - QString getName(); - QString getPath(); - - mirai::TasksFile *tasksFile; -}; struct QMLTaskItem { @@ -50,7 +34,7 @@ struct QMLTaskItem { QList getTags(); bool getShouldShowDate(); - mirai::TaskItem *taskItem; + mirai::TaskItem *taskItem = nullptr; bool shouldShowDate = false; QList tags; }; diff --git a/src/TasksFile.cpp b/src/TasksFile.cpp new file mode 100644 index 0000000..1f89de5 --- /dev/null +++ b/src/TasksFile.cpp @@ -0,0 +1,17 @@ +/* + * Mirai. Copyright (C) 2024 Vyn + * This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only) + * The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt + */ + +#include "TasksFile.h" + +QString QMLTasksFile::getName() +{ + return QString::fromStdString(tasksFile->getName()); +} + +QString QMLTasksFile::getPath() +{ + return QString::fromStdString(tasksFile->getPath()); +} diff --git a/src/TasksFile.h b/src/TasksFile.h new file mode 100644 index 0000000..8e7aac5 --- /dev/null +++ b/src/TasksFile.h @@ -0,0 +1,30 @@ +/* + * Mirai. Copyright (C) 2024 Vyn + * This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only) + * The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt + */ + +#ifndef QML_TASKSFILE_H +#define QML_TASKSFILE_H + +#include "QtCore/qvariant.h" +#include +#include + +#include "core/TasksFile.h" + +struct QMLTasksFile { + + Q_GADGET + Q_PROPERTY(QString name READ getName) + Q_PROPERTY(QString path READ getPath) + QML_VALUE_TYPE(tasksFile) + + public: + QString getName(); + QString getPath(); + + mirai::TasksFile *tasksFile; +}; + +#endif