From 6ef9740db9fb9ec599507f82585cab0d2c8b3e46 Mon Sep 17 00:00:00 2001 From: Vyn Date: Fri, 12 Apr 2024 16:38:22 +0200 Subject: [PATCH] Add scrollbar for tasks --- src/qml/DateField.qml | 1 - src/qml/views/ListView.qml | 143 +++++++++++++++++++------------------ 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/src/qml/DateField.qml b/src/qml/DateField.qml index 969d6e2..965fa3d 100644 --- a/src/qml/DateField.qml +++ b/src/qml/DateField.qml @@ -63,7 +63,6 @@ Rectangle { Component.onCompleted: set(new Date()) // today onClicked: { const formattedDate = Qt.formatDate(date, 'yyyy-MM-dd') - print('onClicked', formattedDate) newTodoDate.text = formattedDate datePicker.close() } diff --git a/src/qml/views/ListView.qml b/src/qml/views/ListView.qml index 4aa2c95..1e27333 100644 --- a/src/qml/views/ListView.qml +++ b/src/qml/views/ListView.qml @@ -10,89 +10,90 @@ import QtQuick.Controls import QtQuick.Layouts import Mirai -ColumnLayout { +ScrollView { + id: scroll + clip: true + contentHeight: layout.height - 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') - } + 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') + } - Repeater { - model: backend.tasks - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: childrenRect.height - id: task - required property var modelData - required property int index - color: "transparent" + Repeater { + model: backend.tasks + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: childrenRect.height + id: task + required property var modelData + required property int index + color: "transparent" - HoverHandler { - acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad - cursorShape: Qt.PointingHandCursor - } - - - ColumnLayout { - anchors.left: parent.left - anchors.right: parent.right - - Component { - id: dateForTasks - AppText { - topPadding: 32 - bottomPadding: 16 - text: task.modelData.date === internal.todayDate ? "Today" - : task.modelData.date === internal.tomorrowDate ? "Tomorrow" - : task.modelData.date - color: task.modelData.date < internal.todayDate ? colorPalette.selected.palette.pink - // : task.modelData.date === internal.todayDate ? colorPalette.selected.palette.sapphire - : colorPalette.selected.text - font.pointSize: 24 - } - } - - Loader { - sourceComponent: task.modelData.shouldShowDate ? dateForTasks : undefined + HoverHandler { + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad + cursorShape: Qt.PointingHandCursor } - TaskItem { - id: taskItem - task: task.modelData - } - } - Menu { - id: contextMenu - MenuItem { - text: "Edit" - onClicked: { - root.editTask(task.modelData, task.index) + ColumnLayout { + anchors.left: parent.left + anchors.right: parent.right + + Component { + id: dateForTasks + AppText { + topPadding: 32 + bottomPadding: 16 + text: task.modelData.date === internal.todayDate ? "Today" + : task.modelData.date === internal.tomorrowDate ? "Tomorrow" + : task.modelData.date + color: task.modelData.date < internal.todayDate ? colorPalette.selected.palette.pink + // : task.modelData.date === internal.todayDate ? colorPalette.selected.palette.sapphire + : colorPalette.selected.text + font.pointSize: 24 + } + } + + Loader { + sourceComponent: task.modelData.shouldShowDate ? dateForTasks : undefined + } + + TaskItem { + id: taskItem + task: task.modelData } } - MenuItem { - text: "Delete" - onClicked: { - backend.removeTodo(task.index) + + Menu { + id: contextMenu + MenuItem { + text: "Edit" + onClicked: { + root.editTask(task.modelData, task.index) + } + } + MenuItem { + text: "Delete" + onClicked: { + backend.removeTodo(task.index) + } } } - } - - MouseArea { - id: mouse - anchors.fill: parent - acceptedButtons: Qt.RightButton - propagateComposedEvents: true - onClicked: { - contextMenu.popup() + MouseArea { + id: mouse + anchors.fill: parent + acceptedButtons: Qt.RightButton + onClicked: { + contextMenu.popup() + } } } } } - Item { - Layout.fillHeight: true - } } - -