Warning, /pim/kube/views/calendar/qml/EventEditor.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.4
0021 import QtQuick.Layouts 1.1
0022
0023 import org.kube.framework 1.0 as Kube
0024 import "dateutils.js" as DateUtils
0025
0026 Item {
0027 id: root
0028
0029 property bool editMode: false
0030 property date start: new Date()
0031 property bool allDay: false
0032 property var controller: Kube.EventController { allDay: root.allDay }
0033 property var accountId: null
0034
0035 signal done()
0036
0037 function discard() {
0038 controller.reload()
0039 root.done()
0040 }
0041
0042 implicitWidth: contentLayout.implicitWidth + 2 * Kube.Units.largeSpacing
0043 implicitHeight: contentLayout.implicitHeight + buttons.implicitHeight + 2 * Kube.Units.largeSpacing
0044
0045 states: [
0046 State {
0047 name: "edit"
0048 PropertyChanges { target: deleteButton; visible: true }
0049 PropertyChanges { target: abortButton; visible: false }
0050 PropertyChanges { target: saveButton; visible: true }
0051 PropertyChanges { target: discardButton; visible: true }
0052 PropertyChanges { target: createButton; visible: false }
0053 PropertyChanges { target: calendarSelector; visible: false }
0054 },
0055 State {
0056 name: "new"
0057 PropertyChanges { target: deleteButton; visible: false }
0058 PropertyChanges { target: abortButton; visible: true }
0059 PropertyChanges { target: saveButton; visible: false }
0060 PropertyChanges { target: discardButton; visible: false }
0061 PropertyChanges { target: createButton; visible: true }
0062 PropertyChanges { target: calendarSelector; visible: true }
0063 }
0064 ]
0065
0066 state: editMode ? "edit" : "new"
0067
0068 ColumnLayout {
0069 id: contentLayout
0070
0071 anchors {
0072 fill: parent
0073 margins: Kube.Units.largeSpacing
0074 }
0075
0076 spacing: Kube.Units.largeSpacing
0077
0078 ColumnLayout {
0079
0080 spacing: Kube.Units.largeSpacing
0081
0082 Kube.HeaderField {
0083 id: titleEdit
0084 Layout.fillWidth: true
0085 placeholderText: qsTr("Event Title")
0086 text: controller.summary
0087 onTextChanged: controller.summary = text
0088 }
0089
0090 DateRangeChooser {
0091 id: dateAndTimeChooser
0092 Layout.fillWidth: true
0093 initialStart: root.editMode ? controller.start : root.start
0094 initialEnd: root.editMode ? controller.end : DateUtils.addMinutesToDate(root.start, 30)
0095 allDay: controller.allDay
0096 onStartChanged: controller.start = start
0097 onEndChanged: controller.end = end
0098 onAllDayChanged: controller.allDay = allDay
0099 }
0100
0101 ColumnLayout {
0102 spacing: Kube.Units.smallSpacing
0103 Layout.fillWidth: true
0104
0105 Kube.TextField {
0106 Layout.fillWidth: true
0107 placeholderText: qsTr("Location")
0108 text: controller.location
0109 onTextChanged: controller.location = text
0110 }
0111
0112 RowLayout {
0113 visible: attendees.count
0114 Layout.maximumWidth: parent.width
0115 Layout.fillWidth: true
0116 Kube.Label {
0117 id: fromLabel
0118 text: qsTr("Organizer:")
0119 }
0120
0121 Kube.ComboBox {
0122 id: identityCombo
0123 objectName: "identityCombo"
0124
0125 width: parent.width - Kube.Units.largeSpacing * 2
0126
0127 model: root.controller.identitySelector.model
0128 textRole: "address"
0129 Layout.fillWidth: true
0130 //A regular binding is not enough in this case, we have to use the Binding element
0131 Binding { target: identityCombo; property: "currentIndex"; value: root.controller.identitySelector.currentIndex }
0132 onCurrentIndexChanged: {
0133 root.controller.identitySelector.currentIndex = currentIndex
0134 }
0135 }
0136 }
0137
0138 AttendeeListEditor {
0139 id: attendees
0140 Layout.fillWidth: true
0141 Layout.fillHeight: true
0142 focus: true
0143 activeFocusOnTab: true
0144 controller: root.controller.attendees
0145 completer: root.controller.attendeeCompleter
0146 }
0147
0148 Kube.SeparatorLine {
0149 Layout.fillWidth: true
0150 }
0151
0152 Kube.TextEditor {
0153 Layout.fillWidth: true
0154 Layout.fillHeight: true
0155 Layout.minimumHeight: Kube.Units.gridUnit * 4
0156
0157 border.width: 0
0158
0159 placeholderText: "Description"
0160 initialText: controller.description
0161 onTextChanged: controller.description = text
0162
0163 Keys.onEscapePressed: calendarSelector.forceActiveFocus(Qt.TabFocusReason)
0164 }
0165 }
0166 }
0167
0168 RowLayout {
0169 id: buttons
0170
0171 spacing: Kube.Units.largeSpacing
0172
0173 Kube.Button {
0174 id: deleteButton
0175 text: qsTr("Delete")
0176 onClicked: {
0177 controller.remove()
0178 root.done()
0179 }
0180 }
0181
0182 Kube.Button {
0183 id: abortButton
0184 text: qsTr("Abort")
0185 onClicked: {
0186 root.done()
0187 }
0188 }
0189
0190 Item {
0191 Layout.fillWidth: true
0192 }
0193
0194 Kube.EntityComboBox {
0195 id: calendarSelector
0196 accountId: root.accountId
0197 type: "calendar"
0198 filter: {"contentTypes": "event", "enabled": true}
0199 onSelected: {
0200 if (!root.editMode) {
0201 controller.calendar = entity
0202 }
0203 }
0204 }
0205
0206 Kube.Button {
0207 id: discardButton
0208 enabled: controller.modified
0209 text: qsTr("Discard Changes")
0210 onClicked: root.discard()
0211 }
0212
0213 Kube.PositiveButton {
0214 id: saveButton
0215 enabled: controller.modified
0216 text: qsTr("Save Changes")
0217 onClicked: {
0218 controller.saveAction.execute()
0219 root.done()
0220 }
0221 }
0222
0223 Kube.PositiveButton {
0224 id: createButton
0225 text: qsTr("Create Event")
0226 onClicked: {
0227 controller.saveAction.execute()
0228 root.done()
0229 }
0230 }
0231 }
0232 }
0233 }