Warning, /pim/kube/views/todo/qml/TodoEditor.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright (C) 2018 Michael Bohlender, <bohlender@kolabsys.com> 0003 * 0004 * This program is free software; you can redistribute it and/or modify 0005 * it under the terms of the GNU General Public License as published by 0006 * the Free Software Foundation; either version 2 of the License, or 0007 * (at your option) any later version. 0008 * 0009 * This program is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU General Public License along 0015 * with this program; if not, write to the Free Software Foundation, Inc., 0016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 import QtQuick 2.9 0020 import QtQuick.Controls 2 0021 import QtQuick.Layouts 1.1 0022 import Qt.labs.settings 1.0 0023 0024 import org.kube.framework 1.0 as Kube 0025 0026 FocusScope { 0027 id: root 0028 0029 property bool editMode: false 0030 property bool doing: false 0031 property var controller: Kube.TodoController { 0032 complete: false 0033 doing: root.doing 0034 parentUid: root.parentUid 0035 } 0036 property var accountId: null 0037 property var currentFolder: null 0038 property var parentUid: null 0039 0040 Settings { 0041 id: settings 0042 category: "TodoEditor" 0043 property var lastUsedTodolist 0044 } 0045 0046 signal done() 0047 0048 function save() { 0049 controller.saveAction.execute() 0050 root.done() 0051 } 0052 0053 function discard() { 0054 controller.reload() 0055 root.done() 0056 } 0057 0058 implicitWidth: contentLayout.implicitWidth + 2 * Kube.Units.largeSpacing 0059 implicitHeight: contentLayout.implicitHeight + buttons.implicitHeight + 2 * Kube.Units.largeSpacing 0060 Keys.onEscapePressed: root.done() 0061 0062 Shortcut { 0063 enabled: root.visible 0064 sequences: [StandardKey.Save] 0065 onActivated: root.save() 0066 } 0067 0068 states: [ 0069 State { 0070 name: "edit" 0071 PropertyChanges { target: deleteButton; visible: true } 0072 PropertyChanges { target: abortButton; visible: false } 0073 PropertyChanges { target: saveButton; visible: true } 0074 PropertyChanges { target: discardButton; visible: true } 0075 PropertyChanges { target: createButton; visible: false } 0076 PropertyChanges { target: calendarSelector; visible: false } 0077 PropertyChanges { target: subtodoButton; visible: true } 0078 }, 0079 State { 0080 name: "new" 0081 PropertyChanges { target: deleteButton; visible: false } 0082 PropertyChanges { target: abortButton; visible: true } 0083 PropertyChanges { target: saveButton; visible: false } 0084 PropertyChanges { target: discardButton; visible: false } 0085 PropertyChanges { target: createButton; visible: true } 0086 PropertyChanges { target: calendarSelector; visible: true } 0087 PropertyChanges { target: subtodoButton; visible: false } 0088 } 0089 ] 0090 0091 state: editMode ? "edit" : "new" 0092 0093 ColumnLayout { 0094 id: contentLayout 0095 0096 anchors { 0097 fill: parent 0098 margins: Kube.Units.largeSpacing 0099 } 0100 0101 spacing: Kube.Units.largeSpacing 0102 0103 ColumnLayout { 0104 0105 spacing: Kube.Units.smallSpacing 0106 0107 RowLayout { 0108 Layout.fillWidth: true 0109 spacing: Kube.Units.smallSpacing 0110 0111 Kube.Label { 0112 visible: calendarSelector.visible 0113 text: qsTr("Create in:") 0114 } 0115 Kube.EntityComboBox { 0116 id: calendarSelector 0117 accountId: root.accountId 0118 type: "calendar" 0119 filter: {"contentTypes": "todo", "enabled": true} 0120 initialSelection: root.currentFolder ? root.currentFolder : settings.lastUsedTodolist 0121 onSelected: { 0122 if (!root.editMode) { 0123 controller.calendar = entity 0124 settings.lastUsedTodolist = identifier 0125 } 0126 } 0127 } 0128 0129 Item { 0130 Layout.fillWidth: true 0131 } 0132 0133 Kube.CheckBox { 0134 checked: controller.doing 0135 onCheckedChanged: { 0136 if (controller.doing != checked) { 0137 controller.doing = checked 0138 } 0139 } 0140 } 0141 0142 Kube.Label { 0143 text: qsTr("Doing") 0144 } 0145 } 0146 0147 Kube.HeaderField { 0148 id: titleEdit 0149 focus: true 0150 Layout.fillWidth: true 0151 placeholderText: qsTr("Todo Title") 0152 text: controller.summary 0153 onTextChanged: controller.summary = text 0154 Keys.onReturnPressed: { 0155 controller.saveAction.execute() 0156 root.done() 0157 } 0158 } 0159 0160 Kube.TextEditor { 0161 Layout.fillWidth: true 0162 Layout.fillHeight: true 0163 Layout.minimumHeight: Kube.Units.gridUnit * 4 0164 activeFocusOnTab: true 0165 0166 border.width: 0 0167 0168 placeholderText: "Description" 0169 initialText: controller.description 0170 onTextChanged: controller.description = text 0171 0172 Keys.onEscapePressed: saveButton.forceActiveFocus(Qt.TabFocusReason) 0173 } 0174 0175 Item { 0176 Layout.fillHeight: true 0177 Layout.fillWidth: true 0178 } 0179 0180 Kube.ListView { 0181 id: subTodoView 0182 width: parent.width 0183 Layout.preferredHeight: implicitHeight 0184 Layout.maximumHeight: implicitHeight 0185 Layout.fillWidth: true 0186 model: Kube.TodoModel { 0187 id: todoModel 0188 filter: { 0189 "calendars": [controller.calendarId], 0190 "parentUid": controller.uid 0191 } 0192 } 0193 0194 delegate: Kube.TodoListDelegate { 0195 summary: model.summary 0196 complete: model.complete 0197 date: model.date 0198 dueDate: model.dueDate 0199 domainObject: model.domainObject 0200 0201 height: Kube.Units.gridUnit * 2 + 2 * Kube.Units.smallSpacing 0202 subText: null 0203 subtextVisible: false 0204 currentDate: Kube.Context.currentDate 0205 pickerActive: false 0206 } 0207 } 0208 0209 Kube.TextButton { 0210 id: subtodoButton 0211 text: "+ " + qsTr("Add subtodo") 0212 textColor: Kube.Colors.highlightColor 0213 focus: true 0214 onClicked: { 0215 Kube.Fabric.postMessage(Kube.Messages.todoEditor, {"parentUid": controller.uid}) 0216 } 0217 } 0218 } 0219 0220 RowLayout { 0221 id: buttons 0222 0223 spacing: Kube.Units.smallSpacing 0224 0225 Kube.Button { 0226 id: deleteButton 0227 text: qsTr("Delete") 0228 onClicked: { 0229 controller.remove() 0230 root.done() 0231 } 0232 } 0233 0234 Kube.Button { 0235 id: abortButton 0236 text: qsTr("Abort") 0237 onClicked: { 0238 root.done() 0239 } 0240 } 0241 0242 Item { 0243 Layout.fillWidth: true 0244 } 0245 0246 Kube.Button { 0247 id: discardButton 0248 enabled: controller.modified 0249 text: qsTr("Discard Changes") 0250 onClicked: root.discard() 0251 } 0252 0253 Kube.PositiveButton { 0254 id: saveButton 0255 enabled: controller.modified 0256 text: qsTr("Save Changes") 0257 onClicked: root.save() 0258 } 0259 0260 Kube.PositiveButton { 0261 id: createButton 0262 text: qsTr("Create Todo") 0263 onClicked: { 0264 controller.saveAction.execute() 0265 root.done() 0266 } 0267 } 0268 } 0269 } 0270 }