2024-04-10 16:53:18 +02:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Window
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import Mirai
|
|
|
|
|
2024-04-12 16:38:22 +02:00
|
|
|
ScrollView {
|
|
|
|
id: scroll
|
|
|
|
clip: true
|
|
|
|
contentHeight: layout.height
|
2024-04-10 16:53:18 +02:00
|
|
|
|
2024-04-12 16:38:22 +02:00
|
|
|
ColumnLayout {
|
|
|
|
id: layout
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
|
|
|
QtObject {
|
|
|
|
id: internal
|
|
|
|
property string todayDate: Qt.formatDate(new Date(), 'yyyy-MM-dd')
|
|
|
|
property string tomorrowDate: Qt.formatDate(new Date(new Date().setDate(new Date().getDate() + 1)), 'yyyy-MM-dd')
|
|
|
|
}
|
2024-04-10 16:53:18 +02:00
|
|
|
|
2024-04-12 16:38:22 +02:00
|
|
|
Repeater {
|
|
|
|
model: backend.tasks
|
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: childrenRect.height
|
|
|
|
id: task
|
|
|
|
required property var modelData
|
|
|
|
required property int index
|
|
|
|
color: "transparent"
|
2024-04-10 16:53:18 +02:00
|
|
|
|
2024-04-12 16:38:22 +02:00
|
|
|
HoverHandler {
|
|
|
|
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
}
|
|
|
|
|
2024-04-10 16:53:18 +02:00
|
|
|
|
2024-04-12 16:38:22 +02:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2024-04-10 16:53:18 +02:00
|
|
|
|
2024-04-12 16:38:22 +02:00
|
|
|
Component {
|
|
|
|
id: dateForTasks
|
|
|
|
AppText {
|
|
|
|
topPadding: 32
|
|
|
|
bottomPadding: 16
|
|
|
|
text: task.modelData.date === internal.todayDate ? "Today"
|
|
|
|
: task.modelData.date === internal.tomorrowDate ? "Tomorrow"
|
|
|
|
: task.modelData.date
|
2024-08-09 21:12:35 +02:00
|
|
|
color: task.modelData.date < internal.todayDate ? colorPalette.selected.red
|
2024-04-12 16:38:22 +02:00
|
|
|
// : task.modelData.date === internal.todayDate ? colorPalette.selected.palette.sapphire
|
|
|
|
: colorPalette.selected.text
|
|
|
|
font.pointSize: 24
|
|
|
|
}
|
2024-04-10 16:53:18 +02:00
|
|
|
}
|
|
|
|
|
2024-04-12 16:38:22 +02:00
|
|
|
Loader {
|
|
|
|
sourceComponent: task.modelData.shouldShowDate ? dateForTasks : undefined
|
|
|
|
}
|
|
|
|
|
|
|
|
TaskItem {
|
|
|
|
id: taskItem
|
|
|
|
task: task.modelData
|
|
|
|
}
|
2024-04-10 16:53:18 +02:00
|
|
|
}
|
|
|
|
|
2024-04-12 16:38:22 +02:00
|
|
|
Menu {
|
|
|
|
id: contextMenu
|
|
|
|
MenuItem {
|
|
|
|
text: "Edit"
|
|
|
|
onClicked: {
|
|
|
|
root.editTask(task.modelData, task.index)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: "Delete"
|
|
|
|
onClicked: {
|
|
|
|
backend.removeTodo(task.index)
|
|
|
|
}
|
2024-04-10 16:53:18 +02:00
|
|
|
}
|
|
|
|
}
|
2024-04-12 16:38:22 +02:00
|
|
|
MouseArea {
|
|
|
|
id: mouse
|
|
|
|
anchors.fill: parent
|
|
|
|
acceptedButtons: Qt.RightButton
|
2024-04-10 16:53:18 +02:00
|
|
|
onClicked: {
|
2024-04-12 16:38:22 +02:00
|
|
|
contextMenu.popup()
|
2024-04-10 16:53:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|