Warning, /plasma-mobile/calindori/src/contents/ui/DayView.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2020 Dimitris Kardarakos <dimkard@posteo.net>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 import QtQuick 2.7
0008 import QtQuick.Controls 2.0 as Controls2
0009 import QtQuick.Layouts 1.3
0010 import org.kde.kirigami 2.12 as Kirigami
0011 import org.kde.calindori 0.1 as Calindori
0012 
0013 ListView {
0014     id: root
0015 
0016     property date selectedDate: Calindori.CalendarController.localSystemDateTime()
0017     property var cal
0018     property bool wideScreen
0019 
0020     signal nextDay
0021     signal previousDay
0022     signal goToday
0023     signal addEvent
0024     signal addTodo
0025 
0026     /**
0027     * @brief Remove the editor page from the stack. If an incidence page exists in the page stack, remove it as well
0028     *
0029     */
0030     function removeEditorPage() {
0031         pageStack.pop();
0032         if(pageStack.lastItem && pageStack.lastItem.hasOwnProperty("isIncidencePage")) {
0033             pageStack.pop(incidencePage);
0034         }
0035     }
0036 
0037     onNextDay: {
0038         var next = selectedDate;
0039         next.setDate(selectedDate.getDate() + 1)
0040         selectedDate = next;
0041     }
0042 
0043     onPreviousDay: {
0044         var prev = selectedDate;
0045         prev.setDate(selectedDate.getDate() - 1)
0046         selectedDate = prev;
0047     }
0048 
0049     onGoToday: {
0050         selectedDate = Calindori.CalendarController.localSystemDateTime();
0051         currentIndex = selectedDate.getHours();
0052     }
0053 
0054     onCurrentIndexChanged: {
0055         if (pageStack.depth > 1) {
0056             pageStack.pop(null);
0057         }
0058     }
0059 
0060     model: 24
0061     currentIndex: selectedDate.getHours()
0062 
0063     delegate: Kirigami.SwipeListItem {
0064         id: hourListItem
0065 
0066         property var hour: model.index
0067 
0068         alwaysVisibleActions: false
0069 
0070         contentItem: RowLayout {
0071             spacing: Kirigami.Units.largeSpacing * 2
0072 
0073             Controls2.Label {
0074                 text: model.index < 10 ? "0" + model.index + ":00" : model.index + ":00"
0075                 Layout.minimumWidth: Kirigami.Units.gridUnit * 2
0076             }
0077 
0078             ColumnLayout {
0079                 Repeater {
0080                     model: Calindori.IncidenceModel {
0081                         appLocale: _appLocale
0082                         filterDt: root.selectedDate
0083                         filterHour: hourListItem.hour
0084                         filterMode: 1
0085                     }
0086 
0087                     IncidenceItemDelegate {
0088                         itemBackgroundColor: model.type === 0 ? Kirigami.Theme.backgroundColor : Qt.darker(Kirigami.Theme.backgroundColor, 1.1)
0089                         label: model.summary
0090                         subtitle: (model.type == 0 ? model.displayStartEndTime : (model.displayDueTime || model.displayStartTime))
0091                         Layout.fillWidth: true
0092 
0093                         onClicked: {
0094                             if(pageStack.lastItem && pageStack.lastItem.hasOwnProperty("isIncidencePage")) {
0095                                 pageStack.pop(incidencePage);
0096                             }
0097 
0098                             pageStack.push(incidencePage, { incidence: model });
0099                         }
0100                     }
0101                 }
0102             }
0103         }
0104 
0105         actions: [
0106             Kirigami.Action {
0107                 iconName: "resource-calendar-insert"
0108                 text: i18n("Create Event")
0109 
0110                 onTriggered: {
0111                     var eventDt = selectedDate;
0112                     eventDt.setHours(index);
0113                     eventDt.setMinutes(0);
0114                     eventDt.setSeconds(0);
0115 
0116                     pageStack.push(eventEditor, { startDt: eventDt });
0117                 }
0118             },
0119 
0120             Kirigami.Action {
0121                 iconName: "task-new"
0122                 text: i18n("Create Task")
0123 
0124                 onTriggered: {
0125                     var todoDt = selectedDate;
0126                     todoDt.setHours(index);
0127                     todoDt.setMinutes(0);
0128                     todoDt.setSeconds(0);
0129 
0130                     pageStack.push(todoEditor, { startDt: todoDt });
0131                 }
0132             }
0133         ]
0134     }
0135 
0136     Component {
0137         id: incidencePage
0138 
0139         IncidencePage {
0140             calendar: root.cal
0141         }
0142     }
0143 
0144     Component {
0145         id: eventEditor
0146 
0147         EventEditorPage {
0148             calendar: root.cal
0149 
0150             onEditcompleted: removeEditorPage()
0151         }
0152     }
0153 
0154     Component {
0155         id: todoEditor
0156 
0157         TodoEditorPage {
0158             onEditcompleted: removeEditorPage()
0159         }
0160     }
0161 }