MauiKit Calendar

EventPage.qml
1import QtQuick
2import QtQml
3import QtQuick.Controls
4import QtQuick.Layouts
5import org.mauikit.controls as Maui
6import org.mauikit.calendar as Cal
7
8/**
9 * @inherit QtQuick.Controls.Pane
10 * @brief A view field for creating a new calendar event.
11 *
12 * @image html eventpage.png
13 *
14 * @code
15 *
16 * @endcode
17 */
18Pane
19{
20 id: control
21
22 implicitHeight: _layout.implicitHeight + topPadding + bottomPadding
23
24 padding: 0
25 background: null
26
27 /**
28 * @brief
29 */
30 property alias incidence : incidenceWrapper
31
32 Cal.IncidenceWrapper
33 {
34 id: incidenceWrapper
35
36 onIncidenceStartChanged:
37 {
38 incidenceStartDateCombo.selectedDate = control.incidence.incidenceStart;
39 incidenceStartTimeCombo.selectedTime = incidenceWrapper.incidenceStart;
40 incidenceStartDateCombo.displayText = incidenceWrapper.incidenceStartDateDisplay;
41 incidenceStartTimeCombo.displayText = incidenceWrapper.incidenceStartTimeDisplay;
42 }
43
44 onIncidenceEndChanged:
45 {
46 incidenceEndDateCombo.selectedDate = control.incidence.incidenceEnd;
47 incidenceEndTimeCombo.selectedTime = incidenceWrapper.incidenceEnd;
48 incidenceEndDateCombo.displayText = incidenceWrapper.incidenceEndDateDisplay;
49 incidenceEndTimeCombo.displayText = incidenceWrapper.incidenceEndTimeDisplay;
50 }
51 }
52
53 contentItem: Maui.ScrollColumn
54 {
55 id: _layout
56
57 Maui.SectionGroup
58 {
59 title: i18n("Info")
60
62 {
63 label1.text: i18n("Description")
64
65 TextField
66 {
67 Layout.fillWidth: true
68 height: 80
69 text: incidenceWrapper.summary
70 placeholderText: i18n(`Add a title for your ${incidenceWrapper.incidenceTypeStr.toLowerCase()}`)
71 onTextChanged: incidenceWrapper.summary = text
72
73 onAccepted : incidenceWrapper.summary = text
74 }
75 }
76
78 {
79 label1.text: i18n("Calendar")
80
81 ComboBox
82 {
83 id: calendarCombo
84 Layout.fillWidth: true
85 textRole: "display"
86 valueRole: "collectionColor"
87
88 model: Cal.CollectionComboBoxModel
89 {
90 id: collectionComboBoxModel
91 onCurrentIndexChanged: calendarCombo.currentIndex = currentIndex
92 defaultCollectionId: incidenceWrapper.collectionId;
93
94 mimeTypeFilter: if (incidenceWrapper.incidenceType === Cal.IncidenceWrapper.TypeEvent)
95 {
96 return [Cal.MimeTypes.calendar]
97 } else if (incidenceWrapper.incidenceType === Cal.IncidenceWrapper.TypeTodo) {
98 return [Cal.MimeTypes.todo]
99 }
100 accessRightsFilter: Cal.Collection.CanCreateItem
101 }
102
103 currentIndex: 0
104 onCurrentIndexChanged: if (currentIndex !== -1) {
105 const collection = model.data(model.index(currentIndex, 0), Cal.Collection.CollectionRole);
106 if (collection) {
107 incidenceWrapper.setCollection(collection)
108 }
109 }
110 }
111 }
112 }
113
114
115 Maui.SectionGroup
116 {
117 title: i18n("Time")
118
120 {
121 label1.text: i18n("All day")
122 enabled: !isNaN(incidenceWrapper.incidenceStart.getTime()) || !isNaN(incidenceWrapper.incidenceEnd.getTime())
123
124 Switch
125 {
126 id: allDayCheckBox
127 checked: incidenceWrapper.allDay
128 onToggled:
129 {
130 if (!checked)
131 {
132 incidenceWrapper.setIncidenceTimeToNearestQuarterHour();
133 }
134 incidenceWrapper.allDay = checked;
135 }
136 }
137 }
138
139 Maui.SectionItem
140 {
141 label1.text: i18n("Start")
142
143 Cal.DateComboBox
144 {
145 id: incidenceStartDateCombo
146 Layout.fillWidth: true
147 displayText: incidenceWrapper.incidenceStartDateDisplay
148 selectedDate: incidenceWrapper.incidenceStart
149 onDatePicked:
150 {
151 console.log("DATE PCIKED", date.getDate(), date.getMonth(), date.getYear())
152 incidenceWrapper.setIncidenceStartDate(date.getDate(), date.getMonth(), date.getYear())
153 }
154
155 }
156
157 Cal.TimeComboBox
158 {
159 id: incidenceStartTimeCombo
160 Layout.fillWidth: true
161 visible: !allDayCheckBox.checked
162
163 timeZoneOffset: incidenceWrapper.startTimeZoneUTCOffsetMins
164 displayText: incidenceWrapper.incidenceEndTimeDisplay
165 selectedTime: incidenceWrapper.incidenceStart
166 onTimePicked:
167 {
168 console.log("TIME PICKER", time.getHours(), time.getMinutes())
169 incidenceWrapper.setIncidenceStartTime(time.getHours(), time.getMinutes())
170 }
171 }
172
173
174 }
175
176 Maui.SectionItem
177 {
178 label1.text: i18n("End")
179
180 Cal.DateComboBox
181 {
182 id: incidenceEndDateCombo
183 Layout.fillWidth: true
184 displayText: incidenceWrapper.incidenceStartDateDisplay
185 selectedDate: incidenceWrapper.incidenceStart
186 onDatePicked:
187 {
188 incidenceWrapper.setIncidenceEndDate(date.getDate(), date.getMonth(), date.getYear())
189 }
190
191 }
192
193 Cal.TimeComboBox
194 {
195 id: incidenceEndTimeCombo
196 Layout.fillWidth: true
197 visible: !allDayCheckBox.checked
198 timeZoneOffset: incidenceWrapper.endTimeZoneUTCOffsetMins
199 displayText: incidenceWrapper.incidenceEndTimeDisplay
200 selectedTime: incidenceWrapper.incidenceEnd
201 onTimePicked:
202 {
203 incidenceWrapper.setIncidenceEndTime(hours, minutes)
204 }
205 }
206
207
208 }
209
210 Maui.SectionItem
211 {
212 label1.text: i18n("TimeZone")
213
214 ComboBox
215 {
216 Layout.fillWidth: true
217 model: Cal.TimeZoneListModel
218 {
219 id: timeZonesModel
220 }
221
222 textRole: "display"
223 valueRole: "id"
224 currentIndex: model ? timeZonesModel.getTimeZoneRow(incidenceWrapper.timeZone) : -1
225
226 onActivated: incidenceWrapper.timeZone = currentValue
227 }
228 }
229 }
230 }
231
232}
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:35:11 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.