diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
deleted file mode 100644
index 7c0097e..0000000
--- a/android/AndroidManifest.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android/build.gradle b/android/build.gradle
deleted file mode 100644
index f94ffbd..0000000
--- a/android/build.gradle
+++ /dev/null
@@ -1,82 +0,0 @@
-buildscript {
- repositories {
- google()
- mavenCentral()
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:7.4.1'
- }
-}
-
-repositories {
- google()
- mavenCentral()
-}
-
-apply plugin: 'com.android.application'
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
- implementation 'androidx.core:core:1.10.1'
-}
-
-android {
- /*******************************************************
- * The following variables:
- * - androidBuildToolsVersion,
- * - androidCompileSdkVersion
- * - qtAndroidDir - holds the path to qt android files
- * needed to build any Qt application
- * on Android.
- *
- * are defined in gradle.properties file. This file is
- * updated by QtCreator and androiddeployqt tools.
- * Changing them manually might break the compilation!
- *******************************************************/
-
- compileSdkVersion androidCompileSdkVersion
- buildToolsVersion androidBuildToolsVersion
- ndkVersion androidNdkVersion
-
- // Extract native libraries from the APK
- packagingOptions.jniLibs.useLegacyPackaging true
-
- sourceSets {
- main {
- manifest.srcFile 'AndroidManifest.xml'
- java.srcDirs = [qtAndroidDir + '/src', 'src', 'java']
- aidl.srcDirs = [qtAndroidDir + '/src', 'src', 'aidl']
- res.srcDirs = [qtAndroidDir + '/res', 'res']
- resources.srcDirs = ['resources']
- renderscript.srcDirs = ['src']
- assets.srcDirs = ['assets']
- jniLibs.srcDirs = ['libs']
- }
- }
-
- tasks.withType(JavaCompile) {
- options.incremental = true
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
- lintOptions {
- abortOnError false
- }
-
- // Do not compress Qt binary resources file
- aaptOptions {
- noCompress 'rcc'
- }
-
- defaultConfig {
- resConfig "en"
- minSdkVersion qtMinSdkVersion
- targetSdkVersion qtTargetSdkVersion
- ndk.abiFilters = qtTargetAbiList.split(",")
- }
-}
diff --git a/android/gradle.properties b/android/gradle.properties
deleted file mode 100644
index 4fe1674..0000000
--- a/android/gradle.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Project-wide Gradle settings.
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-org.gradle.jvmargs=-Xmx2500m -XX:MaxMetaspaceSize=768m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# Enable building projects in parallel
-org.gradle.parallel=true
-
-# Gradle caching allows reusing the build artifacts from a previous
-# build with the same inputs. However, over time, the cache size will
-# grow. Uncomment the following line to enable it.
-#org.gradle.caching=true
-#org.gradle.configuration-cache=true
-
-# Allow AndroidX usage
-android.useAndroidX=true
diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 7f93135..0000000
Binary files a/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index ac72c34..0000000
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
diff --git a/android/gradlew b/android/gradlew
deleted file mode 100755
index c22a517..0000000
--- a/android/gradlew
+++ /dev/null
@@ -1,249 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright © 2015-2021 the original authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-##############################################################################
-#
-# Gradle start up script for POSIX generated by Gradle.
-#
-# Important for running:
-#
-# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
-# noncompliant, but you have some other compliant shell such as ksh or
-# bash, then to run this script, type that shell name before the whole
-# command line, like:
-#
-# ksh Gradle
-#
-# Busybox and similar reduced shells will NOT work, because this script
-# requires all of these POSIX shell features:
-# * functions;
-# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
-# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
-# * compound commands having a testable exit status, especially «case»;
-# * various built-in commands including «command», «set», and «ulimit».
-#
-# Important for patching:
-#
-# (2) This script targets any POSIX shell, so it avoids extensions provided
-# by Bash, Ksh, etc; in particular arrays are avoided.
-#
-# The "traditional" practice of packing multiple parameters into a
-# space-separated string is a well documented source of bugs and security
-# problems, so this is (mostly) avoided, by progressively accumulating
-# options in "$@", and eventually passing that to Java.
-#
-# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
-# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
-# see the in-line comments for details.
-#
-# There are tweaks for specific operating systems such as AIX, CygWin,
-# Darwin, MinGW, and NonStop.
-#
-# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
-# within the Gradle project.
-#
-# You can find Gradle at https://github.com/gradle/gradle/.
-#
-##############################################################################
-
-# Attempt to set APP_HOME
-
-# Resolve links: $0 may be a link
-app_path=$0
-
-# Need this for daisy-chained symlinks.
-while
- APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
- [ -h "$app_path" ]
-do
- ls=$( ls -ld "$app_path" )
- link=${ls#*' -> '}
- case $link in #(
- /*) app_path=$link ;; #(
- *) app_path=$APP_HOME$link ;;
- esac
-done
-
-# This is normally unused
-# shellcheck disable=SC2034
-APP_BASE_NAME=${0##*/}
-# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD=maximum
-
-warn () {
- echo "$*"
-} >&2
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-} >&2
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "$( uname )" in #(
- CYGWIN* ) cygwin=true ;; #(
- Darwin* ) darwin=true ;; #(
- MSYS* | MINGW* ) msys=true ;; #(
- NONSTOP* ) nonstop=true ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD=$JAVA_HOME/jre/sh/java
- else
- JAVACMD=$JAVA_HOME/bin/java
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD=java
- if ! command -v java >/dev/null 2>&1
- then
- die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-fi
-
-# Increase the maximum file descriptors if we can.
-if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
- case $MAX_FD in #(
- max*)
- # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
- MAX_FD=$( ulimit -H -n ) ||
- warn "Could not query maximum file descriptor limit"
- esac
- case $MAX_FD in #(
- '' | soft) :;; #(
- *)
- # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
- ulimit -n "$MAX_FD" ||
- warn "Could not set maximum file descriptor limit to $MAX_FD"
- esac
-fi
-
-# Collect all arguments for the java command, stacking in reverse order:
-# * args from the command line
-# * the main class name
-# * -classpath
-# * -D...appname settings
-# * --module-path (only if needed)
-# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
-
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if "$cygwin" || "$msys" ; then
- APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
- CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
-
- JAVACMD=$( cygpath --unix "$JAVACMD" )
-
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- for arg do
- if
- case $arg in #(
- -*) false ;; # don't mess with options #(
- /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
- [ -e "$t" ] ;; #(
- *) false ;;
- esac
- then
- arg=$( cygpath --path --ignore --mixed "$arg" )
- fi
- # Roll the args list around exactly as many times as the number of
- # args, so each arg winds up back in the position where it started, but
- # possibly modified.
- #
- # NB: a `for` loop captures its iteration list before it begins, so
- # changing the positional parameters here affects neither the number of
- # iterations, nor the values presented in `arg`.
- shift # remove old arg
- set -- "$@" "$arg" # push replacement arg
- done
-fi
-
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"'
-
-# Collect all arguments for the java command;
-# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
-# shell script including quotes and variable substitutions, so put them in
-# double quotes to make sure that they get re-expanded; and
-# * put everything else in single quotes, so that it's not re-expanded.
-
-set -- \
- "-Dorg.gradle.appname=$APP_BASE_NAME" \
- -classpath "$CLASSPATH" \
- org.gradle.wrapper.GradleWrapperMain \
- "$@"
-
-# Stop when "xargs" is not available.
-if ! command -v xargs >/dev/null 2>&1
-then
- die "xargs is not available"
-fi
-
-# Use "xargs" to parse quoted args.
-#
-# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
-#
-# In Bash we could simply go:
-#
-# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
-# set -- "${ARGS[@]}" "$@"
-#
-# but POSIX shell has neither arrays nor command substitution, so instead we
-# post-process each arg (as a line of input to sed) to backslash-escape any
-# character that might be a shell metacharacter, then use eval to reverse
-# that process (while maintaining the separation between arguments), and wrap
-# the whole thing up as a single "set" statement.
-#
-# This will of course break if any of these variables contains a newline or
-# an unmatched quote.
-#
-
-eval "set -- $(
- printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
- xargs -n1 |
- sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
- tr '\n' ' '
- )" '"$@"'
-
-exec "$JAVACMD" "$@"
diff --git a/android/gradlew.bat b/android/gradlew.bat
deleted file mode 100644
index 3624bce..0000000
--- a/android/gradlew.bat
+++ /dev/null
@@ -1,92 +0,0 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%"=="" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
-
-:end
-@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-set EXIT_CODE=%ERRORLEVEL%
-if %EXIT_CODE% equ 0 set EXIT_CODE=1
-if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
-exit /b %EXIT_CODE%
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/android/res/values/libs.xml b/android/res/values/libs.xml
deleted file mode 100644
index fe63866..0000000
--- a/android/res/values/libs.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android/res/xml/qtprovider_paths.xml b/android/res/xml/qtprovider_paths.xml
deleted file mode 100644
index ae5b4b6..0000000
--- a/android/res/xml/qtprovider_paths.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/external/mirai-core/CMakeLists.txt b/external/mirai-core/CMakeLists.txt
index 3505d01..143ddf9 100644
--- a/external/mirai-core/CMakeLists.txt
+++ b/external/mirai-core/CMakeLists.txt
@@ -14,12 +14,12 @@ add_library(mirai-core
src/Event.cpp
src/DateTime.cpp
src/EventEmitter.cpp
- src/BaseResource.cpp
+ src/BaseSource.cpp
+ src/StdFileSource.cpp
src/TasksView.cpp
src/TodoMd.cpp
src/utils.cpp
)
-
target_include_directories(mirai-core PRIVATE "external")
target_include_directories(mirai-core PRIVATE "include/mirai-core")
diff --git a/external/mirai-core/include/mirai-core/BaseFileResource.h b/external/mirai-core/include/mirai-core/BaseFileSource.h
similarity index 50%
rename from external/mirai-core/include/mirai-core/BaseFileResource.h
rename to external/mirai-core/include/mirai-core/BaseFileSource.h
index 9c2d969..b2c0520 100644
--- a/external/mirai-core/include/mirai-core/BaseFileResource.h
+++ b/external/mirai-core/include/mirai-core/BaseFileSource.h
@@ -4,29 +4,27 @@
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
-#ifndef MIRAI_BASE_FILE_RESOURCE_H
-#define MIRAI_BASE_FILE_RESOURCE_H
+#pragma once
-#include "BaseResource.h"
+#include "BaseSource.h"
#include
namespace mirai
{
-struct BaseFileResourceConstructor {
+struct BaseFileSourceConstructor {
std::string name;
std::string path;
};
-class BaseFileResource : public BaseResource
+class BaseFileSource : public BaseSource
{
public:
- BaseFileResource(BaseFileResourceConstructor data)
- : BaseResource(data.name), path(data.path) {};
+ BaseFileSource(BaseFileSourceConstructor data) : BaseSource(data.name), path(data.path) {};
- BaseFileResource(BaseFileResource &) = delete;
- BaseFileResource(BaseFileResource &&) = delete;
- ~BaseFileResource() override = default;
+ BaseFileSource(BaseFileSource &) = delete;
+ BaseFileSource(BaseFileSource &&) = delete;
+ ~BaseFileSource() override = default;
const std::string &getPath() const
{
@@ -37,4 +35,3 @@ class BaseFileResource : public BaseResource
std::string path;
};
} // namespace mirai
-#endif
diff --git a/external/mirai-core/include/mirai-core/BaseResource.h b/external/mirai-core/include/mirai-core/BaseSource.h
similarity index 70%
rename from external/mirai-core/include/mirai-core/BaseResource.h
rename to external/mirai-core/include/mirai-core/BaseSource.h
index 9d822f7..f6f2204 100644
--- a/external/mirai-core/include/mirai-core/BaseResource.h
+++ b/external/mirai-core/include/mirai-core/BaseSource.h
@@ -4,8 +4,7 @@
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
-#ifndef MIRAI_BASE_RESOURCE_H
-#define MIRAI_BASE_RESOURCE_H
+#pragma once
#include "DateTime.h"
#include "Day.h"
@@ -19,7 +18,7 @@
namespace mirai
{
-class BaseResource
+class BaseSource
{
public:
@@ -28,23 +27,16 @@ class BaseResource
Tags tags;
};
- BaseResource(std::string name) : name_(name) {};
- BaseResource(BaseResource &) = delete;
- BaseResource(BaseResource &&) = delete;
+ BaseSource(std::string name) : name_(name) {};
+ BaseSource(BaseSource &) = delete;
+ BaseSource(BaseSource &&) = delete;
- virtual ~BaseResource() = default;
+ virtual ~BaseSource() = default;
virtual void save() = 0;
virtual void load() = 0;
- void setName(std::string name)
- {
- this->name_ = name;
- }
-
- const std::string &getName() const
- {
- return name_;
- }
+ void setName(std::string name);
+ const std::string &getName() const;
void addDay(const DayData &dayData);
Day *day(const Date &date);
@@ -56,10 +48,7 @@ class BaseResource
void setDirty(bool shouldBeDirty);
bool isDirty() const;
- int id() const
- {
- return id_;
- }
+ int id() const;
private:
static int nextId_;
@@ -70,4 +59,3 @@ class BaseResource
};
} // namespace mirai
-#endif
diff --git a/external/mirai-core/include/mirai-core/DateTime.h b/external/mirai-core/include/mirai-core/DateTime.h
index cc423f7..c1125ba 100644
--- a/external/mirai-core/include/mirai-core/DateTime.h
+++ b/external/mirai-core/include/mirai-core/DateTime.h
@@ -16,78 +16,28 @@ namespace mirai
{
struct Date {
- explicit Date(int year, unsigned month, unsigned day) : year(year), month(month), day(day)
- {
- }
+ explicit Date(int year, unsigned month, unsigned day);
- explicit Date(std::chrono::time_point tp)
- {
- auto chronoDate = std::chrono::year_month_day(std::chrono::floor(tp));
- year = static_cast(chronoDate.year());
- month = static_cast(chronoDate.month());
- day = static_cast(chronoDate.day());
- }
+ explicit Date(std::chrono::time_point tp);
+ explicit Date(std::chrono::year_month_day chronoDate);
- explicit Date(std::chrono::year_month_day chronoDate)
- {
- year = static_cast(chronoDate.year());
- month = static_cast(chronoDate.month());
- day = static_cast(chronoDate.day());
- }
+ bool operator==(const Date &other) const;
+ bool operator<(const Date &other) const;
+ bool operator>(const Date &other) const;
int year;
unsigned month;
unsigned day;
-
- bool operator==(const Date &other) const
- {
- return other.year == year && other.month == month && other.day == day;
- }
-
- bool operator<(const Date &other) const
- {
- if (year < other.year) {
- return true;
- }
- if (year == other.year && month < other.month) {
- return true;
- }
- if (year == other.year && month == other.month && day < other.day) {
- return true;
- }
- return false;
- }
-
- bool operator>(const Date &other) const
- {
- return !(*this < other) && !(*this == other);
- }
};
struct Time {
+
+ bool operator==(const Time &other) const;
+ bool operator<(const Time &other) const;
+ bool operator>(const Time &other) const;
+
int hour;
int minute;
-
- bool operator==(const Time &other) const
- {
- return other.hour == hour && other.minute == minute;
- }
-
- bool operator<(const Time &other) const
- {
- if (hour < other.hour) {
- return true;
- }
- if (hour == other.hour && minute < other.minute) {
- return true;
- }
- return false;
- }
-
- bool operator>(const Time &other) const
- {
- return !(*this < other) && !(*this == other);
- }
};
std::optional stringToDate(const std::string &dateStr);
diff --git a/external/mirai-core/include/mirai-core/Day.h b/external/mirai-core/include/mirai-core/Day.h
index da9743a..44584cb 100644
--- a/external/mirai-core/include/mirai-core/Day.h
+++ b/external/mirai-core/include/mirai-core/Day.h
@@ -17,7 +17,7 @@
namespace mirai
{
-class BaseResource;
+class BaseSource;
struct DayData {
Date date;
@@ -28,7 +28,7 @@ struct DayData {
class Day
{
public:
- Day(BaseResource *source, const DayData &data);
+ Day(BaseSource *source, const DayData &data);
void setDate(const Date &date);
Event *createEvent(const EventData &eventData);
@@ -40,25 +40,13 @@ class Day
const Date &getDate() const;
- Event *getEventById(int eventId)
- {
- for (auto &event : events_) {
- if (event->id() == eventId) {
- return event.get();
- }
- }
- return nullptr;
- }
-
- BaseResource *source()
- {
- return source_;
- }
+ Event *getEventById(int eventId);
+ BaseSource *source();
private:
void onChange();
- BaseResource *source_;
+ BaseSource *source_;
std::vector> events_;
std::vector> tasks_;
DayData data_;
diff --git a/external/mirai-core/include/mirai-core/Event.h b/external/mirai-core/include/mirai-core/Event.h
index 56fa23c..7f445a5 100644
--- a/external/mirai-core/include/mirai-core/Event.h
+++ b/external/mirai-core/include/mirai-core/Event.h
@@ -16,7 +16,7 @@
namespace mirai
{
-class BaseResource;
+class BaseSource;
struct EventData {
std::string description;
@@ -33,14 +33,9 @@ class Event
{
private:
public:
- Event(BaseResource *source, Day *parent, const EventData &data);
+ Event(BaseSource *source, Day *parent, const EventData &data);
- Event &operator=(const EventData &newData)
- {
- data = newData;
- onChange();
- return *this;
- };
+ Event &operator=(const EventData &newData);
void setText(const std::string &text);
void setStartTime(const Time &time);
@@ -57,15 +52,8 @@ class Event
const Tags &getTags() const;
bool hasTag(const std::string &tag) const;
- int id() const
- {
- return id_;
- }
-
- Day *day()
- {
- return day_;
- }
+ int id() const;
+ Day *day();
private:
void onChange();
@@ -75,6 +63,6 @@ class Event
Day *day_;
EventData data;
std::vector> tasks_;
- BaseResource *source_;
+ BaseSource *source_;
};
} // namespace mirai
diff --git a/external/mirai-core/include/mirai-core/Mirai.h b/external/mirai-core/include/mirai-core/Mirai.h
index 206387d..d9bbe15 100644
--- a/external/mirai-core/include/mirai-core/Mirai.h
+++ b/external/mirai-core/include/mirai-core/Mirai.h
@@ -4,11 +4,10 @@
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
-#ifndef MIRAI_MIRAI_H
-#define MIRAI_MIRAI_H
+#pragma once
-#include "BaseFileResource.h"
-#include "BaseResource.h"
+#include "BaseFileSource.h"
+#include "BaseSource.h"
#include "TaskItem.h"
#include "TodoMd.h"
#include
@@ -25,31 +24,22 @@ class Mirai
{
public:
- void loadResource(std::unique_ptr &&resource);
- void unloadAllResources();
+ void loadSource(std::unique_ptr &&resource);
+ void unloadAllSources();
void save();
- void removeTask(const TaskItem *taskItem);
- std::optional> getResourceByName(const std::string &name);
+ void deleteTask(const TaskItem &taskItem);
+ std::optional> getSourceByName(const std::string &name);
- std::vector> &getResources();
+ std::vector> &getSources();
const std::vector &getTags();
void reloadTags();
- // new stuff
-
// Returns a non owning pointer to the requested resource or nullptr if not found.
- BaseResource *getResourceById(int id)
- {
- if (id >= resources_.size()) {
- return nullptr;
- }
- return resources_.at(id).get();
- }
+ BaseSource *getSourceById(int id);
private:
- std::vector> resources_;
+ std::vector> sources_;
std::vector tags_;
};
} // namespace mirai
-#endif
diff --git a/external/mirai-core/include/mirai-core/StdFileResource.h b/external/mirai-core/include/mirai-core/StdFileResource.h
deleted file mode 100644
index e7d50e6..0000000
--- a/external/mirai-core/include/mirai-core/StdFileResource.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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 MIRAI_STD_FILE_RESOURCE_H
-#define MIRAI_STD_FILE_RESOURCE_H
-
-#include "BaseFileResource.h"
-#include "TodoMd.h"
-#include
-#include
-#include
-#include
-
-namespace mirai
-{
-
-class StdFileResource : public BaseFileResource
-{
- public:
- StdFileResource(BaseFileResourceConstructor data) : BaseFileResource(data) {};
- StdFileResource(StdFileResource &) = delete;
- StdFileResource(StdFileResource &&) = delete;
- StdFileResource operator=(StdFileResource &) = delete;
- StdFileResource operator=(StdFileResource &&) = delete;
-
- ~StdFileResource() override = default;
-
- void save() override
- {
- std::ofstream file(getPath());
- if (!file.is_open()) {
- throw std::runtime_error("can't create " + getPath());
- }
-
- const std::string content = TodoMdFormat::stringify(getName(), *days());
-
- file << content;
- file.close();
- };
-
- void load() override
- {
- std::ifstream file(getPath());
- if (!file.is_open()) {
- return;
- }
- std::string content = "";
- std::string line;
-
- while (std::getline(file, line)) {
- content += line + "\n";
- }
- file.close();
- auto result = TodoMdFormat::parse(content);
- for (const auto &dayData : result.days) {
- Day *newDay = day(dayData.date);
- for (const auto &eventData : dayData.events) {
- Event *newEvent = newDay->createEvent(eventData);
- for (const auto &taskData : eventData.tasks) {
- TaskItem *newTask = newEvent->createTask(taskData);
- }
- }
- for (const auto &taskData : dayData.tasks) {
- TaskItem *newTask = newDay->createTask(taskData);
- }
- }
- setName(result.name);
- };
-};
-} // namespace mirai
-#endif
diff --git a/external/mirai-core/include/mirai-core/StdFileSource.h b/external/mirai-core/include/mirai-core/StdFileSource.h
new file mode 100644
index 0000000..0f1b244
--- /dev/null
+++ b/external/mirai-core/include/mirai-core/StdFileSource.h
@@ -0,0 +1,29 @@
+/*
+ * 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
+ */
+
+#pragma once
+
+#include "BaseFileSource.h"
+
+namespace mirai
+{
+
+class StdFileSource : public BaseFileSource
+{
+ public:
+ StdFileSource(BaseFileSourceConstructor data) : BaseFileSource(data) {};
+ StdFileSource(StdFileSource &) = delete;
+ StdFileSource(StdFileSource &&) = delete;
+ StdFileSource operator=(StdFileSource &) = delete;
+ StdFileSource operator=(StdFileSource &&) = delete;
+
+ ~StdFileSource() override = default;
+
+ void save() override;
+ void load() override;
+ ;
+};
+} // namespace mirai
diff --git a/external/mirai-core/include/mirai-core/TaskItem.h b/external/mirai-core/include/mirai-core/TaskItem.h
index 7f2f1b0..af57618 100644
--- a/external/mirai-core/include/mirai-core/TaskItem.h
+++ b/external/mirai-core/include/mirai-core/TaskItem.h
@@ -4,8 +4,7 @@
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
-#ifndef MIRAI_TASKITEM_H
-#define MIRAI_TASKITEM_H
+#pragma once
#include "using.h"
#include
@@ -14,7 +13,7 @@
namespace mirai
{
-class BaseResource;
+class BaseSource;
class Day;
enum TaskItemState { TODO, DONE };
@@ -28,20 +27,13 @@ struct TaskItemData {
class TaskItem
{
public:
- TaskItem(BaseResource *source, Day *day, const TaskItemData data);
+ TaskItem(BaseSource *source, Day *day, const TaskItemData data);
- TaskItem &operator=(const TaskItemData &newData)
- {
- data = newData;
- onChange();
- return *this;
- };
+ TaskItem &operator=(const TaskItemData &newData);
void markAsDone();
-
void markAsUndone();
void setDate(const std::string &date);
-
void setText(const std::string &text);
const std::string &getLine() const;
@@ -50,20 +42,9 @@ class TaskItem
const Tags &getTags() const;
bool hasTag(const std::string &tag) const;
- int id() const
- {
- return id_;
- }
-
- BaseResource *source()
- {
- return source_;
- }
-
- Day *day()
- {
- return day_;
- }
+ int id() const;
+ BaseSource *source();
+ Day *day();
private:
void onChange();
@@ -72,10 +53,8 @@ class TaskItem
int id_ = nextId++;
TaskItemData data;
- BaseResource *source_;
+ BaseSource *source_;
Day *day_;
};
} // namespace mirai
-
-#endif
diff --git a/external/mirai-core/include/mirai-core/TasksView.h b/external/mirai-core/include/mirai-core/TasksView.h
index 535a63e..b9cc47a 100644
--- a/external/mirai-core/include/mirai-core/TasksView.h
+++ b/external/mirai-core/include/mirai-core/TasksView.h
@@ -4,8 +4,7 @@
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
-#ifndef MIRAI_TASKSVIEW_H
-#define MIRAI_TASKSVIEW_H
+#pragma once
#include "Mirai.h"
#include "TaskItem.h"
#include "using.h"
@@ -39,41 +38,14 @@ class TasksView
void update();
void addTagFilter(const std::string &tag);
void removeTagFilter(const std::string &tag);
- void addResourceFilter(const std::string &fileName);
- void removeResourceFilter(const std::string &fileName);
+ void addSourceFilter(const std::string &fileName);
+ void removeSourceFilter(const std::string &fileName);
void removeFilters();
const Tags &getActiveTagsFilter();
const std::vector &getActiveFilesFilter();
- void hideCompletedTasks(bool hide)
- {
- shouldHideCompletedTasks_ = hide;
- }
-
- bool shouldHideCompletedTasks() const
- {
- return shouldHideCompletedTasks_;
- }
-
- /*auto begin()*/ // TODO REWORK
- /*{*/
- /*return tasksToShow.begin();*/
- /*}*/
-
- /*auto begin() const*/
- /*{*/
- /*return tasksToShow.cbegin();*/
- /*}*/
-
- /*auto end() const*/
- /*{*/
- /*return tasksToShow.cend();*/
- /*}*/
-
- /*auto end()*/
- /*{*/
- /*return tasksToShow.end();*/
- /*}*/
+ void hideCompletedTasks(bool hide);
+ bool shouldHideCompletedTasks() const;
private:
std::vector filteredDays;
@@ -84,4 +56,3 @@ class TasksView
bool shouldHideCompletedTasks_ = true;
};
} // namespace mirai
-#endif
diff --git a/external/mirai-core/include/mirai-core/TodoMd.h b/external/mirai-core/include/mirai-core/TodoMd.h
index 16e5928..5f95c0e 100644
--- a/external/mirai-core/include/mirai-core/TodoMd.h
+++ b/external/mirai-core/include/mirai-core/TodoMd.h
@@ -4,8 +4,7 @@
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
-#ifndef MIRAI_TODOMD_H
-#define MIRAI_TODOMD_H
+#pragma once
#include "DateTime.h"
#include "Day.h"
@@ -44,5 +43,3 @@ class TodoMdFormat
static Tags extractTagsFromMetadata(std::string metadata);
};
} // namespace mirai
-
-#endif
diff --git a/external/mirai-core/include/mirai-core/TodoTxt.h b/external/mirai-core/include/mirai-core/TodoTxt.h
index 6b523f3..81d3b22 100644
--- a/external/mirai-core/include/mirai-core/TodoTxt.h
+++ b/external/mirai-core/include/mirai-core/TodoTxt.h
@@ -4,8 +4,7 @@
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
-#ifndef MIRAI_TODOTXT_H
-#define MIRAI_TODOTXT_H
+#pragma once
/*#include "TaskItem.h"*/
/*#include "utils.h"*/
@@ -90,5 +89,3 @@
/*}*/
/*};*/
/*}*/
-
-#endif
diff --git a/external/mirai-core/include/mirai-core/using.h b/external/mirai-core/include/mirai-core/using.h
index 7f3a671..b37af86 100644
--- a/external/mirai-core/include/mirai-core/using.h
+++ b/external/mirai-core/include/mirai-core/using.h
@@ -4,8 +4,7 @@
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
-#ifndef MIRAI_USING_H
-#define MIRAI_USING_H
+#pragma once
#include
#include
@@ -15,5 +14,3 @@ namespace mirai
{
using Tags = std::vector;
}
-
-#endif
diff --git a/external/mirai-core/include/mirai-core/utils.h b/external/mirai-core/include/mirai-core/utils.h
index 6617567..83b639b 100644
--- a/external/mirai-core/include/mirai-core/utils.h
+++ b/external/mirai-core/include/mirai-core/utils.h
@@ -4,8 +4,7 @@
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
-#ifndef MIRAI_UTILS_H
-#define MIRAI_UTILS_H
+#pragma once
#include
#include
@@ -21,5 +20,3 @@ namespace vectorUtils = cpputils::vector;
bool isDate(const std::string &dateStr);
} // namespace mirai
-
-#endif
diff --git a/external/mirai-core/src/BaseResource.cpp b/external/mirai-core/src/BaseSource.cpp
similarity index 79%
rename from external/mirai-core/src/BaseResource.cpp
rename to external/mirai-core/src/BaseSource.cpp
index 90204a5..5e80d8a 100644
--- a/external/mirai-core/src/BaseResource.cpp
+++ b/external/mirai-core/src/BaseSource.cpp
@@ -4,7 +4,7 @@
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
-#include "BaseResource.h"
+#include "BaseSource.h"
#include "Day.h"
#include "TaskItem.h"
#include
@@ -16,17 +16,17 @@
namespace mirai
{
-void BaseResource::setDirty(bool shouldBeDirty)
+void BaseSource::setDirty(bool shouldBeDirty)
{
isDirty_ = shouldBeDirty;
}
-bool BaseResource::isDirty() const
+bool BaseSource::isDirty() const
{
return isDirty_;
}
-Day *BaseResource::day(const Date &date)
+Day *BaseSource::day(const Date &date)
{
auto dayFound = std::find_if(days_.begin(), days_.end(), [&](std::unique_ptr &day) {
return day->getDate().day == date.day && day->getDate().month == date.month &&
@@ -41,18 +41,18 @@ Day *BaseResource::day(const Date &date)
return dayFound->get();
}
-std::vector> *BaseResource::days()
+std::vector> *BaseSource::days()
{
return &days_;
}
-void BaseResource::addDay(const DayData &dayData)
+void BaseSource::addDay(const DayData &dayData)
{
days_.push_back(std::make_unique(this, dayData));
setDirty(true);
}
-TaskItem *BaseResource::getTaskById(int taskId)
+TaskItem *BaseSource::getTaskById(int taskId)
{
for (auto &day : days_) {
for (auto &task : *day->tasks()) {
@@ -71,7 +71,7 @@ TaskItem *BaseResource::getTaskById(int taskId)
return nullptr;
}
-void BaseResource::deleteTask(const TaskItem &taskToDelete)
+void BaseSource::deleteTask(const TaskItem &taskToDelete)
{
for (auto &day : days_) {
for (auto &task : *day->tasks()) {
@@ -91,7 +91,7 @@ void BaseResource::deleteTask(const TaskItem &taskToDelete)
}
}
-Event *BaseResource::getEventById(int eventId)
+Event *BaseSource::getEventById(int eventId)
{
for (auto &day : days_) {
for (auto &event : *day->events()) {
@@ -103,6 +103,21 @@ Event *BaseResource::getEventById(int eventId)
return nullptr;
}
+void BaseSource::setName(std::string name)
+{
+ this->name_ = name;
+}
+
+const std::string &BaseSource::getName() const
+{
+ return name_;
+}
+
+int BaseSource::id() const
+{
+ return id_;
+}
+
/*void BaseResource::addTask(TaskItemData taskItem)*/
/*{*/
/*tasks.push_back(std::make_unique(this, taskItem));*/
@@ -122,6 +137,6 @@ Event *BaseResource::getEventById(int eventId)
/*setDirty(true);*/
/*}*/
-int BaseResource::nextId_ = 0;
+int BaseSource::nextId_ = 0;
} // namespace mirai
diff --git a/external/mirai-core/src/DateTime.cpp b/external/mirai-core/src/DateTime.cpp
index 6094c92..bc051a3 100644
--- a/external/mirai-core/src/DateTime.cpp
+++ b/external/mirai-core/src/DateTime.cpp
@@ -34,4 +34,72 @@ std::optional stringToDate(const std::string &dateStr)
auto day = dateSplit[2];
return mirai::Date(year, static_cast(month), static_cast(day));
}
+
+Date::Date(int year, unsigned month, unsigned day) : year(year), month(month), day(day)
+{
+}
+
+Date::Date(std::chrono::time_point tp)
+{
+ auto chronoDate = std::chrono::year_month_day(std::chrono::floor(tp));
+ year = static_cast(chronoDate.year());
+ month = static_cast(chronoDate.month());
+ day = static_cast(chronoDate.day());
+}
+
+Date::Date(std::chrono::year_month_day chronoDate)
+{
+ year = static_cast(chronoDate.year());
+ month = static_cast(chronoDate.month());
+ day = static_cast(chronoDate.day());
+}
+
+int year;
+unsigned month;
+unsigned day;
+
+bool Date::operator==(const Date &other) const
+{
+ return other.year == year && other.month == month && other.day == day;
+}
+
+bool Date::operator<(const Date &other) const
+{
+ if (year < other.year) {
+ return true;
+ }
+ if (year == other.year && month < other.month) {
+ return true;
+ }
+ if (year == other.year && month == other.month && day < other.day) {
+ return true;
+ }
+ return false;
+}
+
+bool Date::operator>(const Date &other) const
+{
+ return !(*this < other) && !(*this == other);
+}
+
+bool Time::operator==(const Time &other) const
+{
+ return other.hour == hour && other.minute == minute;
+}
+
+bool Time::operator<(const Time &other) const
+{
+ if (hour < other.hour) {
+ return true;
+ }
+ if (hour == other.hour && minute < other.minute) {
+ return true;
+ }
+ return false;
+}
+
+bool Time::operator>(const Time &other) const
+{
+ return !(*this < other) && !(*this == other);
+}
} // namespace mirai
diff --git a/external/mirai-core/src/Day.cpp b/external/mirai-core/src/Day.cpp
index d55f932..26b305d 100644
--- a/external/mirai-core/src/Day.cpp
+++ b/external/mirai-core/src/Day.cpp
@@ -5,7 +5,7 @@
*/
#include "Day.h"
-#include "BaseResource.h"
+#include "BaseSource.h"
#include
#include
#include
@@ -15,7 +15,7 @@
namespace mirai
{
-Day::Day(BaseResource *source, const DayData &data) : source_(source), data_(data)
+Day::Day(BaseSource *source, const DayData &data) : source_(source), data_(data)
{
}
@@ -86,4 +86,19 @@ std::vector> *Day::tasks()
{
return &tasks_;
}
+
+Event *Day::getEventById(int eventId)
+{
+ for (auto &event : events_) {
+ if (event->id() == eventId) {
+ return event.get();
+ }
+ }
+ return nullptr;
+}
+
+BaseSource *Day::source()
+{
+ return source_;
+}
} // namespace mirai
diff --git a/external/mirai-core/src/Event.cpp b/external/mirai-core/src/Event.cpp
index 54f5548..f4d206f 100644
--- a/external/mirai-core/src/Event.cpp
+++ b/external/mirai-core/src/Event.cpp
@@ -5,14 +5,14 @@
*/
#include "Event.h"
-#include "BaseResource.h"
+#include "BaseSource.h"
#include "TaskItem.h"
#include "utils.h"
namespace mirai
{
-Event::Event(BaseResource *source, Day *parent, const EventData &data)
+Event::Event(BaseSource *source, Day *parent, const EventData &data)
: source_(source), day_(parent), data(data)
{
}
@@ -94,6 +94,23 @@ void Event::onChange()
source_->setDirty(true);
}
+Event &Event::operator=(const EventData &newData)
+{
+ data = newData;
+ onChange();
+ return *this;
+};
+
+int Event::id() const
+{
+ return id_;
+}
+
+Day *Event::day()
+{
+ return day_;
+}
+
int Event::nextId = 0;
} // namespace mirai
diff --git a/external/mirai-core/src/Mirai.cpp b/external/mirai-core/src/Mirai.cpp
index 50160b6..2e19684 100644
--- a/external/mirai-core/src/Mirai.cpp
+++ b/external/mirai-core/src/Mirai.cpp
@@ -19,21 +19,21 @@
namespace mirai
{
-void Mirai::loadResource(std::unique_ptr &&resource)
+void Mirai::loadSource(std::unique_ptr &&resource)
{
resource->load();
- resources_.push_back(std::move(resource));
+ sources_.push_back(std::move(resource));
reloadTags();
};
-void Mirai::unloadAllResources()
+void Mirai::unloadAllSources()
{
- resources_.clear();
+ sources_.clear();
}
void Mirai::save()
{
- for (auto &resource : resources_) {
+ for (auto &resource : sources_) {
if (resource->isDirty()) {
resource->save();
resource->setDirty(false);
@@ -42,27 +42,26 @@ void Mirai::save()
reloadTags();
}
-void Mirai::removeTask(const TaskItem *taskItem)
+void Mirai::deleteTask(const TaskItem &taskItem)
{
- for (auto &resource : resources_) {
- // resource->removeTask(taskItem); // TODO REWORK
+ for (auto &resource : sources_) {
+ resource->deleteTask(taskItem);
}
}
-std::vector> &Mirai::getResources()
+std::vector> &Mirai::getSources()
{
- return resources_;
+ return sources_;
}
-std::optional> Mirai::getResourceByName(const std::string &name
-)
+std::optional> Mirai::getSourceByName(const std::string &name)
{
auto resourceIterator =
- std::ranges::find_if(resources_, [&](const std::unique_ptr &resource) {
+ std::ranges::find_if(sources_, [&](const std::unique_ptr &resource) {
return resource->getName() == name;
});
- if (resourceIterator == resources_.end()) {
+ if (resourceIterator == sources_.end()) {
return std::nullopt;
}
return *(resourceIterator->get());
@@ -75,18 +74,27 @@ const std::vector &Mirai::getTags()
void Mirai::reloadTags()
{
- /*cpputils::debug::Timer reloadingTagsDuration;*/ // TODO REWORK
- /*tags.clear();*/
- /*for (auto &resource : resources) {*/
- /*for (auto &task : resource->getTasks()) {*/
- /*for (auto &tag : task->getTags()) {*/
- /*if (!vectorUtils::contains(tags, tag)) {*/
- /*tags.push_back(tag);*/
- /*}*/
- /*}*/
- /*}*/
- /*}*/
+ // TODO TAGS
+ /*cpputils::debug::Timer reloadingTagsDuration;*/
+ /*tags.clear();*/
+ /*for (auto &resource : resources) {*/
+ /*for (auto &task : resource->getTasks()) {*/
+ /*for (auto &tag : task->getTags()) {*/
+ /*if (!vectorUtils::contains(tags, tag)) {*/
+ /*tags.push_back(tag);*/
+ /*}*/
+ /*}*/
+ /*}*/
+ /*}*/
/*reloadingTagsDuration.printTimeElapsed("ReloadingTags");*/
}
+BaseSource *Mirai::getSourceById(int id)
+{
+ if (id >= sources_.size()) {
+ return nullptr;
+ }
+ return sources_.at(id).get();
+}
+
} // namespace mirai
diff --git a/external/mirai-core/src/StdFileSource.cpp b/external/mirai-core/src/StdFileSource.cpp
new file mode 100644
index 0000000..4b30c55
--- /dev/null
+++ b/external/mirai-core/src/StdFileSource.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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 "StdFileSource.h"
+#include "TodoMd.h"
+#include
+#include
+#include
+#include
+
+namespace mirai
+{
+
+void StdFileSource::save()
+{
+ std::ofstream file(getPath());
+ if (!file.is_open()) {
+ throw std::runtime_error("can't create " + getPath());
+ }
+
+ const std::string content = TodoMdFormat::stringify(getName(), *days());
+
+ file << content;
+ file.close();
+};
+
+void StdFileSource::load()
+{
+ std::ifstream file(getPath());
+ if (!file.is_open()) {
+ return;
+ }
+ std::string content = "";
+ std::string line;
+
+ while (std::getline(file, line)) {
+ content += line + "\n";
+ }
+ file.close();
+ auto result = TodoMdFormat::parse(content);
+ for (const auto &dayData : result.days) {
+ Day *newDay = day(dayData.date);
+ for (const auto &eventData : dayData.events) {
+ Event *newEvent = newDay->createEvent(eventData);
+ for (const auto &taskData : eventData.tasks) {
+ TaskItem *newTask = newEvent->createTask(taskData);
+ }
+ }
+ for (const auto &taskData : dayData.tasks) {
+ TaskItem *newTask = newDay->createTask(taskData);
+ }
+ }
+ setName(result.name);
+};
+} // namespace mirai
diff --git a/external/mirai-core/src/TaskItem.cpp b/external/mirai-core/src/TaskItem.cpp
index 974c811..1ffcda4 100644
--- a/external/mirai-core/src/TaskItem.cpp
+++ b/external/mirai-core/src/TaskItem.cpp
@@ -5,7 +5,7 @@
*/
#include "TaskItem.h"
-#include "BaseResource.h"
+#include "BaseSource.h"
#include "utils.h"
#include
@@ -14,7 +14,14 @@ namespace mirai
int TaskItem::nextId = 0;
-TaskItem::TaskItem(BaseResource *source, Day *day, TaskItemData data)
+TaskItem &TaskItem::operator=(const TaskItemData &newData)
+{
+ data = newData;
+ onChange();
+ return *this;
+};
+
+TaskItem::TaskItem(BaseSource *source, Day *day, TaskItemData data)
: source_(source), day_(day), data(data)
{
}
@@ -62,4 +69,19 @@ void TaskItem::onChange()
source()->setDirty(true);
}
+int TaskItem::id() const
+{
+ return id_;
+}
+
+BaseSource *TaskItem::source()
+{
+ return source_;
+}
+
+Day *TaskItem::day()
+{
+ return day_;
+}
+
} // namespace mirai
diff --git a/external/mirai-core/src/TasksView.cpp b/external/mirai-core/src/TasksView.cpp
index 0f32703..fea6925 100644
--- a/external/mirai-core/src/TasksView.cpp
+++ b/external/mirai-core/src/TasksView.cpp
@@ -46,7 +46,7 @@ void TasksView::update()
auto todayDate = std::format("{:%Y-%m-%d}", std::chrono::system_clock::now());
filteredDays.clear();
- for (auto &file : mirai->getResources()) {
+ for (auto &file : mirai->getSources()) {
if (resourcesFilter.size() > 0 &&
!vectorUtils::contains(resourcesFilter, file->getName())) {
continue;
@@ -55,9 +55,8 @@ void TasksView::update()
FilteredDay filteredDay{.day = day.get()};
for (auto &task : *day->tasks()) {
auto taskDate = std::format(
- "{}-0{}-{}", day->getDate().year, // TODO REWORK REMOVE 0{}
- day->getDate().month,
- day->getDate().day // TODO REWORK CLEAN THIS MESS
+ "{:04d}-{:02d}-{:02d}", day->getDate().year, day->getDate().month,
+ day->getDate().day
);
if (shouldHideCompletedTasks() && task->getState() == DONE &&
taskDate < todayDate) {
@@ -72,8 +71,8 @@ void TasksView::update()
for (auto &event : *day->events()) {
FilteredEvent filteredEvent{.event = event.get()};
auto eventDate = std::format(
- // TODO REWORK
- "{}-0{}-{}", day->getDate().year, day->getDate().month, day->getDate().day
+ "{:04d}-{:02d}-{:02d}", day->getDate().year, day->getDate().month,
+ day->getDate().day
);
for (auto &task : *event->tasks()) {
@@ -141,13 +140,13 @@ void TasksView::removeTagFilter(const std::string &tag)
update();
}
-void TasksView::addResourceFilter(const std::string &fileName)
+void TasksView::addSourceFilter(const std::string &fileName)
{
resourcesFilter.push_back(fileName);
update();
}
-void TasksView::removeResourceFilter(const std::string &fileName)
+void TasksView::removeSourceFilter(const std::string &fileName)
{
resourcesFilter.erase(std::remove_if(
resourcesFilter.begin(), resourcesFilter.end(),
@@ -173,4 +172,14 @@ const std::vector &TasksView::getActiveFilesFilter()
{
return resourcesFilter;
}
+
+void TasksView::hideCompletedTasks(bool hide)
+{
+ shouldHideCompletedTasks_ = hide;
+}
+
+bool TasksView::shouldHideCompletedTasks() const
+{
+ return shouldHideCompletedTasks_;
+}
} // namespace mirai
diff --git a/src/UiState.cpp b/src/UiState.cpp
index 70dc7d0..32721e4 100644
--- a/src/UiState.cpp
+++ b/src/UiState.cpp
@@ -34,18 +34,18 @@
UiState::UiState(mirai::Mirai *miraiInstance) : miraiInstance_(miraiInstance), view_(miraiInstance)
{
- resources_ = std::make_shared>();
+ sources_ = std::make_shared>();
days_ = std::make_shared>();
tags_ = std::make_shared>();
- taskEditWindow_->global().set_resources(resources_);
- taskEditWindow_->global().set_tags(tags_);
- eventWindow_->global().set_resources(resources_);
+ taskWindow_->global().set_sources(sources_);
+ taskWindow_->global().set_tags(tags_);
+ eventWindow_->global().set_sources(sources_);
eventWindow_->global().set_tags(tags_);
view_.update();
- reloadResources();
+ reloadSources();
reloadTags();
reloadTasks();
@@ -73,6 +73,59 @@ std::optional stringToDate(const std::string &dateStr)
return Date{.year = year, .month = month, .day = day};
}
+void UiState::setupTaskWindowCallbacks()
+{
+ taskWindow_->on_save([&](SaveTaskData newTaskData) {
+ auto source = miraiInstance_->getSourceById(newTaskData.sourceId);
+ assert(source);
+ auto task = source->getTaskById(newTaskData.id);
+ assert(task);
+ const Date &date = newTaskData.date;
+ const std::string dateStr = SlintDateToStdString(date);
+ auto taskData =
+ mirai::TodoMdFormat::stringToTask("- [ ] " + std::string(newTaskData.title), dateStr);
+
+ task->setText(taskData.text);
+ if (task->day()->getDate() != SlintDateToMiraiDate(date)) {
+ auto newDate = source->day(SlintDateToMiraiDate(date));
+ newDate->createTask({
+ .text = taskData.text,
+ .state = task->getState(),
+ .tags = taskData.tags,
+ });
+ auto oldDate = task->day();
+ source->deleteTask(*task);
+ }
+ miraiInstance_->save();
+ view_.update();
+ reloadTasks();
+ taskWindow_->hide();
+ });
+
+ taskWindow_->on_create([&](NewTaskData newTaskData) {
+ const Date &date = newTaskData.date;
+ const std::string dateStr = SlintDateToStdString(date);
+ auto source = miraiInstance_->getSourceById(newTaskData.sourceId);
+ auto task =
+ mirai::TodoMdFormat::stringToTask("- [ ] " + std::string(newTaskData.title), dateStr);
+
+ if (newTaskData.eventId == -1) {
+ auto day = source->day(SlintDateToMiraiDate(date));
+ assert(day);
+ day->createTask(task);
+ } else {
+ auto event = source->getEventById(newTaskData.eventId);
+ assert(event);
+ event->createTask(task);
+ }
+
+ miraiInstance_->save();
+ view_.update();
+ reloadTasks();
+ taskWindow_->hide();
+ });
+}
+
void UiState::setupEventWindowCallbacks()
{
mainWindow_->global().on_open_new_event_form([&]() {
@@ -92,11 +145,11 @@ void UiState::setupEventWindowCallbacks()
});
mainWindow_->global().on_open_edit_event_form([&](int sourceId, int eventId) {
- auto resource = miraiInstance_->getResourceById(sourceId);
- assert(resource);
- auto event = resource->getEventById(eventId);
+ auto source = miraiInstance_->getSourceById(sourceId);
+ assert(source);
+ auto event = source->getEventById(eventId);
assert(event);
- eventWindow_->global().set_resources(resources_);
+ eventWindow_->global().set_sources(sources_);
eventWindow_->global().set_tags(tags_);
eventWindow_->set_sourceId(sourceId);
@@ -109,9 +162,9 @@ void UiState::setupEventWindowCallbacks()
});
mainWindow_->global().on_delete_event_clicked([&](int sourceId, int eventId) {
- auto resource = miraiInstance_->getResourceById(sourceId);
- assert(resource);
- auto event = resource->getEventById(eventId);
+ auto source = miraiInstance_->getSourceById(sourceId);
+ assert(source);
+ auto event = source->getEventById(eventId);
assert(event);
auto day = event->day();
assert(day);
@@ -124,9 +177,9 @@ void UiState::setupEventWindowCallbacks()
eventWindow_->on_create([&](NewEventParams newEventParams) {
const Date &date = newEventParams.date;
const std::string dateStr = SlintDateToStdString(date);
- auto resource = miraiInstance_->getResourceById(newEventParams.sourceId);
+ auto source = miraiInstance_->getSourceById(newEventParams.sourceId);
- auto day = resource->day(SlintDateToMiraiDate(date));
+ auto day = source->day(SlintDateToMiraiDate(date));
day->createEvent({
.description = std::string(newEventParams.title),
.date = SlintDateToMiraiDate(newEventParams.date),
@@ -142,9 +195,9 @@ void UiState::setupEventWindowCallbacks()
eventWindow_->on_save([&](SaveEventParams newEventParams) {
const Date &date = newEventParams.date;
const std::string dateStr = SlintDateToStdString(date);
- auto resource = miraiInstance_->getResourceById(newEventParams.sourceId);
- assert(resource);
- auto event = resource->getEventById(newEventParams.id);
+ auto source = miraiInstance_->getSourceById(newEventParams.sourceId);
+ assert(source);
+ auto event = source->getEventById(newEventParams.id);
assert(event);
event->setText(std::string(newEventParams.title));
event->setStartTime(SlintTimeToMiraiTime(newEventParams.startsAt));
@@ -174,22 +227,22 @@ void UiState::setupUtilsCallbacks()
void UiState::setupCallbacks()
{
mainWindow_->global().on_task_clicked([&](int sourceId, int taskId) {
- auto resource = miraiInstance_->getResourceById(sourceId);
- assert(resource);
- auto task = resource->getTaskById(taskId);
+ auto source = miraiInstance_->getSourceById(sourceId);
+ assert(source);
+ auto task = source->getTaskById(taskId);
assert(task);
task->getState() == mirai::DONE ? task->markAsUndone() : task->markAsDone();
miraiInstance_->save();
});
mainWindow_->global().on_source_clicked([&](int index) {
- const auto &source = miraiInstance_->getResourceById(index);
+ const auto &source = miraiInstance_->getSourceById(index);
const auto &sourceName = source->getName();
if (std::ranges::find(view_.getActiveFilesFilter(), sourceName) ==
view_.getActiveFilesFilter().end()) {
- view_.addResourceFilter(sourceName);
+ view_.addSourceFilter(sourceName);
} else {
- view_.removeResourceFilter(sourceName);
+ view_.removeSourceFilter(sourceName);
}
view_.update();
reloadTasks();
@@ -208,110 +261,58 @@ void UiState::setupCallbacks()
});
mainWindow_->global().on_delete_task_clicked([&](int sourceId, int taskId) {
- auto resource = miraiInstance_->getResourceById(sourceId);
- assert(resource);
- auto task = resource->getTaskById(taskId);
+ auto source = miraiInstance_->getSourceById(sourceId);
+ assert(source);
+ auto task = source->getTaskById(taskId);
assert(task);
- resource->deleteTask(*task);
+ source->deleteTask(*task);
miraiInstance_->save();
view_.update();
reloadTasks();
});
mainWindow_->global().on_open_edit_task_form([&](int sourceId, int taskId) {
- auto resource = miraiInstance_->getResourceById(sourceId);
- assert(resource);
- auto task = resource->getTaskById(taskId);
+ auto source = miraiInstance_->getSourceById(sourceId);
+ assert(source);
+ auto task = source->getTaskById(taskId);
assert(task);
- taskEditWindow_->set_taskResourceIndex(sourceId);
- taskEditWindow_->set_taskId(task->id());
- taskEditWindow_->set_taskTitle(slint::SharedString(task->getText()));
- taskEditWindow_->set_taskDate(MiraiDateToSlintDate(task->day()->getDate()));
+ taskWindow_->set_taskSourceIndex(sourceId);
+ taskWindow_->set_taskId(task->id());
+ taskWindow_->set_taskTitle(slint::SharedString(task->getText()));
+ taskWindow_->set_taskDate(MiraiDateToSlintDate(task->day()->getDate()));
- taskEditWindow_->on_save([&](SaveTaskData newTaskData) {
- auto resource = miraiInstance_->getResourceById(newTaskData.sourceId);
- assert(resource);
- auto task = resource->getTaskById(newTaskData.id);
- assert(task);
- const Date &date = newTaskData.date;
- const std::string dateStr = SlintDateToStdString(date);
- auto taskData = mirai::TodoMdFormat::stringToTask(
- "- [ ] " + std::string(newTaskData.title), dateStr
- );
-
- task->setText(taskData.text);
- if (task->day()->getDate() != SlintDateToMiraiDate(date)) {
- auto newDate = resource->day(SlintDateToMiraiDate(date));
- newDate->createTask({
- .text = taskData.text,
- .state = task->getState(),
- .tags = taskData.tags,
- });
- auto oldDate = task->day();
- resource->deleteTask(*task);
- }
- miraiInstance_->save();
- view_.update();
- reloadTasks();
- taskEditWindow_->hide();
- });
- taskEditWindow_->show();
+ taskWindow_->show();
});
mainWindow_->global().on_open_new_task_form([&](OpenNewTaskFormParams params) {
- taskEditWindow_->global().set_resources(resources_);
- taskEditWindow_->global().set_tags(tags_);
+ taskWindow_->global().set_sources(sources_);
+ taskWindow_->global().set_tags(tags_);
auto todayDate = std::chrono::year_month_day{
std::chrono::floor(std::chrono::system_clock::now())
};
- taskEditWindow_->set_taskId(-1);
- taskEditWindow_->set_eventId(params.eventId);
- taskEditWindow_->set_taskResourceIndex(
- params.eventSourceId == -1 ? 0 : params.eventSourceId
- );
- taskEditWindow_->set_taskTitle("");
+ taskWindow_->set_taskId(-1);
+ taskWindow_->set_eventId(params.eventId);
+ taskWindow_->set_taskSourceIndex(params.eventSourceId == -1 ? 0 : params.eventSourceId);
+ taskWindow_->set_taskTitle("");
if (params.eventId == -1) {
- taskEditWindow_->set_taskDate({
+ taskWindow_->set_taskDate({
.year = static_cast(todayDate.year()),
// Try to directly use `unsigned`
.month = static_cast(static_cast(todayDate.month())),
.day = static_cast(static_cast(todayDate.day())),
});
} else {
- auto resource = miraiInstance_->getResourceById(params.eventSourceId);
- assert(resource);
- auto event = resource->getEventById(params.eventId);
+ auto source = miraiInstance_->getSourceById(params.eventSourceId);
+ assert(source);
+ auto event = source->getEventById(params.eventId);
assert(event);
- taskEditWindow_->set_taskDate(MiraiDateToSlintDate(event->getDate()));
+ taskWindow_->set_taskDate(MiraiDateToSlintDate(event->getDate()));
}
- taskEditWindow_->on_create([&](NewTaskData newTaskData) {
- const Date &date = newTaskData.date;
- const std::string dateStr = SlintDateToStdString(date);
- auto resource = miraiInstance_->getResourceById(newTaskData.sourceId);
- auto task = mirai::TodoMdFormat::stringToTask(
- "- [ ] " + std::string(newTaskData.title), dateStr
- );
-
- if (newTaskData.eventId == -1) {
- auto day = resource->day(SlintDateToMiraiDate(date));
- assert(day);
- day->createTask(task);
- } else {
- auto event = resource->getEventById(newTaskData.eventId);
- assert(event);
- event->createTask(task);
- }
-
- miraiInstance_->save();
- view_.update();
- reloadTasks();
- taskEditWindow_->hide();
- });
- taskEditWindow_->show();
+ taskWindow_->show();
});
mainWindow_->global().on_toggle_show_completed_tasks([&] {
@@ -320,10 +321,11 @@ void UiState::setupCallbacks()
reloadTasks();
});
- mainWindow_->global().set_resources(resources_);
+ mainWindow_->global().set_sources(sources_);
mainWindow_->global().set_tags(tags_);
mainWindow_->global().set_visible_tasks(days_);
+ setupTaskWindowCallbacks();
setupEventWindowCallbacks();
setupUtilsCallbacks();
}
@@ -341,7 +343,7 @@ stdToSlintStringVector(const std::vector &stdVector)
void UiState::reloadTasks()
{
days_->clear();
- if (miraiInstance_->getResources().size() == 0) {
+ if (miraiInstance_->getSources().size() == 0) {
return;
}
auto todayDate = mirai::Date(std::chrono::system_clock::now());
@@ -411,11 +413,11 @@ void UiState::reloadTasks()
mainWindow_->global().set_visible_tasks(days_);
}
-void UiState::reloadResources()
+void UiState::reloadSources()
{
- resources_->clear();
- for (const auto &resource : miraiInstance_->getResources()) {
- resources_->push_back(slint::SharedString(resource->getName()));
+ sources_->clear();
+ for (const auto &source : miraiInstance_->getSources()) {
+ sources_->push_back(slint::SharedString(source->getName()));
}
}
diff --git a/src/UiState.h b/src/UiState.h
index 5197ef7..3c1da5d 100644
--- a/src/UiState.h
+++ b/src/UiState.h
@@ -19,21 +19,22 @@ class UiState
void run();
- void reloadResources();
+ void reloadSources();
void reloadTags();
void reloadTasks();
private:
void setupCallbacks();
+ void setupTaskWindowCallbacks();
void setupEventWindowCallbacks();
void setupUtilsCallbacks();
- std::shared_ptr> resources_;
+ std::shared_ptr> sources_;
std::shared_ptr> tags_;
std::shared_ptr> days_;
slint::ComponentHandle mainWindow_ = AppWindow::create();
- slint::ComponentHandle taskEditWindow_ = TaskEdit::create();
+ slint::ComponentHandle taskWindow_ = TaskWindow::create();
slint::ComponentHandle eventWindow_ = EventWindow::create();
mirai::Mirai *miraiInstance_;
diff --git a/src/main.cpp b/src/main.cpp
index a8612d5..dff6b91 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -7,7 +7,7 @@
#include "UiState.h"
#include "mirai-core/Config.h"
#include "mirai-core/Mirai.h"
-#include "mirai-core/StdFileResource.h"
+#include "mirai-core/StdFileSource.h"
#include
#include
@@ -18,10 +18,10 @@ int main(int argc, char **argv)
mirai::Mirai mirai;
for (const auto &sourceFilePath : config.sources()) {
- auto file = std::make_unique(
- mirai::BaseFileResourceConstructor{.name = sourceFilePath, .path = sourceFilePath}
+ auto file = std::make_unique(
+ mirai::BaseFileSourceConstructor{.name = sourceFilePath, .path = sourceFilePath}
);
- mirai.loadResource(std::move(file));
+ mirai.loadSource(std::move(file));
}
UiState uiState{&mirai};
diff --git a/tests/saving.cpp b/tests/saving.cpp
index 8e4ddce..c4d3ace 100644
--- a/tests/saving.cpp
+++ b/tests/saving.cpp
@@ -4,9 +4,9 @@
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
-#include "core/BaseFileResource.h"
+#include "core/BaseFileSource.h"
#include "core/Mirai.h"
-#include "core/StdFileResource.h"
+#include "core/StdFileSource.h"
#include "core/TaskItem.h"
#include "core/TodoMd.h"
#include
@@ -18,8 +18,8 @@ TEST_CASE("Saving data")
{
{
mirai::Mirai mirai;
- auto fileResource = std::make_unique(
- mirai::BaseFileResourceConstructor{.name = "Testing", .path = "testing.md"}
+ auto fileResource = std::make_unique(
+ mirai::BaseFileSourceConstructor{.name = "Testing", .path = "testing.md"}
);
mirai.loadResource(std::move(fileResource));
@@ -32,8 +32,8 @@ TEST_CASE("Saving data")
{
mirai::Mirai mirai;
- auto fileResource = std::make_unique(
- mirai::BaseFileResourceConstructor{.name = "Testing", .path = "testing.md"}
+ auto fileResource = std::make_unique(
+ mirai::BaseFileSourceConstructor{.name = "Testing", .path = "testing.md"}
);
mirai.loadResource(std::move(fileResource));
diff --git a/ui/Backend.slint b/ui/Backend.slint
index 511efaf..babac59 100644
--- a/ui/Backend.slint
+++ b/ui/Backend.slint
@@ -35,7 +35,7 @@ struct OpenNewTaskFormParams {
}
export global Backend {
- in-out property<[string]> resources;
+ in-out property<[string]> sources;
in-out property<[string]> tags;
in-out property<[Day]> visible_tasks;
diff --git a/ui/SideBar.slint b/ui/SideBar.slint
index 7a91e36..97408ac 100644
--- a/ui/SideBar.slint
+++ b/ui/SideBar.slint
@@ -13,7 +13,7 @@ export component SideBar inherits Rectangle {
}
VerticalLayout {
spacing: 4px;
- for item[index] in Backend.resources: ToggleButton {
+ for item[index] in Backend.sources: ToggleButton {
text: item;
text-alignment: left;
clicked => { Backend.source_clicked(index) }
diff --git a/ui/appwindow.slint b/ui/appwindow.slint
index c78b917..658417b 100644
--- a/ui/appwindow.slint
+++ b/ui/appwindow.slint
@@ -2,7 +2,7 @@ import { Backend } from "Backend.slint";
import { Button, VerticalBox, CheckBox, Palette } from "std-widgets.slint";
import { SideBar } from "SideBar.slint";
import { MainView } from "MainView.slint";
-import { TaskEdit } from "windows/TaskEdit.slint";
+import { TaskWindow } from "windows/TaskWindow.slint";
import { EventWindow } from "windows/EventWindow.slint";
export component AppWindow inherits Window {
@@ -23,4 +23,4 @@ export component AppWindow inherits Window {
}
-export { Backend, TaskEdit, EventWindow } // Export to make it visible to the C++ backend
+export { Backend, TaskWindow, EventWindow } // Export to make it visible to the C++ backend
diff --git a/ui/windows/EventWindow.slint b/ui/windows/EventWindow.slint
index 97438bd..4772527 100644
--- a/ui/windows/EventWindow.slint
+++ b/ui/windows/EventWindow.slint
@@ -29,7 +29,7 @@ export component EventWindow inherits Window {
default-font-size: 16px;
background: Palette.background;
- in-out property sourceId <=> resourceInput.current-index;
+ in-out property sourceId <=> sourceInput.current-index;
in-out property eventId: -1;
in-out property taskDate <=> taskDateInput.date;
in-out property taskTitle <=> taskTitleInput.text;
@@ -46,8 +46,8 @@ export component EventWindow inherits Window {
text: eventId == -1 ? "New event" : "Edit event";
}
- resourceInput := ComboBox {
- model: Backend.resources;
+ sourceInput := ComboBox {
+ model: Backend.sources;
enabled: eventId == -1;
}
diff --git a/ui/windows/TaskEdit.slint b/ui/windows/TaskWindow.slint
similarity index 86%
rename from ui/windows/TaskEdit.slint
rename to ui/windows/TaskWindow.slint
index 6abdaa0..2f16626 100644
--- a/ui/windows/TaskEdit.slint
+++ b/ui/windows/TaskWindow.slint
@@ -16,7 +16,7 @@ export struct SaveTaskData {
date: Date,
}
-export component TaskEdit inherits Window {
+export component TaskWindow inherits Window {
title: "Mirai - " + (taskId == -1 ? "New task" : "Edit task");
min-width: 100px;
max-width: 1920px;
@@ -30,7 +30,7 @@ export component TaskEdit inherits Window {
in-out property eventId: -1;
in-out property taskDate <=> taskDateInput.date;
in-out property taskTitle <=> taskTitleInput.text;
- in-out property taskResourceIndex <=> resourceInput.current-index;
+ in-out property taskSourceIndex <=> sourceInput.current-index;
callback create(NewTaskData);
callback save(SaveTaskData);
@@ -42,8 +42,8 @@ export component TaskEdit inherits Window {
text: taskId == -1 ? "New task" : "Edit task";
}
- resourceInput := ComboBox {
- model: Backend.resources;
+ sourceInput := ComboBox {
+ model: Backend.sources;
enabled: taskId == -1 && eventId == -1;
}
@@ -63,14 +63,14 @@ export component TaskEdit inherits Window {
clicked => {
if (taskId == -1) {
create({
- sourceId: taskResourceIndex,
+ sourceId: taskSourceIndex,
eventId: eventId,
title: taskTitle,
date: taskDate,
});
} else {
save({
- sourceId: taskResourceIndex,
+ sourceId: taskSourceIndex,
id: taskId,
title: taskTitle,
date: taskDate,