Warning, /pim/kube/views/calendar/qml/View.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * Copyright (C) 2018 Michael Bohlender, <bohlender@kolabsys.com>
0003 * Copyright (C) 2019 Christian Mollekopf, <mollekopf@kolabsys.com>
0004 *
0005 * This program is free software; you can redistribute it and/or modify
0006 * it under the terms of the GNU General Public License as published by
0007 * the Free Software Foundation; either version 2 of the License, or
0008 * (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License along
0016 * with this program; if not, write to the Free Software Foundation, Inc.,
0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018 */
0019
0020 import QtQuick 2.9
0021 import QtQuick.Controls 2
0022 import QtQuick.Layouts 1.2
0023
0024 import org.kube.framework 1.0 as Kube
0025 import "dateutils.js" as DateUtils
0026
0027 Kube.View {
0028 id: root
0029
0030 property date selectedDate: Kube.Context.currentDate
0031
0032 onRefresh: {
0033 Kube.Fabric.postMessage(Kube.Messages.synchronize, {"type": "calendar"})
0034 Kube.Fabric.postMessage(Kube.Messages.synchronize, {"type": "event"})
0035 }
0036
0037 helpViewComponent: Kube.HelpPopup {
0038 ListModel {
0039 ListElement { description: qsTr("Jump to next week/month:"); shortcut: "j" }
0040 ListElement { description: qsTr("Jump to previous week/month:"); shortcut: "k" }
0041 }
0042 }
0043
0044 Shortcut {
0045 enabled: root.isCurrentView
0046 sequences: ['j', StandardKey.Forward, StandardKey.MoveToNextLine, StandardKey.MoveToNextChar]
0047 onActivated: root.goToNext()
0048 }
0049
0050 Shortcut {
0051 enabled: root.isCurrentView
0052 sequences: ['k', StandardKey.Back, StandardKey.MoveToPreviousLine, StandardKey.MoveToPreviousChar]
0053 onActivated: root.goToPrevious()
0054 }
0055
0056 function goToNext() {
0057 if (weekViewButton.checked) {
0058 root.selectedDate = DateUtils.nextWeek(root.selectedDate)
0059 } else {
0060 root.selectedDate = DateUtils.nextMonth(root.selectedDate)
0061 }
0062 }
0063 function goToPrevious() {
0064 if (weekViewButton.checked) {
0065 root.selectedDate = DateUtils.previousWeek(root.selectedDate)
0066 } else {
0067 root.selectedDate = DateUtils.previousMonth(root.selectedDate)
0068 }
0069 }
0070 RowLayout {
0071 Kube.LeftSidebar {
0072 Layout.fillHeight: parent.height
0073 buttons: [
0074 Kube.PositiveButton {
0075 id: newEventButton
0076 objectName: "newEventButton"
0077
0078 Layout.fillWidth: true
0079 focus: true
0080 text: qsTr("New Event")
0081 onClicked: eventPopup.createObject(root, {start: DateUtils.sameDay(Kube.Context.currentDate, root.selectedDate) ? Kube.Context.currentDate : root.selectedDate}).open()
0082 },
0083 RowLayout {
0084 Layout.fillWidth: true
0085 spacing: Kube.Units.smallSpacing
0086 ButtonGroup {
0087 id: viewButtonGroup
0088 }
0089 Kube.TextButton {
0090 id: weekViewButton
0091 Layout.fillWidth: true
0092 text: qsTr("Week")
0093 textColor: Kube.Colors.highlightedTextColor
0094 checkable: true
0095 checked: true
0096 ButtonGroup.group: viewButtonGroup
0097 }
0098 Kube.TextButton {
0099 id: monthViewButton
0100 Layout.fillWidth: true
0101 text: qsTr("Month")
0102 textColor: Kube.Colors.highlightedTextColor
0103 checkable: true
0104 ButtonGroup.group: viewButtonGroup
0105 }
0106 },
0107 DateView {
0108 Layout.fillWidth: true
0109 date: Kube.Context.currentDate
0110 MouseArea {
0111 anchors.fill: parent
0112 onClicked: {
0113 root.selectedDate = Kube.Context.currentDate
0114 }
0115 }
0116 },
0117 DateSelector {
0118 id: dateSelector
0119 Layout.fillWidth: true
0120 selectedDate: root.selectedDate
0121 onSelected: {
0122 root.selectedDate = date
0123 }
0124 function next() {
0125 root.goToNext()
0126 }
0127 function previous() {
0128 root.goToPrevious()
0129 }
0130 }
0131 ]
0132
0133 Kube.CalendarSelector {
0134 id: accountSwitcher
0135 objectName: "calendarSelector"
0136 Layout.fillWidth: true
0137 Layout.fillHeight: true
0138 contentType: "event"
0139 }
0140 }
0141
0142 WeekView {
0143 visible: weekViewButton.checked
0144 Layout.fillHeight: true
0145 Layout.fillWidth: true
0146 currentDate: Kube.Context.currentDate
0147 startDate: DateUtils.getFirstDayOfWeek(root.selectedDate)
0148 calendarFilter: accountSwitcher.enabledEntities
0149 }
0150
0151 MonthView {
0152 visible: monthViewButton.checked
0153 Layout.fillHeight: true
0154 Layout.fillWidth: true
0155 currentDate: Kube.Context.currentDate
0156 startDate: DateUtils.getFirstDayOfWeek(DateUtils.getFirstDayOfMonth(root.selectedDate))
0157 month: root.selectedDate.getMonth()
0158 calendarFilter: accountSwitcher.enabledEntities
0159 }
0160 }
0161
0162 Kube.Listener {
0163 filter: Kube.Messages.eventEditor
0164 onMessageReceived: eventPopup.createObject(root, message).open()
0165 }
0166
0167 Component {
0168 id: eventPopup
0169 Kube.Popup {
0170 id: popup
0171
0172 property alias start: editor.start
0173 property alias allDay: editor.allDay
0174
0175 x: root.width * 0.15
0176 y: root.height * 0.15
0177
0178 width: root.width * 0.7
0179 height: root.height * 0.7
0180 padding: 0
0181 Rectangle {
0182 anchors.fill: parent
0183 color: Kube.Colors.paperWhite
0184 EventEditor {
0185 id: editor
0186 anchors.fill: parent
0187 onDone: popup.close()
0188 accountId: Kube.Context.currentAccountId
0189 }
0190 }
0191 }
0192 }
0193 }